Added sound preview when button is click

This commit is contained in:
Wong Cho Ching
2014-01-29 22:21:49 +08:00
parent ec71c08816
commit 575494361b
2 changed files with 25 additions and 0 deletions

View File

@@ -319,6 +319,7 @@ bool SfxrSynth::isPlaying() const
sfxrInstrument::sfxrInstrument( InstrumentTrack * _instrument_track ) :
Instrument( _instrument_track, &sfxr_plugin_descriptor ),
m_instrumentTrack(_instrument_track),
m_attModel(0.0f, this),
m_holdModel(0.3f, this),
m_susModel(0.0f, this),
@@ -651,6 +652,17 @@ sfxrInstrumentView::sfxrInstrumentView( Instrument * _instrument,
connect( m_mutateBtn, SIGNAL ( clicked() ), this, SLOT ( mutate() ) );
//preview sound on generator/random/mutate button clicked
connect( m_pickupBtn, SIGNAL ( clicked() ), this, SLOT ( previewSound() ) );
connect( m_laserBtn, SIGNAL ( clicked() ), this, SLOT ( previewSound() ) );
connect( m_explosionBtn, SIGNAL ( clicked() ), this, SLOT ( previewSound() ) );
connect( m_powerupBtn, SIGNAL ( clicked() ), this, SLOT ( previewSound() ) );
connect( m_hitBtn, SIGNAL ( clicked() ), this, SLOT ( previewSound() ) );
connect( m_jumpBtn, SIGNAL ( clicked() ), this, SLOT ( previewSound() ) );
connect( m_blipBtn, SIGNAL ( clicked() ), this, SLOT ( previewSound() ) );
connect( m_randomizeBtn, SIGNAL ( clicked() ), this, SLOT ( previewSound() ) );
connect( m_mutateBtn, SIGNAL ( clicked() ), this, SLOT ( previewSound() ) );
}
@@ -1046,6 +1058,16 @@ void sfxrInstrumentView::mutate()
void sfxrInstrumentView::previewSound()
{
sfxrInstrument * s = castModel<sfxrInstrument>();
InstrumentTrack * it = s->m_instrumentTrack;
it->processInEvent( midiEvent( MidiNoteOff, 0, it->baseNoteModel()->value(), 0 ), midiTime() );
it->processInEvent( midiEvent( MidiNoteOn, 0, it->baseNoteModel()->value(), MidiMaxVelocity ), midiTime() );
}
extern "C"
{

View File

@@ -184,6 +184,7 @@ public:
private:
InstrumentTrack * m_instrumentTrack;
SfxrZeroToOneFloatModel m_attModel;
SfxrZeroToOneFloatModel m_holdModel;
SfxrZeroToOneFloatModel m_susModel;
@@ -241,6 +242,8 @@ protected slots:
void randomize();
void mutate();
void previewSound();
private:
virtual void modelChanged();