Skip to content

Commit

Permalink
same note layering when sustain pedal is pressed (LMMS#3774)
Browse files Browse the repository at this point in the history
  • Loading branch information
serdnab authored and zonkmachine committed Aug 26, 2017
1 parent fde3c30 commit ab80176
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 36 deletions.
21 changes: 10 additions & 11 deletions src/core/NotePlayHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<f_cnt_t>( 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
Expand Down Expand Up @@ -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<f_cnt_t>( totalFramesPlayed() / Engine::framesPerTick() ) ) );
m_instrumentTrack->midiNoteOff( *this );
}
}
}


Expand Down
27 changes: 2 additions & 25 deletions src/tracks/InstrumentTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<f_cnt_t>(
nph->totalFramesPlayed() /
Engine::framesPerTick() ) ) );
midiNoteOff( *nph );
}
nph = NULL;
}
}
m_sustainPedalPressed = false;
}
}
Expand Down

0 comments on commit ab80176

Please sign in to comment.