diff --git a/examples/ext/synth_shed/synth_shed/Makefile b/examples/ext/synth_shed/synth_shed/Makefile index 0588ea6..9429807 100644 --- a/examples/ext/synth_shed/synth_shed/Makefile +++ b/examples/ext/synth_shed/synth_shed/Makefile @@ -40,7 +40,6 @@ $(TARGET_MODULE_STATIC) : $(OBJS) $(LIBS_STATIC) $(CXX) $(LDFLAGS_STATIC) -o $@ $^ clean: - $(MAKE) -C gen clean rm -f $(TARGET) rm -f $(OBJS) diff --git a/examples/lib/lib_synth_shed/main.c b/examples/lib/lib_synth_shed/main.c index db8c62c..3036031 100644 --- a/examples/lib/lib_synth_shed/main.c +++ b/examples/lib/lib_synth_shed/main.c @@ -2,15 +2,24 @@ #include +//void synth_init(synth_t *sfac) { +// sfac = synth_create("UltraBoog"); +//} int main() { init_synth_shed(); +// synth_t* newsynth = NULL; +// synth_init(newsynth); - synth_t* my_synth = synth_create("UltraBoog"); + synth_t* my_synth = synth_create("Korg", "MS20", 2); + printf("brand %s\n", my_synth->brand); + printf("model %s\n", my_synth->model); printf("%s", play_synth(my_synth)); synth_set_osc_count(my_synth, 33); printf("%s", play_synth(my_synth)); + return 0; } + diff --git a/examples/lib/lib_synth_shed/synth_shed.c b/examples/lib/lib_synth_shed/synth_shed.c index 7088ec5..86f05bf 100644 --- a/examples/lib/lib_synth_shed/synth_shed.c +++ b/examples/lib/lib_synth_shed/synth_shed.c @@ -8,17 +8,19 @@ void init_synth_shed() { printf("init_synth_shed() - called\n"); } -synth_t* synth_create(const char* name) { - synth_t* new = (synth_t*) malloc(sizeof(synth_t)); - assert(new); - if (new != NULL) { - new->model_name = "TESTNAME"; - new->osc_count = 1; - new->technolgy = ANALOG; - new->filter.technology = ANALOG; - new->filter.type = LPF; +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; + return new_synth; } SYNTH_STATUS synth_set_osc_count(synth_t* synth, int osc_count) { @@ -33,11 +35,9 @@ SYNTH_STATUS synth_set_osc_count(synth_t* synth, int osc_count) { } -//SYNTH_STATUS synth_set_filter(synth_t* synth, -// filter_t* filt); -// -//SYNTH_STATUS synth_set_tech(synth_t* synth, -// tech_t tech); +//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); @@ -72,7 +72,8 @@ const char* play_synth(synth_t* synth) { assert(synth); char ret[9999]; const char* greet = "Playing synth:"; - const char* model = synth->model_name; + const char* brand = synth->brand; + const char* model = synth->model; char osc[4]; sprintf(osc, "%i", synth->osc_count); @@ -81,6 +82,6 @@ const char* play_synth(synth_t* synth) { const char* filt_tech = tech_to_string(&synth->filter.technology); const char* filt_type = filtertype_to_string(&synth->filter.type); - sprintf(ret, "%s\nnamed: %s\nosc: %s\ntech:%s\nfilt:%s / %s\n\n", greet, model, osc, tech, filt_tech, filt_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); } diff --git a/examples/lib/lib_synth_shed/synth_shed.h b/examples/lib/lib_synth_shed/synth_shed.h index 3af47d4..3a74ccc 100644 --- a/examples/lib/lib_synth_shed/synth_shed.h +++ b/examples/lib/lib_synth_shed/synth_shed.h @@ -31,7 +31,8 @@ typedef struct _filter { } filter_t; struct _synth { - const char* model_name; + const char* brand; + const char* model; int osc_count; tech_t technolgy; filter_t filter; @@ -41,15 +42,16 @@ struct _synth { // Functions void init_synth_shed(); -synth_t* synth_create(const char* name); +synth_t* synth_create(const char* brand, const char* model, int osc_count); + +// This function covers the problem of a pointer to pointer arg +SYNTH_STATUS synth_create_pp(synth_t** new_synth); SYNTH_STATUS synth_set_osc_count(synth_t* synth, int osc_count); -//SYNTH_STATUS synth_set_filter(synth_t* synth, -// filter_t* filt); -// -//SYNTH_STATUS synth_set_tech(synth_t* synth, -// tech_t tech); +//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);