From 4f7de09c753ece6f2099512522d489b0104a59a8 Mon Sep 17 00:00:00 2001 From: gramanas Date: Mon, 27 Nov 2023 18:33:42 +0200 Subject: cc adsr and ui --- src/midi.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'src/midi.c') diff --git a/src/midi.c b/src/midi.c index c65a298..11029b0 100644 --- a/src/midi.c +++ b/src/midi.c @@ -44,22 +44,26 @@ 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); + cc_step(&synth->cc_adsr_a, x); + //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); + cc_step(&synth->cc_adsr_d, x); + //synth->adsr.d = synth->adsr.d + (x * 0.01); break; case 2: - synth->adsr.s = synth->adsr.s + (x * 0.01); + cc_step(&synth->cc_adsr_s, x); + //synth->adsr.s = synth->adsr.s + (x * 0.01); break; case 3: - synth->adsr.r = synth->adsr.r + (x * 0.01); + cc_step(&synth->cc_adsr_r, x); + //synth->adsr.r = synth->adsr.r + (x * 0.01); break; case 4: cc_step(&synth->cc_cutoff, x); @@ -69,18 +73,25 @@ void midi_decode(uint32_t msg, synth_t * synth) { cc_step(&synth->cc_resonance, x); break; case 6: - cc_step(&synth->cc_pitch, x); + //cc_step(&synth->cc_pitch, x); + cc_step(&synth->cc_lfo_freq, 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); + //cc_reset(&synth->cc_pitch); + cc_step(&synth->cc_lfo_amp, x); + //synth->lfo.amp = synth->lfo.amp + (x * 0.002); break; + case 8: + //cc_reset(&synth->cc_pitch); + synth->wvt_pos = data2; + //synth->lfo.amp = synth->lfo.amp + (x * 0.002); break; case 28: - synth->filter = x - 1; + if (synth->geni > 0) synth->geni--; break; case 29: + if (synth->geni < 6) synth->geni++; break; default: } -- cgit v1.2.3