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.c52
1 files changed, 21 insertions, 31 deletions
diff --git a/src/synth_gui.c b/src/synth_gui.c
index da90f52..62a6ab7 100644
--- a/src/synth_gui.c
+++ b/src/synth_gui.c
@@ -364,42 +364,32 @@ void
draw_osc(synth_t * synth, int x, int y, int width, int height)
{
DrawRectangle(x, y, width, height, BLACK);
- DrawRectangleLines(x, y, width, height, WHITE);
+ DrawRectangleLines(x, y, width, height, GRAY);
+
float osc_wave[width];
+ float osc_max = 0;
+
for (int i = 0; i < width; i++) {
osc_wave[i] = 0;
}
- for (int i = 0; i < synth->midi_active_n; i++) {
- midi_note_t * note = synth->midi_active[i];
- midi_note_t note_dup;
- note_dup.freq = note->freq;
- note_dup.channel = note->channel;
- note_dup.noteOn = note->noteOn;
- note_dup.noteOff = note->noteOff;
- note_dup.velocity = note->velocity;
- note_dup.wvt_index = 0;
- note_dup.lfo_index = note->lfo_index;
- note_dup.elapsed = note->elapsed;
- note_dup.noteOffSample = note->noteOffSample;
- note_dup.adsr = note->adsr;
- note_dup.active = note->active;
- for (int i = 0; i < width; i++) {
- float freq = SAMPLE_RATE/(float)width;
- osc_wave[i] += synth->gen[synth->geni](freq, &note_dup, synth->x, SAMPLE_RATE);
- }
- break;
+ midi_note_t note_dup = {0};
+ for (int i = 0; i < width; i++) {
+ float freq = SAMPLE_RATE/(float)width;
+ osc_wave[i] += synth->gen[synth->geni](freq, &note_dup, synth->x, SAMPLE_RATE);
}
- float max = 0;
for (int i = 0; i < width; i++) {
- if (fabs(osc_wave[i]) > max) max = fabs(osc_wave[i]);
+ if (fabs(osc_wave[i]) > osc_max) osc_max = fabs(osc_wave[i]);
}
- if (synth->midi_active_n) {
- for (int i = 0; i < width; i++) {
- DrawPixel(i + x , y + height / 2.0 + floor(height/2.0 * osc_wave[i] / max), RED);
- }
+ Color color = GRAY;
+ if (synth->midi_active_n > 0) {
+ color = RED;
+ }
+ for (int i = 0; i < width; i++) {
+ //DrawPixel(i + x , y + height / 2.0 + floor(height/2.0 * osc_wave[i] / osc_max), WHITE);
+ DrawCircle(i + x , y + height / 2.0 + floor(height/2.0 * osc_wave[i] / osc_max), 2, color);
}
}
@@ -603,11 +593,6 @@ draw_signals(synth_t * synth, int x, int y, int width, int height)
draw_adsr(synth, x, y, width, height);
}
- synth->viz.osc_enabled = GuiCheckBox((Rectangle){ x + width - 170, y, 16, 16 }, "osc", synth->viz.osc_enabled);
- if (synth->viz.osc_enabled) {
- draw_osc(synth, x + width - 80, y + height - 80, 80, 80);
- }
-
synth->viz.adsr_graph_enabled = GuiCheckBox((Rectangle){ x + width - 270, y, 16, 16 }, "adsr graph", synth->viz.adsr_graph_enabled);
if (synth->viz.adsr_graph_enabled) {
draw_adsr_graph(synth, x + 20, y + 20, width - 40, height - 40);
@@ -951,6 +936,11 @@ draw_main(synth_t *synth)
draw_bars(synth, 20, 20, 200, 16, 3);
draw_text(synth, WIDTH / 2 - 108, 20);
+ //synth->viz.osc_enabled = GuiCheckBox((Rectangle){ x + width - 170, y, 16, 16 }, "osc", synth->viz.osc_enabled);
+ if (synth->viz.osc_enabled) {
+ draw_osc(synth, WIDTH / 2 + 180, 140, 80, 80);
+ }
+
if ( GuiButton((Rectangle){ WIDTH / 2.0 - 108, 150 - 6 - 6 + 42, 216, 6 }, "")) {
synth->x = 1;
}