Browse Source

update example library

master
heck 5 years ago
parent
commit
b7be3b7dbe
  1. 2
      gen/data/input/synth_shed/main.c
  2. 22
      gen/data/input/synth_shed/synth_shed.c
  3. 13
      gen/data/input/synth_shed/synth_shed.h

2
gen/data/input/synth_shed/main.c

@ -7,7 +7,9 @@ int main() {
init_synth_shed(); init_synth_shed();
synth_t* my_synth = synth_create("UltraBoog"); synth_t* my_synth = synth_create("UltraBoog");
printf("%s", play_synth(my_synth));
synth_set_osc_count(my_synth, 33);
printf("%s", play_synth(my_synth)); printf("%s", play_synth(my_synth));
return 0; return 0;

22
gen/data/input/synth_shed/synth_shed.c

@ -10,19 +10,29 @@ void init_synth_shed() {
synth_t* synth_create(const char* name) { synth_t* synth_create(const char* name) {
synth_t* new = (synth_t*) malloc(sizeof(synth_t)); synth_t* new = (synth_t*) malloc(sizeof(synth_t));
assert(new);
if (new != NULL) { if (new != NULL) {
new->model_name = name; new->model_name = name;
new->osc_count = 1; new->osc_count = 1;
new->technolgy = ANALOG; new->technolgy = ANALOG;
new->filter.technology = ANALOG; new->filter.technology = ANALOG;
new->filter->type = LPF; new->filter.type = LPF;
} }
return new; return new;
} }
//SYNTH_STATUS synth_set_osc_count(synth_t* synth, SYNTH_STATUS synth_set_osc_count(synth_t* synth, int osc_count) {
// 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, //SYNTH_STATUS synth_set_filter(synth_t* synth,
// filter_t* filt); // filter_t* filt);
// //
@ -69,8 +79,8 @@ const char* play_synth(synth_t* synth) {
const char* tech = tech_to_string(&synth->technolgy); const char* tech = tech_to_string(&synth->technolgy);
const char* filt_tech = tech_to_string(&synth->filter.technology); const char* filt_tech = tech_to_string(&synth->filter.technology);
const char* filt_type = filtertype_to_string(synth->filter->type); const char* filt_type = filtertype_to_string(&synth->filter.type);
sprintf(ret, "%s\nnamed: %s\nosc: %s\ntech:%s\nfilt:%s / %s\n", greet, model, osc, tech, filt_tech, filt_type); sprintf(ret, "%s\nnamed: %s\nosc: %s\ntech:%s\nfilt:%s / %s\n\n", greet, model, osc, tech, filt_tech, filt_type);
return strdup(ret); return strdup(ret);
} }

13
gen/data/input/synth_shed/synth_shed.h

@ -6,7 +6,7 @@
typedef int SYNTH_STATUS; typedef int SYNTH_STATUS;
typedef enum _filtertype filtertype_t; typedef enum _filtertype filtertype_t;
typedef struct _synth synth_t; typedef struct _synth synth_t;
typedef synth_t synth;
// Enums // Enums
enum _filtertype { enum _filtertype {
HPF, HPF,
@ -22,7 +22,7 @@ typedef enum _tech {
// Structs // Structs
typedef struct _filter { typedef struct _filter {
tech_t technology; tech_t technology;
filtertype_t *type; filtertype_t type;
} filter_t; } filter_t;
@ -39,9 +39,8 @@ void init_synth_shed();
synth_t* synth_create(const char* name); synth_t* synth_create(const char* name);
//SYNTH_STATUS synth_set_osc_count(synth_t* synth, SYNTH_STATUS synth_set_osc_count(synth_t* synth, int osc_count);
// int osc_count);
//
//SYNTH_STATUS synth_set_filter(synth_t* synth, //SYNTH_STATUS synth_set_filter(synth_t* synth,
// filter_t* filt); // filter_t* filt);
// //
@ -50,9 +49,9 @@ synth_t* synth_create(const char* name);
const char* tech_to_string(const tech_t* tech); const char* tech_to_string(const tech_t* tech);
const char* filtertype_to_string(const filtertype_t *filt); const char* filtertype_to_string(const filtertype_t* filt);
const char* play_synth(synth_t *synth); const char* play_synth(synth_t* synth);
#endif //SYNTH_SHED_H #endif //SYNTH_SHED_H

Loading…
Cancel
Save