diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2023-04-29 14:34:48 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2023-04-29 14:34:48 +0300 |
commit | 0cceb2057e382129ae24565fdefff87e91b076ab (patch) | |
tree | 36676e98fecc6bf0a0ee80dbab21331dddc372d7 /src/synth_gui.c | |
parent | 402f6791150d503fc29ed75a7b8be9abfdd3867f (diff) | |
download | synth-project-0cceb2057e382129ae24565fdefff87e91b076ab.tar.gz synth-project-0cceb2057e382129ae24565fdefff87e91b076ab.tar.bz2 synth-project-0cceb2057e382129ae24565fdefff87e91b076ab.zip |
self contained adsr
Diffstat (limited to 'src/synth_gui.c')
-rw-r--r-- | src/synth_gui.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/synth_gui.c b/src/synth_gui.c index 2405d57..df219ba 100644 --- a/src/synth_gui.c +++ b/src/synth_gui.c @@ -100,22 +100,23 @@ draw_signals(synth_t * synth, int x, int y, int width, int height) for (int i = x; i < WIDTH - x; i++) { DrawCircle(i , y + height / 2 + floor(250 * synth->viz.wave[i - x]), point_radius, MAGENTA); } - if (synth->multi) { - for (int i = x; i < WIDTH - x; i++) { - //DrawCircle(i , y + height / 2 + floor(50 * make_sample(i - x, synth, SAMPLE_RATE / synth->viz.sample_rate_divider, 1)), point_radius, RED); - } - } else { - for (int i = x; i < WIDTH - x; i++) { - //DrawCircle(i , y + height / 2 + floor(50 * make_sample((i - x) % period, synth, SAMPLE_RATE / synth->viz.sample_rate_divider, 1)), point_radius, RED); - } - } for (int i = x; i < WIDTH - x; i++) { - //DrawCircle(i , y + height - 1+ floor((WIDTH / 24) * - adsr_amplitude(synth, synth->adsr.elapsed, synth->n.noteOn, synth->n.noteOff)), point_radius, GREEN); + for (int j = 0; j < MIDI_NOTES; j++) { + if (!synth->midi_note[j].active) + continue; + + DrawCircle(i , y + height - 1 + 4.5*floor((WIDTH / 24) * - adsr_amplitude(&synth->adsr, synth->midi_note[j].noteOn, synth->midi_note[j].noteOff, synth->midi_note[j].elapsed)), point_radius, GREEN); + } } float adsr_duration = synth->adsr.a + synth->adsr.d + (synth->adsr.a + synth->adsr.d + synth->adsr.r) / 3.0 + synth->adsr.r; for (int i = x; i < WIDTH - x; i++) { - //DrawCircle(i , y + height - 1 + floor((WIDTH / 24) * - adsr_amplitude(synth, (i - x) * (adsr_duration * SAMPLE_RATE) / WIDTH, synth->n.noteOn, synth->n.noteOff)), point_radius, BLUE); + for (int j = 0; j < MIDI_NOTES; j++) { + if (!synth->midi_note[j].active) + continue; + + DrawCircle(i , y + height - 1 + 4.5*floor((WIDTH / 24) * - adsr_amplitude(&synth->adsr, synth->midi_note[j].noteOn, synth->midi_note[j].noteOff, (i - x) * (adsr_duration * SAMPLE_RATE) / WIDTH)), point_radius, BLUE); + } } } @@ -181,9 +182,9 @@ rayrun(void *synthData) draw_signals(synth, 20, 390, WIDTH - 2*20, 200); DrawText("THE SYNTH!!!!!!!!!!!!!!!!!!1", WIDTH / 2 - 100, 50, 20, LIGHTGRAY); - DrawText("KEYBOARD: Q .. ] TOGGLE MULTI: ENTER", WIDTH / 2 -300, HEIGHT - 20 - 50, 20, LIGHTGRAY); - snprintf(buf, sizeof buf, "%f", synth->viz.wave[0]); - DrawText(buf, WIDTH / 2 -300, HEIGHT - 40 - 50, 20, LIGHTGRAY); + DrawText("KEYBOARD: Q .. ] TOGGLE MULTI: ENTER", WIDTH / 2 -300, HEIGHT - 300 - 50, 20, LIGHTGRAY); + snprintf(buf, sizeof buf, "%f stream time: %f", synth->viz.wave[0], Pa_GetStreamTime(synth->stream)); + DrawText(buf, WIDTH / 2 -300, HEIGHT - 300, 20, LIGHTGRAY); EndDrawing(); //---------------------------------------------------------------------------------- |