From 575494361b12fb7540d8dfe19c849a12872dfe59 Mon Sep 17 00:00:00 2001 From: Wong Cho Ching Date: Wed, 29 Jan 2014 22:21:49 +0800 Subject: [PATCH 1/6] Added sound preview when button is click --- plugins/sfxr/sfxr.cpp | 22 ++++++++++++++++++++++ plugins/sfxr/sfxr.h | 3 +++ 2 files changed, 25 insertions(+) diff --git a/plugins/sfxr/sfxr.cpp b/plugins/sfxr/sfxr.cpp index 66f9b58a1..070be1358 100644 --- a/plugins/sfxr/sfxr.cpp +++ b/plugins/sfxr/sfxr.cpp @@ -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(); + 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" { diff --git a/plugins/sfxr/sfxr.h b/plugins/sfxr/sfxr.h index 20250db70..524f67314 100644 --- a/plugins/sfxr/sfxr.h +++ b/plugins/sfxr/sfxr.h @@ -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(); From 20eb81c955344c602ba2b0dc801fd9cec2826c2d Mon Sep 17 00:00:00 2001 From: Wong Cho Ching Date: Wed, 29 Jan 2014 23:46:50 +0800 Subject: [PATCH 2/6] bug fix --- plugins/sfxr/sfxr.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/sfxr/sfxr.cpp b/plugins/sfxr/sfxr.cpp index 070be1358..66740bca2 100644 --- a/plugins/sfxr/sfxr.cpp +++ b/plugins/sfxr/sfxr.cpp @@ -48,6 +48,7 @@ float frnd(float range) #include "templates.h" #include "tooltip.h" #include "song.h" +#include "midi.h" #include "embed.cpp" @@ -157,7 +158,7 @@ void SfxrSynth::resetSample( bool restart ) - +#include void SfxrSynth::update( sampleFrame * buffer, const fpp_t frameNum ) { for(int i=0;iframesLeftForCurrentPeriod(); - if ( _n->totalFramesPlayed() == 0 ) + if ( _n->totalFramesPlayed() == 0 || _n->m_pluginData == NULL ) { _n->m_pluginData = new SfxrSynth( this ); } @@ -467,7 +468,7 @@ void sfxrInstrument::playNote( notePlayHandle * _n, sampleFrame * _working_buffe { for( ch_cnt_t j=0; j(); InstrumentTrack * it = s->m_instrumentTrack; - it->processInEvent( midiEvent( MidiNoteOff, 0, it->baseNoteModel()->value(), 0 ), midiTime() ); + it->silenceAllNotes(); it->processInEvent( midiEvent( MidiNoteOn, 0, it->baseNoteModel()->value(), MidiMaxVelocity ), midiTime() ); } From 277ff5b99e40f74a75ed681f878df865d2e4cf2b Mon Sep 17 00:00:00 2001 From: Wong Cho Ching Date: Wed, 29 Jan 2014 23:51:35 +0800 Subject: [PATCH 3/6] fix strict compiler error --- plugins/sfxr/sfxr.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/sfxr/sfxr.cpp b/plugins/sfxr/sfxr.cpp index 66740bca2..46de46a32 100644 --- a/plugins/sfxr/sfxr.cpp +++ b/plugins/sfxr/sfxr.cpp @@ -48,7 +48,8 @@ float frnd(float range) #include "templates.h" #include "tooltip.h" #include "song.h" -#include "midi.h" +class midiEvent; +class midiTime; #include "embed.cpp" From 3500cde6a4257aa1b8fa3ea21d1f4eb00d7f8341 Mon Sep 17 00:00:00 2001 From: Wong Cho Ching Date: Thu, 30 Jan 2014 00:04:45 +0800 Subject: [PATCH 4/6] fixes compiler error, 2nd attempt --- plugins/sfxr/sfxr.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/sfxr/sfxr.cpp b/plugins/sfxr/sfxr.cpp index 46de46a32..07cb27600 100644 --- a/plugins/sfxr/sfxr.cpp +++ b/plugins/sfxr/sfxr.cpp @@ -48,8 +48,7 @@ float frnd(float range) #include "templates.h" #include "tooltip.h" #include "song.h" -class midiEvent; -class midiTime; +#include "Midi.h" #include "embed.cpp" From cdedd344746a5530d9b27bc351d0a99f8646dbbd Mon Sep 17 00:00:00 2001 From: Wong Cho Ching Date: Thu, 30 Jan 2014 00:05:42 +0800 Subject: [PATCH 5/6] remove stdio.h --- plugins/sfxr/sfxr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/sfxr/sfxr.cpp b/plugins/sfxr/sfxr.cpp index 07cb27600..6a6c10380 100644 --- a/plugins/sfxr/sfxr.cpp +++ b/plugins/sfxr/sfxr.cpp @@ -158,7 +158,7 @@ void SfxrSynth::resetSample( bool restart ) -#include + void SfxrSynth::update( sampleFrame * buffer, const fpp_t frameNum ) { for(int i=0;i Date: Thu, 30 Jan 2014 00:16:08 +0800 Subject: [PATCH 6/6] updated include file --- plugins/sfxr/sfxr.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/sfxr/sfxr.cpp b/plugins/sfxr/sfxr.cpp index 6a6c10380..a459768d3 100644 --- a/plugins/sfxr/sfxr.cpp +++ b/plugins/sfxr/sfxr.cpp @@ -48,7 +48,8 @@ float frnd(float range) #include "templates.h" #include "tooltip.h" #include "song.h" -#include "Midi.h" +#include "MidiEvent.h" +#include "MidiTime.h" #include "embed.cpp" @@ -1064,7 +1065,7 @@ void sfxrInstrumentView::previewSound() sfxrInstrument * s = castModel(); InstrumentTrack * it = s->m_instrumentTrack; it->silenceAllNotes(); - it->processInEvent( midiEvent( MidiNoteOn, 0, it->baseNoteModel()->value(), MidiMaxVelocity ), midiTime() ); + it->processInEvent( MidiEvent( MidiNoteOn, 0, it->baseNoteModel()->value(), MidiMaxVelocity ), MidiTime() ); }