diff options
author | rekado <rekado@elephly.net> | 2013-01-14 22:18:45 +0800 |
---|---|---|
committer | rekado <rekado@elephly.net> | 2013-01-14 22:18:45 +0800 |
commit | d4c8d0754ae1dc7bdbd8ae9da6df10394333bf84 (patch) | |
tree | 4f448b503e713ce7a78b60507810058994fd4741 /src/mdaPiano.cpp | |
parent | cfcc7b8fa35afc096c1771a4b513f94ccaa1fc67 (diff) |
dampen/undampen notes on pedal
Diffstat (limited to 'src/mdaPiano.cpp')
-rw-r--r-- | src/mdaPiano.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
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; |