summaryrefslogtreecommitdiffstats
path: root/src/synth_gui.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2023-04-20 18:24:49 +0300
committergramanas <anastasis.gramm2@gmail.com>2023-04-20 18:24:49 +0300
commitc161e1016a04566a56b4858ea43502fed88dcc7f (patch)
treeb4b3086f000df6b63229dae6057f1aa253811b30 /src/synth_gui.c
parent1e374b426b4182c7b73b35219aadaca267b9623c (diff)
downloadsynth-project-c161e1016a04566a56b4858ea43502fed88dcc7f.tar.gz
synth-project-c161e1016a04566a56b4858ea43502fed88dcc7f.tar.bz2
synth-project-c161e1016a04566a56b4858ea43502fed88dcc7f.zip
Add midi
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);