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.c36
1 files changed, 4 insertions, 32 deletions
diff --git a/src/synth_gui.c b/src/synth_gui.c
index d09a9b6..6b44595 100644
--- a/src/synth_gui.c
+++ b/src/synth_gui.c
@@ -14,16 +14,9 @@ set_note(void *synthData, float note, PaTime time, int key)
synth->n.noteOn = time;
synth->n.noteOff = 0;
synth->n.elapsed = 0;
- if (synth->poly) {
- if (!synth->notes_active) synth->adsr.elapsed = 0;
- } else {
- synth->adsr.elapsed = 0;
- }
+ synth->adsr.elapsed = 0;
synth->active = 1;
-
- synth->freq[synth->notes_active] = note;
- synth->freq_count[synth->notes_active++] = 0;
}
@@ -43,35 +36,11 @@ keyboard(void *synthData, PaStream *stream)
set_note(synth, note, Pa_GetStreamTime(stream), keys[i]);
//printf("Note On : %s[%d] %fHz\n", int_to_note(i % 12), (synth->octave + (i / 12)) % 8, note);
}
- printf("[");
- for (int j = 0; j < synth->notes_active; j++) {
- printf("%f ", synth->freq[j]);
- }
- printf("]\n");
}
}
for (int i = 0; keys[i]; i++) {
if (IsKeyReleased(keys[i])) {
note = notes[i % 12][(synth->octave + (i / 12)) % 8];
- int j;
- for (j = 0; j < synth->notes_active; j++) {
- // printf("Comparing freq(j): %f to note: %f\n", synth->freq[j], note);
- if (synth->freq[j] == note) {
- synth->freq[j] = 0;
- synth->notes_active--;
- //printf("Note down %f\n", note);
- break;
- }
- }
- for (int k = j; k < synth->notes_active + 1; k++) {
- //printf("moving %f <-- %f\n", synth->freq[k], synth->freq[k + 1]);
- synth->freq[k] = synth->freq[k + 1];
- }
- printf("[");
- for (int j = 0; j < synth->notes_active; j++) {
- printf("%f ", synth->freq[j]);
- }
- printf("]\n");
if (synth->n.key == keys[i]) {
synth->n.noteOff = Pa_GetStreamTime(stream);
//printf("Note Off: %s[%d]\n", int_to_note(i % 12), (synth->octave + (i / 12)) % 8);
@@ -112,6 +81,9 @@ draw_signals(synth_t * synth, int x, int y, int width, int height)
GuiSpinner((Rectangle){ x+ 100, y - 24 - 6, 100, 24 }, "rate divider: ", &(synth->viz.sample_rate_divider), 1, 10, 0);
int period = (1 / (synth->n.freq + 1)) * SAMPLE_RATE / synth->viz.sample_rate_divider;
+ for (int i = x; i < WIDTH - x; i++) {
+ DrawCircle(i , y + height / 2 + floor(50 * synth->viz.wave[x * (SAMPLE_RATE / 2)]), 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);