diff --git a/include/InstrumentTrack.h b/include/InstrumentTrack.h index 20200e1a7..ea10447c5 100644 --- a/include/InstrumentTrack.h +++ b/include/InstrumentTrack.h @@ -74,7 +74,7 @@ public: virtual void processInEvent( const MidiEvent& event, const MidiTime& time = MidiTime(), f_cnt_t offset = 0 ); virtual void processOutEvent( const MidiEvent& event, const MidiTime& time = MidiTime(), f_cnt_t offset = 0 ); // silence all running notes played by this track - void silenceAllNotes(); + void silenceAllNotes( bool removeIPH = false ); bool isSustainPedalPressed() const { diff --git a/include/Mixer.h b/include/Mixer.h index 9a20cae5a..7007e1801 100644 --- a/include/Mixer.h +++ b/include/Mixer.h @@ -229,7 +229,7 @@ public: return m_playHandles; } - void removePlayHandles( track * _track ); + void removePlayHandles( track * _track, bool removeIPHs = true ); bool hasNotePlayHandles(); diff --git a/src/core/Mixer.cpp b/src/core/Mixer.cpp index 9c35ee852..c9fd9b83c 100644 --- a/src/core/Mixer.cpp +++ b/src/core/Mixer.cpp @@ -686,13 +686,13 @@ void Mixer::removePlayHandle( PlayHandle * _ph ) -void Mixer::removePlayHandles( track * _track ) +void Mixer::removePlayHandles( track * _track, bool removeIPHs ) { lock(); PlayHandleList::Iterator it = m_playHandles.begin(); while( it != m_playHandles.end() ) { - if( ( *it )->isFromTrack( _track ) ) + if( ( *it )->isFromTrack( _track ) && ( removeIPHs || ( *it )->type() != PlayHandle::TypeInstrumentPlayHandle ) ) { delete *it; it = m_playHandles.erase( it ); diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index e661f4f4c..be2de2497 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -144,8 +144,8 @@ int InstrumentTrack::baseNote() const InstrumentTrack::~InstrumentTrack() { - // kill all running notes - silenceAllNotes(); + // kill all running notes and the iph + silenceAllNotes( true ); // now we're save deleting the instrument delete m_instrument; @@ -402,7 +402,7 @@ void InstrumentTrack::processOutEvent( const MidiEvent& event, const MidiTime& t -void InstrumentTrack::silenceAllNotes() +void InstrumentTrack::silenceAllNotes( bool removeIPH ) { engine::mixer()->lock(); for( int i = 0; i < NumKeys; ++i ) @@ -413,7 +413,7 @@ void InstrumentTrack::silenceAllNotes() // invalidate all NotePlayHandles linked to this track m_processHandles.clear(); - engine::mixer()->removePlayHandles( this ); + engine::mixer()->removePlayHandles( this, removeIPH ); engine::mixer()->unlock(); } @@ -700,7 +700,7 @@ void InstrumentTrack::saveTrackSpecificSettings( QDomDocument& doc, QDomElement void InstrumentTrack::loadTrackSpecificSettings( const QDomElement & thisElement ) { - silenceAllNotes(); + silenceAllNotes( true ); engine::mixer()->lock(); @@ -776,7 +776,7 @@ void InstrumentTrack::loadTrackSpecificSettings( const QDomElement & thisElement Instrument * InstrumentTrack::loadInstrument( const QString & _plugin_name ) { - silenceAllNotes(); + silenceAllNotes( true ); engine::mixer()->lock(); delete m_instrument;