summaryrefslogtreecommitdiffstats
path: root/src/synth_gui.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/synth_gui.c')
-rw-r--r--src/synth_gui.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/synth_gui.c b/src/synth_gui.c
index ee4ae05..ca1acc9 100644
--- a/src/synth_gui.c
+++ b/src/synth_gui.c
@@ -23,6 +23,7 @@ keyboard(void *synthData, PaStream *stream)
synth->midi_note[i].velocity = 1.0;
synth->midi_note[i].elapsed = 0;
synth->midi_note[i].active = 1;
+
//synth->adsr.elapsed = 0;
synth->active = 1;
}
@@ -30,6 +31,7 @@ keyboard(void *synthData, PaStream *stream)
for (int i = 0; keys[i]; i++) {
if (IsKeyReleased(keys[i])) {
synth->midi_note[i].noteOff = Pa_GetStreamTime(synth->stream);
+ synth->midi_note[i].noteOffSample = synth->midi_note[i].elapsed;
note = notes[i % 12][(synth->octave + (i / 12)) % 8];
}
}
@@ -56,6 +58,9 @@ keyboard(void *synthData, PaStream *stream)
if (synth->modifiers[i] == KEY_V) {
cc_step(&synth->cc_lfo_freq, 1);
}
+ if (synth->modifiers[i] == KEY_B) {
+ cc_step(&synth->cc_lfo_amp, 1);
+ }
}
}
if (IsKeyDown(264)) { // down
@@ -72,6 +77,9 @@ keyboard(void *synthData, PaStream *stream)
if (synth->modifiers[i] == KEY_V) {
cc_step(&synth->cc_lfo_freq, -1);
}
+ if (synth->modifiers[i] == KEY_B) {
+ cc_step(&synth->cc_lfo_amp, -1);
+ }
}
}
if (IsKeyDown(KEY_ENTER)) { // down
@@ -88,6 +96,9 @@ keyboard(void *synthData, PaStream *stream)
if (synth->modifiers[i] == KEY_V) {
cc_reset(&synth->cc_lfo_freq);
}
+ if (synth->modifiers[i] == KEY_B) {
+ cc_reset(&synth->cc_lfo_amp);
+ }
}
}
}
@@ -131,21 +142,21 @@ draw_signals(synth_t * synth, int x, int y, int width, int height)
DrawCircle(i , y + height / 2 + floor(250 * synth->viz.wave[i - x]), point_radius, MAGENTA);
}
- 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++) {
- for (int j = 0; j < MIDI_NOTES; j++) {
- if (!synth->midi_note[j].active)
- continue;
+/* 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++) { */
+/* 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);
- }
- }
+/* DrawCircle(i , y + height - 1 + 4.5*floor((WIDTH / 24) * - fix_adsr(&synth->adsr, synth->midi_note[j].noteOn, synth->midi_note[j].noteOff, (i - x) * (adsr_duration * SAMPLE_RATE) / WIDTH, synth->midi_note[j].noteOffSample)), point_radius, BLUE); */
+/* } */
+/* } */
for (int i = x; i < WIDTH - x; i++) {
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);
+ DrawCircle(i , y + height - 1 + 4.5*floor((WIDTH / 24) * - fix_adsr(&synth->adsr, synth->midi_note[j].noteOn, synth->midi_note[j].noteOff, synth->midi_note[j].elapsed, synth->midi_note[j].noteOffSample)), point_radius, GREEN);
}
}
}
@@ -188,6 +199,10 @@ rayrun(void *synthData)
DrawText(buf, WIDTH / 2 - 108, 150 - 42, 20, LIGHTGRAY);
snprintf(buf, sizeof buf, "filter reso %.4f", synth->cc_resonance.value);
DrawText(buf, WIDTH / 2 - 108, 150 - 62, 20, LIGHTGRAY);
+ snprintf(buf, sizeof buf, "lfo amp %.4f", synth->cc_lfo_amp.value);
+ DrawText(buf, WIDTH / 2 - 108, 150 - 22, 20, LIGHTGRAY);
+ snprintf(buf, sizeof buf, "lfo freq %.4f", synth->cc_lfo_freq.value);
+ DrawText(buf, WIDTH / 2 - 108, 150 - 102, 20, LIGHTGRAY);
/* snprintf(buf, sizeof buf, "freq offset %.1f", synth->freq_offset); */
/* DrawText(buf, WIDTH / 2 - 108, 150 - 42, 20, LIGHTGRAY); */
/* synth->freq_offset = GuiSlider((Rectangle){ WIDTH / 2 - 108, 150 - 42, 216, 24 }, "fine", buf, synth->freq_offset , -20.0f, 20.0f); */
@@ -210,7 +225,7 @@ rayrun(void *synthData)
GuiSpinner((Rectangle){ WIDTH - 100 - 50 , 50, 100, 24 }, "oct: ", &(synth->octave), 0, 7, 0);
snprintf(buf, sizeof buf, "generator %d --> ", synth->geni);
- GuiSpinner((Rectangle){ WIDTH - 100 - 50 , 50 + 24 + 6, 100, 24 }, buf, &(synth->geni), 0, 3, 0);
+ GuiSpinner((Rectangle){ WIDTH - 100 - 50 , 50 + 24 + 6, 100, 24 }, buf, &(synth->geni), 0, 6, 0);
synth->clamp = GuiToggle((Rectangle){ WIDTH - 100 - 50, 50 + 24 + 6 + 24 + 6, 100, 24 }, "clamp", synth->clamp);
@@ -218,7 +233,7 @@ rayrun(void *synthData)
// signals
draw_signals(synth, 20, 390, WIDTH - 2*20, 200);
- DrawText("THE SYNTH!!!!!!!!!!!!!!!!!!1", WIDTH / 2 - 100, 50, 20, LIGHTGRAY);
+ //DrawText("THE SYNTH!!!!!!!!!!!!!!!!!!1", WIDTH / 2 - 100, 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);