Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix recording of single streamed instruments(regression in #3774) #3803

Merged
merged 2 commits into from
Sep 18, 2017
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
1 change: 1 addition & 0 deletions include/InstrumentTrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ protected slots:
MidiPort m_midiPort;

NotePlayHandle* m_notes[NumKeys];
NotePlayHandleList m_sustainedNotes;

int m_runningMidiNotes[NumKeys];
QMutex m_midiNotesMutex;
Expand Down
21 changes: 11 additions & 10 deletions src/core/NotePlayHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,8 @@ void NotePlayHandle::play( sampleFrame * _working_buffer )
if( m_released && (!instrumentTrack()->isSustainPedalPressed() ||
m_releaseStarted) )
{
if (m_releaseStarted == false)
{
m_releaseStarted = true;

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 @@ -389,6 +380,16 @@ 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
24 changes: 23 additions & 1 deletion src/tracks/InstrumentTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ 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_sustainedNotes << m_notes[event.key()];
}
m_notes[event.key()] = NULL;
Engine::mixer()->doneChangeInModel();
}
Expand Down Expand Up @@ -302,8 +308,24 @@ void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& ti
{
m_sustainPedalPressed = true;
}
else
else if (isSustainPedalPressed())
{
for (NotePlayHandle* nph : m_sustainedNotes)
{
if (nph && nph->isReleased())
{
if( nph->origin() ==
nph->OriginMidiInput)
{
nph->setLength(
MidiTime( static_cast<f_cnt_t>(
nph->totalFramesPlayed() /
Engine::framesPerTick() ) ) );
midiNoteOff( *nph );
}
}
}
m_sustainedNotes.clear();
m_sustainPedalPressed = false;
}
}
Expand Down