From: rekado Date: Mon, 14 Jan 2013 14:18:45 +0000 (+0800) Subject: dampen/undampen notes on pedal X-Git-Tag: 0.0.1~74 X-Git-Url: https://git.elephly.net/?p=software%2Flv2-mdametapiano.git;a=commitdiff_plain;h=d4c8d0754ae1dc7bdbd8ae9da6df10394333bf84 dampen/undampen notes on pedal --- diff --git a/src/mdaPiano.cpp b/src/mdaPiano.cpp index 3e44cc7..fbd0665 100644 --- a/src/mdaPiano.cpp +++ b/src/mdaPiano.cpp @@ -144,10 +144,13 @@ void mdaPiano::handle_midi(uint32_t size, unsigned char* data) { case 0x40: //sustain pedal case 0x42: //sustenuto pedal sustain = data[2] & 0x40; - if(sustain==0) - { - notes[npos++] = SUSTAIN; //end all sustained notes - notes[npos++] = 0; + + for (unsigned i = 0; i < NVOICES; ++i) { + voices[i]->set_sustain(sustain); + //if pedal was released: dampen sustained notes + if((sustain==0) && (voices[i]->is_sustained())) { + voices[i]->release(0); + } } break; diff --git a/src/mdaPianoVoice.h b/src/mdaPianoVoice.h index 22f8218..e50c176 100644 --- a/src/mdaPianoVoice.h +++ b/src/mdaPianoVoice.h @@ -50,6 +50,7 @@ class mdaPianoVoice : public LV2::Voice { public: mdaPianoVoice(double, short*, KGRP*); + void set_sustain(unsigned short v) { sustain = v; } void set_volume(float v) { volume = v; } void set_muff(float v) { muff = v; }