From 560356027650af8cd3dcc21888cdc3a76382ea5d Mon Sep 17 00:00:00 2001 From: gramanas Date: Tue, 18 Apr 2023 23:01:22 +0300 Subject: Fix adsr at 0 A and add active switch --- src/synth_gui.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/synth_gui.c') diff --git a/src/synth_gui.c b/src/synth_gui.c index 3cfde6f..f92c853 100644 --- a/src/synth_gui.c +++ b/src/synth_gui.c @@ -15,6 +15,7 @@ set_note(void *synthData, float note, PaTime time, int key) synth->n.noteOff = 0; synth->n.elapsed = 0; synth->adsr.elapsed = 0; + synth->active = 1; } @@ -53,7 +54,7 @@ draw_adsr_sliders(synth_t * synth, int x, int y, int width, int height, int offs int count = 0; snprintf(buf, sizeof buf, "%.3f", synth->adsr.a); - synth->adsr.a = GuiSliderBar((Rectangle){ x, y + count++ * (height + offset), width, height }, "A: ", buf, synth->adsr.a , 0.001f, 2.0f); + synth->adsr.a = GuiSliderBar((Rectangle){ x, y + count++ * (height + offset), width, height }, "A: ", buf, synth->adsr.a , 0.0f, 2.0f); snprintf(buf, sizeof buf, "%.3f", synth->adsr.d); synth->adsr.d = GuiSliderBar((Rectangle){ x, y + count++ * (height + offset), width, height }, "D: ", buf, synth->adsr.d , 0.001f, 2.0f); snprintf(buf, sizeof buf, "%.3f", synth->adsr.s); @@ -82,7 +83,6 @@ draw_signals(synth_t * synth, int x, int y, int width, int height) } } else { for (int i = x; i < WIDTH - x; i++) { - //DrawCircle((WIDTH - (1 / (synth->n.freq + 1)) * SAMPLE_RATE) / 2 + i , (HEIGHT / 2) + floor(50 * make_sample(i % period, synth, SAMPLE_RATE)), point_radius, RED); DrawCircle(i , y + height / 2 + floor(50 * make_sample((i - x) % period, synth, SAMPLE_RATE / synth->viz.sample_rate_divider, 1)), point_radius, RED); } } @@ -129,19 +129,19 @@ rayrun(void *synthData, PaStream *stream) synth->freq_offset = 0; } snprintf(buf, sizeof buf, "%.1f", synth->freq_offset); - synth->freq_offset = GuiSliderBar((Rectangle){ WIDTH / 2 - 108, 150 - 42, 216, 24 }, "fine", buf, synth->freq_offset , -20.0f, 20.0f); + synth->freq_offset = GuiSlider((Rectangle){ WIDTH / 2 - 108, 150 - 42, 216, 24 }, "fine", buf, synth->freq_offset , -20.0f, 20.0f); if ( GuiButton((Rectangle){ WIDTH / 2 - 108, 150 - 6 - 6, 216, 6 }, "")) { synth->gain = 1; } snprintf(buf, sizeof buf, "%.1f", synth->gain); - synth->gain = GuiSliderBar((Rectangle){ WIDTH / 2 - 108, 150, 216, 24 }, "gain", buf, synth->gain , 0.0f, 2.0f); + synth->gain = GuiSlider((Rectangle){ WIDTH / 2 - 108, 150, 216, 24 }, "gain", buf, synth->gain , 0.0f, 2.0f); if ( GuiButton((Rectangle){ WIDTH / 2 - 108, 150 - 6 - 6 + 42, 216, 6 }, "")) { synth->x = 1; } snprintf(buf, sizeof buf, "%.1f", synth->x); - synth->x = GuiSliderBar((Rectangle){ WIDTH / 2 - 108, 150 + 42, 216, 24 }, "x", buf, synth->x , 0.0f, 2.0f); + synth->x = GuiSlider((Rectangle){ WIDTH / 2 - 108, 150 + 42, 216, 24 }, "x", buf, synth->x , 0.0f, 2.0f); synth->multi = GuiToggle((Rectangle){ WIDTH - 100 - 50 - 100 - 50 , 50, 100, 24 }, "!MULTI!", synth->multi); synth->filter = GuiToggle((Rectangle){ WIDTH - 100 - 50 - 100 - 50 , 50 + 24 + 6, 100, 24 }, "FILTER", synth->filter); -- cgit v1.2.3