diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index 84d888fee6b..0dff48fc02b 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -252,8 +252,17 @@ void NotePlayHandle::play( sampleFrame * _working_buffer ) if( m_released && (!instrumentTrack()->isSustainPedalPressed() || m_releaseStarted) ) { - m_releaseStarted = true; + if (m_releaseStarted == false) + { + if( m_origin == OriginMidiInput ) + { + setLength( MidiTime( static_cast( totalFramesPlayed() / Engine::framesPerTick() ) ) ); + m_instrumentTrack->midiNoteOff( *this ); + } + + m_releaseStarted = true; + } f_cnt_t todo = framesThisPeriod; // if this note is base-note for arpeggio, always set @@ -380,16 +389,6 @@ void NotePlayHandle::noteOff( const f_cnt_t _s ) MidiTime::fromFrames( _s, Engine::framesPerTick() ), _s ); } - - // inform attached components about MIDI finished (used for recording in Piano Roll) - if (!instrumentTrack()->isSustainPedalPressed()) - { - if( m_origin == OriginMidiInput ) - { - setLength( MidiTime( static_cast( totalFramesPlayed() / Engine::framesPerTick() ) ) ); - m_instrumentTrack->midiNoteOff( *this ); - } - } } diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index dc101dbf411..71cc43fb56e 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -273,14 +273,7 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& ti // be deleted later automatically) Engine::mixer()->requestChangeInModel(); m_notes[event.key()]->noteOff( offset ); - - if (!(isSustainPedalPressed()) || - !(m_notes[event.key()]->origin() == - m_notes[event.key()]->OriginMidiInput)) - { - m_notes[event.key()] = NULL; - } - + m_notes[event.key()] = NULL; Engine::mixer()->doneChangeInModel(); } eventHandled = true; @@ -309,24 +302,8 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& ti { m_sustainPedalPressed = true; } - else if (isSustainPedalPressed()) + else { - for (NotePlayHandle*& nph : m_notes) - { - if (nph && nph->isReleased()) - { - if( nph->origin() == - nph->OriginMidiInput) - { - nph->setLength( - MidiTime( static_cast( - nph->totalFramesPlayed() / - Engine::framesPerTick() ) ) ); - midiNoteOff( *nph ); - } - nph = NULL; - } - } m_sustainPedalPressed = false; } }