diff --git a/include/instrument_track.h b/include/instrument_track.h index dbbefbece..3fcf177b6 100644 --- a/include/instrument_track.h +++ b/include/instrument_track.h @@ -75,7 +75,8 @@ public: const midiTime & _time ); virtual void processOutEvent( const midiEvent & _me, const midiTime & _time ); - + // silence all running notes played by this track + void silenceAllNotes(); f_cnt_t beatLen( notePlayHandle * _n ) const; @@ -194,8 +195,6 @@ protected: { return "instrumenttrack"; } - // invalidates all note-play-handles linked to this instrument - void invalidateAllMyNPH( void ); protected slots: diff --git a/src/tracks/instrument_track.cpp b/src/tracks/instrument_track.cpp index 17e342dfc..9374b24b9 100644 --- a/src/tracks/instrument_track.cpp +++ b/src/tracks/instrument_track.cpp @@ -134,7 +134,10 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) : instrumentTrack::~instrumentTrack() { - engine::getMixer()->removePlayHandles( this ); + // kill all running notes + silenceAllNotes(); + + // now we're save deleting the instrument delete m_instrument; } @@ -403,6 +406,24 @@ void instrumentTrack::processOutEvent( const midiEvent & _me, +void instrumentTrack::silenceAllNotes() +{ + engine::getMixer()->lock(); + for( int i = 0; i < NumKeys; ++i ) + { + m_notes[i] = NULL; + m_runningMidiNotes[i] = 0; + } + + // invalidate all NotePlayHandles linked to this track + m_processHandles.clear(); + engine::getMixer()->removePlayHandles( this ); + engine::getMixer()->unlock(); +} + + + + f_cnt_t instrumentTrack::beatLen( notePlayHandle * _n ) const { if( m_instrument != NULL ) @@ -711,7 +732,7 @@ void instrumentTrack::saveTrackSpecificSettings( QDomDocument & _doc, void instrumentTrack::loadTrackSpecificSettings( const QDomElement & _this ) { - invalidateAllMyNPH(); + silenceAllNotes(); engine::getMixer()->lock(); @@ -818,7 +839,7 @@ void instrumentTrack::loadTrackSpecificSettings( const QDomElement & _this ) instrument * instrumentTrack::loadInstrument( const QString & _plugin_name ) { - invalidateAllMyNPH(); + silenceAllNotes(); engine::getMixer()->lock(); delete m_instrument; @@ -833,23 +854,6 @@ instrument * instrumentTrack::loadInstrument( const QString & _plugin_name ) -void instrumentTrack::invalidateAllMyNPH( void ) -{ - engine::getMixer()->lock(); - for( int i = 0; i < NumKeys; ++i ) - { - m_notes[i] = NULL; - } - - // invalidate all note-play-handles linked to this channel - m_processHandles.clear(); - engine::getMixer()->removePlayHandles( this ); - engine::getMixer()->unlock(); -} - - - - // #### ITV: