Fix recording of sustained midi notes (#3710)
This commit is contained in:
@@ -378,10 +378,13 @@ void NotePlayHandle::noteOff( const f_cnt_t _s )
|
||||
}
|
||||
|
||||
// inform attached components about MIDI finished (used for recording in Piano Roll)
|
||||
if( m_origin == OriginMidiInput )
|
||||
if (!instrumentTrack()->isSustainPedalPressed())
|
||||
{
|
||||
setLength( MidiTime( static_cast<f_cnt_t>( totalFramesPlayed() / Engine::framesPerTick() ) ) );
|
||||
m_instrumentTrack->midiNoteOff( *this );
|
||||
if( m_origin == OriginMidiInput )
|
||||
{
|
||||
setLength( MidiTime( static_cast<f_cnt_t>( totalFramesPlayed() / Engine::framesPerTick() ) ) );
|
||||
m_instrumentTrack->midiNoteOff( *this );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -273,7 +273,14 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& ti
|
||||
// be deleted later automatically)
|
||||
Engine::mixer()->requestChangeInModel();
|
||||
m_notes[event.key()]->noteOff( offset );
|
||||
m_notes[event.key()] = NULL;
|
||||
|
||||
if (!(isSustainPedalPressed()) ||
|
||||
!(m_notes[event.key()]->origin() ==
|
||||
m_notes[event.key()]->OriginMidiInput))
|
||||
{
|
||||
m_notes[event.key()] = NULL;
|
||||
}
|
||||
|
||||
Engine::mixer()->doneChangeInModel();
|
||||
}
|
||||
eventHandled = true;
|
||||
@@ -302,8 +309,24 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& ti
|
||||
{
|
||||
m_sustainPedalPressed = true;
|
||||
}
|
||||
else
|
||||
else if (isSustainPedalPressed())
|
||||
{
|
||||
for (NotePlayHandle*& nph : m_notes)
|
||||
{
|
||||
if (nph && nph->isReleased())
|
||||
{
|
||||
if( nph->origin() ==
|
||||
nph->OriginMidiInput)
|
||||
{
|
||||
nph->setLength(
|
||||
MidiTime( static_cast<f_cnt_t>(
|
||||
nph->totalFramesPlayed() /
|
||||
Engine::framesPerTick() ) ) );
|
||||
midiNoteOff( *nph );
|
||||
}
|
||||
nph = NULL;
|
||||
}
|
||||
}
|
||||
m_sustainPedalPressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user