You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

87 lines
2.2 KiB

#include "synth_shed.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
void init_synth_shed() {
printf("init_synth_shed() - called\n");
}
synth_t* synth_create(const char* brand, const char* model, int osc_count) {
printf("%s::%s brand:'%s, model: %s'\n",__FILE__, __FUNCTION__, brand, model);
synth_t* new_synth = (synth_t*) malloc(sizeof(synth_t));
assert(new_synth);
if (new_synth != NULL) {
new_synth->brand = brand;
new_synth->model = model;
new_synth->osc_count = osc_count;
new_synth->technolgy = ANALOG;
new_synth->filter.technology = ANALOG;
new_synth->filter.type = LPF;
}
return new_synth;
}
SYNTH_STATUS synth_set_osc_count(synth_t* synth, int osc_count) {
assert(synth);
SYNTH_STATUS status = 0;
if (osc_count < 0) {
status = 1;
} else {
synth->osc_count = osc_count;
}
return status;
}
//SYNTH_STATUS synth_set_filter(synth_t* synth, filter_t* filt);
//SYNTH_STATUS synth_set_tech(synth_t* synth, tech_t tech);
const char* tech_to_string(const enum _tech* tech) {
assert(tech);
const char* ret = "unknown tech";
if (*tech == ANALOG) {
return "ANALOG";
}
if (*tech == DIGITAL) {
return "DIGITAL";
}
return ret;
}
const char* filtertype_to_string(const filtertype_t* const filt) {
assert(filt);
const char* ret = "unknown filtertype";
if (*filt == LPF) {
ret = "LPF";
}
if (*filt == HPF) {
ret = "HPF";
}
if (*filt == BPF) {
ret = "BPF";
}
return ret;
}
const char* play_synth(synth_t* synth) {
assert(synth);
char ret[9999];
const char* greet = "Playing synth:";
const char* brand = synth->brand;
const char* model = synth->model;
char osc[4];
sprintf(osc, "%i", synth->osc_count);
const char* tech = tech_to_string(&synth->technolgy);
const char* filt_tech = tech_to_string(&synth->filter.technology);
const char* filt_type = filtertype_to_string(&synth->filter.type);
sprintf(ret, "%s\nbrand: %s\nmodel: %s\nosc: %s\ntech:%s\nfilt:%s / %s\n\n", greet, brand,model, osc, tech, filt_tech, filt_type);
return strdup(ret);
}