diff options
author | gramanas <anastasis.gramm2@gmail.com> | 2023-11-27 01:03:38 +0200 |
---|---|---|
committer | gramanas <anastasis.gramm2@gmail.com> | 2023-11-27 01:03:38 +0200 |
commit | b0128e30840dff1e7db7bcfd69e6fa4f09ed5fbe (patch) | |
tree | 633be15d0e962db8fd7f2254df7a852f53b85ddc /src/midi.c | |
parent | fb31c071fe835c5ffd1f70d3558acecee2ed7f17 (diff) | |
download | synth-project-b0128e30840dff1e7db7bcfd69e6fa4f09ed5fbe.tar.gz synth-project-b0128e30840dff1e7db7bcfd69e6fa4f09ed5fbe.tar.bz2 synth-project-b0128e30840dff1e7db7bcfd69e6fa4f09ed5fbe.zip |
wavetables
Diffstat (limited to 'src/midi.c')
-rw-r--r-- | src/midi.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -92,7 +92,19 @@ void midi_decode(uint32_t msg, synth_t * synth) { printf("Channel Pressure: channel=%d, pressure=%d\n", channel, data1); break; case 0x0E: - printf("Pitch Bend: channel=%d, value=%d\n", channel, ((data2 << 7) | data1) - 8192); + int val = ((data2 << 7) | data1) - 8192; + printf("Pitch Bend: channel=%d, value=%d\n", channel, val); + float pitch; + float semitones = 2; + if (val == 0) { + pitch = 1; + } else if (val > 0) { + pitch = 1 + ((float)val / 8191) * semitones * pow(2.0, 1.0 / 12.0) / 12; + } else { + pitch = 1 + ((float)val / 8192) * semitones * pow(2.0, 1.0 / 12.0) / 12; + } + synth->cc_pitch.target = pitch; + /* cc_step(synth->cc_pitch, 1); */ break; default: printf("Unknown MIDI message\n"); |