diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2023-11-26 16:37:54 +0200 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2023-11-26 16:37:54 +0200 |
commit | fb31c071fe835c5ffd1f70d3558acecee2ed7f17 (patch) | |
tree | 914baaab271de13d086428634a4834a4a08a6926 | |
parent | 8d17aa29baf0b33229dbdd82d8d5f6cbe3fe0240 (diff) | |
download | synth-project-fb31c071fe835c5ffd1f70d3558acecee2ed7f17.tar.gz synth-project-fb31c071fe835c5ffd1f70d3558acecee2ed7f17.tar.bz2 synth-project-fb31c071fe835c5ffd1f70d3558acecee2ed7f17.zip |
Make synth a pointer
-rw-r--r-- | src/synth.c | 9 | ||||
-rw-r--r-- | src/synth_engine.h | 4 | ||||
-rw-r--r-- | src/synth_engine_v2.c | 13 |
3 files changed, 15 insertions, 11 deletions
diff --git a/src/synth.c b/src/synth.c index ea4a8f7..f7ae019 100644 --- a/src/synth.c +++ b/src/synth.c @@ -42,16 +42,15 @@ int main(void) { - synth_t synth; midi_t midi; - init_synth(&synth); - init_midi(&midi, &synth); + synth_t * synth = init_synth(); + init_midi(&midi, synth); - rayrun(&synth); + rayrun(synth); terminate_midi(&midi); - free_synth(&synth); + free_synth(synth); return 0; } diff --git a/src/synth_engine.h b/src/synth_engine.h index d01331f..34f90b2 100644 --- a/src/synth_engine.h +++ b/src/synth_engine.h @@ -94,7 +94,7 @@ typedef struct { int octave; int delay; - float del[SAMPLE_RATE * 10]; + float * del; int deli; float del_time; float del_feedback; @@ -119,7 +119,7 @@ typedef struct { osc_t * osctri; } synth_t; -void init_synth(synth_t * synth); +synth_t * init_synth(); void free_synth(synth_t * synth); #endif /* SYNTH_ENGINE_H */ diff --git a/src/synth_engine_v2.c b/src/synth_engine_v2.c index 726839f..a3c6efa 100644 --- a/src/synth_engine_v2.c +++ b/src/synth_engine_v2.c @@ -331,9 +331,12 @@ m_init_synth(synth_t * synth) } -void -init_synth(synth_t * synth) +synth_t * +init_synth(void) { + synth_t * synth = (synth_t *)malloc(sizeof(synth_t)); + if (!synth) return NULL; + synth->cci = 0; CC(synth->cc_cutoff, "cutoff", 10, 22000, 30, 5000); CC(synth->cc_resonance, "resonance", 1, 10, .02, 1); @@ -379,7 +382,7 @@ init_synth(synth_t * synth) synth->octave = 3; synth->delay = 0; - synth->del[SAMPLE_RATE * 10]; + synth->del = (float *) calloc(sizeof(float), SAMPLE_RATE * 30); synth->deli = 0; synth->del_time = .1; synth->del_feedback = 0.5f; @@ -442,7 +445,9 @@ free_synth(synth_t * synth) free(synth->viz.fft_output_buffer); free(synth->viz.fft_smooth_buffer); - //free(synth->ring_data); free_bw_low_pass(synth->fff); free_bw_band_stop(synth->fff2); + + free(synth->del); + free(synth); } |