diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2023-06-28 22:40:47 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2023-06-28 22:40:47 +0300 |
commit | 89e85142d0958d3e3a87fb155d698fc59eafd4c6 (patch) | |
tree | 013c3e878a6fa3b822999e05771e129777e37323 | |
parent | 60c82a72fedd719f69c1f1de896aca00784a2881 (diff) | |
download | synth-project-89e85142d0958d3e3a87fb155d698fc59eafd4c6.tar.gz synth-project-89e85142d0958d3e3a87fb155d698fc59eafd4c6.tar.bz2 synth-project-89e85142d0958d3e3a87fb155d698fc59eafd4c6.zip |
Remove old note stuff
-rw-r--r-- | src/midi.c | 17 | ||||
-rw-r--r-- | src/synth_engine.c | 7 | ||||
-rw-r--r-- | src/synth_engine.h | 9 | ||||
-rw-r--r-- | src/synth_gui.c | 26 |
4 files changed, 0 insertions, 59 deletions
@@ -15,25 +15,10 @@ void midi_decode(uint32_t msg, synth_t * synth) { switch (message) { case 0x08: // printf("Note Off: channel=%d, note=%d, velocity=%d\n", channel, data1, data2); - if (synth->n.key == data1) { - synth->n.noteOff = Pa_GetStreamTime(synth->stream); - } - synth->midi_note[data1].noteOff = Pa_GetStreamTime(synth->stream); - break; case 0x09: // printf("Note On: channel=%d, note=%d, velocity=%d\n", channel, data1, data2); - synth->n.key = data1; - synth->n.freq = notes[data1 % 12][(data1 / 12) % 8]; - synth->n.noteOn = Pa_GetStreamTime(synth->stream); - synth->n.noteOff = 0; - synth->n.elapsed = 0; - synth->adsr.elapsed = 0; - synth->active = 1; - //synth->gain = data2 / 127.0; - - //synth->midi_note[i].n = -1; synth->midi_note[data1].freq = notes[data1 % 12][(data1 / 12) % 8]; synth->midi_note[data1].channel = channel; @@ -42,7 +27,6 @@ void midi_decode(uint32_t msg, synth_t * synth) { synth->midi_note[data1].velocity = (float)data2 / 127.0; synth->midi_note[data1].elapsed = 0; synth->midi_note[data1].active = 1; - break; case 0x0A: printf("Aftertouch: channel=%d, note=%d, pressure=%d\n", channel, data1, data2); @@ -98,7 +82,6 @@ void midi_decode(uint32_t msg, synth_t * synth) { break; case 0x0E: printf("Pitch Bend: channel=%d, value=%d\n", channel, ((data2 << 7) | data1) - 8192); - synth->n.freq = (((data2 << 7) | data1) - 8192); break; default: printf("Unknown MIDI message\n"); diff --git a/src/synth_engine.c b/src/synth_engine.c index 9dc6457..a4d3d17 100644 --- a/src/synth_engine.c +++ b/src/synth_engine.c @@ -240,7 +240,6 @@ increment_synth(synth_t *synth) { synth->lfo.elapsed++; synth->adsr.elapsed++; - synth->n.elapsed++; for (int i = 0; i < MIDI_NOTES; i++) { if (!synth->midi_note[i].active) continue; @@ -437,12 +436,6 @@ init_synth(synth_t * synth) synth->midi_note[i].adsr = &(synth->adsr); } - synth->n.freq = 0; - synth->n.noteOn = 0; - synth->n.noteOff = 1; - synth->n.key = 0; - synth->n.elapsed = 0; - synth->octave = 3; synth->poly = 0; diff --git a/src/synth_engine.h b/src/synth_engine.h index 0c8145f..e2e91fd 100644 --- a/src/synth_engine.h +++ b/src/synth_engine.h @@ -32,14 +32,6 @@ typedef struct lfo_t { unsigned long long elapsed; } lfo_t; -typedef struct note_t { - float freq; - PaTime noteOn; - PaTime noteOff; - int key; - unsigned long long elapsed; -} note_t; - typedef struct midi_note_t { float freq; int channel; @@ -74,7 +66,6 @@ typedef struct { midi_note_t midi_note[MIDI_NOTES]; - note_t n; adsr_t adsr; lfo_t lfo; diff --git a/src/synth_gui.c b/src/synth_gui.c index 510075b..d39995b 100644 --- a/src/synth_gui.c +++ b/src/synth_gui.c @@ -3,23 +3,6 @@ #include "raygui.h" //#include "raylib.h" - -void -set_note(void *synthData, float note, PaTime time, int key) -{ - synth_t * synth = (synth_t *)synthData; - - synth->n.key = key; - synth->n.freq = note; - synth->n.noteOn = time; - synth->n.noteOff = 0; - synth->n.elapsed = 0; - synth->adsr.elapsed = 0; - - synth->active = 1; -} - - void keyboard(void *synthData, PaStream *stream) { @@ -33,8 +16,6 @@ keyboard(void *synthData, PaStream *stream) if (IsKeyPressed(keys[i])) { note = notes[i % 12][(synth->octave + (i / 12)) % 8]; if (note) { - 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); synth->midi_note[i].freq = 16.35160 * pow(2, (synth->octave + i / 12.0)); //notes[i % 12][(synth->octave + (i / 12)) % 8]; //synth->midi_note[i].freq = notes[i % 12][(synth->octave + (i / 12)) % 8]; @@ -51,11 +32,6 @@ keyboard(void *synthData, PaStream *stream) if (IsKeyReleased(keys[i])) { synth->midi_note[i].noteOff = Pa_GetStreamTime(synth->stream); note = notes[i % 12][(synth->octave + (i / 12)) % 8]; - if (synth->n.key == keys[i]) { - synth->n.noteOff = Pa_GetStreamTime(stream); - synth->midi_note[i].noteOff = Pa_GetStreamTime(synth->stream); - //printf("Note Off: %s[%d]\n", int_to_note(i % 12), (synth->octave + (i / 12)) % 8); - } } } @@ -151,8 +127,6 @@ draw_signals(synth_t * synth, int x, int y, int width, int height) int point_radius = 1.5; 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(250 * synth->viz.wave[i - x]), point_radius, MAGENTA); |