Browse Source

lib_synth_shed - add brand/model, for having a create_synth() with multiple char * args (for YML gen testing)

master
heck 5 years ago
parent
commit
ffaed67f12
  1. 1
      examples/ext/synth_shed/synth_shed/Makefile
  2. 11
      examples/lib/lib_synth_shed/main.c
  3. 35
      examples/lib/lib_synth_shed/synth_shed.c
  4. 16
      examples/lib/lib_synth_shed/synth_shed.h

1
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)

11
examples/lib/lib_synth_shed/main.c

@ -2,15 +2,24 @@
#include <stdio.h>
//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;
}

35
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);
}

16
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);

Loading…
Cancel
Save