InstrumentTrack: new method silenceAllNotes()

Added new method silenceAllNotes() which is a replacement for
invalidateAllMyNPH() and also resets m_runningMidiNotes array.

silenceAllNotes() is now used in destructor as well.

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
(cherry picked from commit 3c9859da9f)
This commit is contained in:
Tobias Doerffel
2009-06-10 23:40:58 +02:00
parent 57c4a5abc5
commit 93a19e43f1
2 changed files with 26 additions and 23 deletions

View File

@@ -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:

View File

@@ -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: