diff --git a/include/InstrumentTrack.h b/include/InstrumentTrack.h index ea10447c5..8eafc2723 100644 --- a/include/InstrumentTrack.h +++ b/include/InstrumentTrack.h @@ -230,6 +230,7 @@ private: NotePlayHandle* m_notes[NumKeys]; int m_runningMidiNotes[NumKeys]; bool m_sustainPedalPressed; + QMutex m_notesMutex; bool m_silentBuffersProcessed; diff --git a/src/core/InstrumentFunctions.cpp b/src/core/InstrumentFunctions.cpp index 7ffb4a3bb..5549a0d7e 100644 --- a/src/core/InstrumentFunctions.cpp +++ b/src/core/InstrumentFunctions.cpp @@ -235,7 +235,7 @@ void InstrumentFunctionNoteStacking::processNote( NotePlayHandle * _n ) // time an audio-buffer is rendered... if( ( _n->origin() == NotePlayHandle::OriginArpeggio || ( _n->hasParent() == false && _n->instrumentTrack()->isArpeggioEnabled() == false ) ) && _n->totalFramesPlayed() == 0 && - m_chordsEnabledModel.value() == true ) + m_chordsEnabledModel.value() == true && ! _n->isReleased() ) { // then insert sub-notes for chord const int selected_chord = m_chordsModel.value(); diff --git a/src/core/NotePlayHandle.cpp b/src/core/NotePlayHandle.cpp index 8806d65e3..0a3107acd 100644 --- a/src/core/NotePlayHandle.cpp +++ b/src/core/NotePlayHandle.cpp @@ -101,7 +101,7 @@ NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack, m_instrumentTrack->midiNoteOn( *this ); } - if( hasParent() || !instrumentTrack->isArpeggioEnabled() ) + if( hasParent() || ! m_instrumentTrack->isArpeggioEnabled() ) { const int baseVelocity = m_instrumentTrack->midiPort()->baseVelocity(); @@ -229,7 +229,7 @@ void NotePlayHandle::play( sampleFrame * _working_buffer ) // because we do not allow NotePlayHandle::isFinished() to be true // until all sub-notes are completely played and no new ones // are inserted by arpAndChordsTabWidget::processNote() - if( isMasterNote() ) + if( ! m_subNotes.isEmpty() ) { m_releaseFramesToDo = m_releaseFramesDone + 2 * engine::mixer()->framesPerPeriod(); } @@ -349,7 +349,7 @@ void NotePlayHandle::noteOff( const f_cnt_t _s ) m_framesBeforeRelease = _s; m_releaseFramesToDo = qMax( 0, actualReleaseFramesToDo() ); - if( hasParent() || !instrumentTrack()->isArpeggioEnabled() ) + if( hasParent() || ! m_instrumentTrack->isArpeggioEnabled() ) { // send MidiNoteOff event f_cnt_t realOffset = offset() + _s; // get actual frameoffset of release, in global time diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index be2de2497..59e0d1352 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -240,7 +240,7 @@ MidiEvent InstrumentTrack::applyMasterKey( const MidiEvent& event ) void InstrumentTrack::processInEvent( const MidiEvent& event, const MidiTime& time, f_cnt_t offset ) { engine::mixer()->lock(); - + QMutexLocker locker( &m_notesMutex ); bool eventHandled = false; switch( event.type() )