Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't mix styles. This would be comparably to the rest of your changes in this PR and surrounding code.

if( m_releaseStarted == false )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (a) is new convention, if( a ) is old one. Many things are written with old convention, which make the code inconsistent for recently edited files.
I suggest using new style in line 252.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. ;)

{

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