diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2023-06-27 22:37:53 +0300 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2023-06-27 22:37:53 +0300 |
commit | 60c82a72fedd719f69c1f1de896aca00784a2881 (patch) | |
tree | 3679e0886fc12aa8eeeab60260347ee7a0c5ae0e /src/midi.c | |
parent | e77d4d42cacd21bf80e4f47cba2fe85f5a5b0991 (diff) | |
download | synth-project-60c82a72fedd719f69c1f1de896aca00784a2881.tar.gz synth-project-60c82a72fedd719f69c1f1de896aca00784a2881.tar.bz2 synth-project-60c82a72fedd719f69c1f1de896aca00784a2881.zip |
Changes
Diffstat (limited to 'src/midi.c')
-rw-r--r-- | src/midi.c | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -1,5 +1,6 @@ #include "midi.h" #include "notes.h" +#include "control.h" #include <string.h> @@ -13,7 +14,7 @@ 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); + // 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); } @@ -22,7 +23,7 @@ void midi_decode(uint32_t msg, synth_t * synth) { break; case 0x09: - printf("Note On: channel=%d, note=%d, velocity=%d\n", channel, data1, data2); + // 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); @@ -47,11 +48,13 @@ void midi_decode(uint32_t msg, synth_t * synth) { printf("Aftertouch: channel=%d, note=%d, pressure=%d\n", channel, data1, data2); break; case 0x0B: - printf("Control Change: channel=%d, controller=%d, value=%d\n", channel, data1, data2); + // printf("Control Change: channel=%d, controller=%d, value=%d\n", channel, data1, data2); int x = data2 < 64 ? 1 : -1; switch (data1) { case 0: synth->adsr.a = synth->adsr.a + (x * 0.01); + //synth->freq_offset = synth->freq_offset + (x*5); + //cc_step(&synth->cc_cutoff, x); break; case 1: synth->adsr.d = synth->adsr.d + (x * 0.01); @@ -63,15 +66,18 @@ void midi_decode(uint32_t msg, synth_t * synth) { synth->adsr.r = synth->adsr.r + (x * 0.01); break; case 4: + cc_step(&synth->cc_cutoff, x); synth->cutoff = synth->cutoff + (x * (10 * log10(synth->cutoff))); break; case 5: - synth->resonance = synth->resonance + (x * 0.02); + cc_step(&synth->cc_resonance, x); break; case 6: - synth->lfo.freq = synth->lfo.freq + (x * 0.1); + cc_step(&synth->cc_pitch, x); + //synth->lfo.freq = synth->lfo.freq + (x * 0.1); break; case 7: + cc_reset(&synth->cc_pitch); synth->lfo.amp = synth->lfo.amp + (x * 0.002); break; break; @@ -137,7 +143,9 @@ init_midi(midi_t *m, synth_t *synth) info = Pm_GetDeviceInfo(i); printf("%d: %s [input: %d output: %d opened: %d is_virt:%d] (interf: %s) -- %d\n", i, info->name, info->input, info->output, info->opened, info->is_virtual, info->interf, Pm_GetDefaultInputDeviceID()); //if (!strcmp("MPK225 MIDI", info->name) && !info->input) break; - if (!strcmp("MPK225 Port A", info->name) && info->input == 1) break; + //if (!strcmp("MPK225 Port A", info->name) && info->input == 1) break; + //if (!strcmp("CH345 MIDI 1", info->name) && info->input == 1) break; + if (!strcmp("Midi Through Port-0", info->name) && info->input == 1) break; } Pt_Start(1, midiCallback, m); |