summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/midi.c17
-rw-r--r--src/synth_engine.c7
-rw-r--r--src/synth_engine.h9
-rw-r--r--src/synth_gui.c26
4 files changed, 0 insertions, 59 deletions
diff --git a/src/midi.c b/src/midi.c
index d3e2adb..d9955d2 100644
--- a/src/midi.c
+++ b/src/midi.c
@@ -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);