ResourcePreviewer: start/stop playback of preview sound

Make the internal InstrumentTrack play the default key in preview()
and stop playback in new method stopPreview().

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
This commit is contained in:
Tobias Doerffel
2009-06-11 00:30:39 +02:00
parent fd417de7fd
commit d11bf48891
2 changed files with 19 additions and 0 deletions

View File

@@ -39,6 +39,7 @@ public:
~ResourcePreviewer();
void preview( ResourceItem * _item );
void stopPreview();
private:

View File

@@ -58,6 +58,10 @@ ResourcePreviewer::~ResourcePreviewer()
void ResourcePreviewer::preview( ResourceItem * _item )
{
// stop any existing preview sounds
stopPreview();
// disable journalling of changes in our preview track
const bool j = engine::getProjectJournal()->isJournalling();
engine::getProjectJournal()->setJournalling( false );
engine::setSuppressMessages( true );
@@ -75,8 +79,22 @@ void ResourcePreviewer::preview( ResourceItem * _item )
break;
}
// re-enable journalling
engine::setSuppressMessages( false );
engine::getProjectJournal()->setJournalling( j );
// playback default note
m_previewTrack->processInEvent(
midiEvent( MidiNoteOn, 0, DefaultKey, MidiMaxVelocity ),
midiTime() );
}
void ResourcePreviewer::stopPreview()
{
m_previewTrack->silenceAllNotes();
}