From 9588e3dcce6a31058e4a2dcf563e2fb3b4a05b6a Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Mon, 29 Jun 2009 23:35:52 +0200 Subject: [PATCH] VeSTige: adapted to resource framework Adapted VeSTige plugin to new resource framework support in plugin base class. Furthermore some coding style improvements. Signed-off-by: Tobias Doerffel --- plugins/vestige/vestige.cpp | 132 ++++++++++++++++++++---------------- plugins/vestige/vestige.h | 21 +++--- 2 files changed, 84 insertions(+), 69 deletions(-) diff --git a/plugins/vestige/vestige.cpp b/plugins/vestige/vestige.cpp index 85f48e8c5..dcdb47bae 100644 --- a/plugins/vestige/vestige.cpp +++ b/plugins/vestige/vestige.cpp @@ -32,6 +32,7 @@ #include #include +#include "ResourceFileMapper.h" #include "engine.h" #include "gui_templates.h" #include "instrument_play_handle.h" @@ -46,6 +47,9 @@ #include "embed.cpp" +static const char * __supportedExts[] = +{ "dll", NULL }; + extern "C" { @@ -59,7 +63,7 @@ plugin::descriptor vestige_plugin_descriptor = 0x0100, plugin::Instrument, new pluginPixmapLoader( "logo" ), - "dll", + __supportedExts, NULL } ; @@ -119,9 +123,69 @@ void vestigeInstrument::saveSettings( QDomDocument & _doc, QDomElement & _this ) -QString vestigeInstrument::nodeName( void ) const +QString vestigeInstrument::nodeName() const { - return( vestige_plugin_descriptor.name ); + return vestige_plugin_descriptor.name; +} + + + + +void vestigeInstrument::loadResource( const ResourceItem * _item ) +{ + ResourceFileMapper mapper( _item ); + loadFile( mapper.fileName() ); +} + + + + +void vestigeInstrument::play( sampleFrame * _buf ) +{ + m_pluginMutex.lock(); + if( m_plugin == NULL ) + { + m_pluginMutex.unlock(); + return; + } + + m_plugin->process( NULL, _buf ); + + const fpp_t frames = engine::getMixer()->framesPerPeriod(); + + getInstrumentTrack()->processAudioBuffer( _buf, frames, NULL ); + + m_pluginMutex.unlock(); +} + + + + +bool vestigeInstrument::handleMidiEvent( const midiEvent & _me, + const midiTime & _time ) +{ + m_pluginMutex.lock(); + if( m_plugin != NULL ) + { + m_plugin->processMidiEvent( _me, _time ); + } + m_pluginMutex.unlock(); + return true; +} + + + + +void vestigeInstrument::closePlugin() +{ + m_pluginMutex.lock(); + if( m_plugin ) + { + delete m_plugin->pluginWidget(); + } + delete m_plugin; + m_plugin = NULL; + m_pluginMutex.unlock(); } @@ -180,59 +244,9 @@ void vestigeInstrument::loadFile( const QString & _file ) -void vestigeInstrument::play( sampleFrame * _buf ) -{ - m_pluginMutex.lock(); - if( m_plugin == NULL ) - { - m_pluginMutex.unlock(); - return; - } - - m_plugin->process( NULL, _buf ); - - const fpp_t frames = engine::getMixer()->framesPerPeriod(); - - getInstrumentTrack()->processAudioBuffer( _buf, frames, NULL ); - - m_pluginMutex.unlock(); -} - - - - -bool vestigeInstrument::handleMidiEvent( const midiEvent & _me, - const midiTime & _time ) -{ - m_pluginMutex.lock(); - if( m_plugin != NULL ) - { - m_plugin->processMidiEvent( _me, _time ); - } - m_pluginMutex.unlock(); - return true; -} - - - - -void vestigeInstrument::closePlugin( void ) -{ - m_pluginMutex.lock(); - if( m_plugin ) - { - delete m_plugin->pluginWidget(); - } - delete m_plugin; - m_plugin = NULL; - m_pluginMutex.unlock(); -} - - - pluginView * vestigeInstrument::instantiateView( QWidget * _parent ) { - return( new vestigeInstrumentView( this, _parent ) ); + return new vestigeInstrumentView( this, _parent ); } @@ -301,7 +315,7 @@ vestigeInstrumentView::~vestigeInstrumentView() -void vestigeInstrumentView::modelChanged( void ) +void vestigeInstrumentView::modelChanged() { m_vi = castModel(); } @@ -309,7 +323,7 @@ void vestigeInstrumentView::modelChanged( void ) -void vestigeInstrumentView::openPlugin( void ) +void vestigeInstrumentView::openPlugin() { QFileDialog ofd( NULL, tr( "Open VST-plugin" ) ); @@ -353,7 +367,7 @@ void vestigeInstrumentView::openPlugin( void ) -void vestigeInstrumentView::toggleGUI( void ) +void vestigeInstrumentView::toggleGUI() { QMutexLocker ml( &m_vi->m_pluginMutex ); if( m_vi->m_plugin == NULL ) @@ -378,7 +392,7 @@ void vestigeInstrumentView::toggleGUI( void ) -void vestigeInstrumentView::noteOffAll( void ) +void vestigeInstrumentView::noteOffAll() { m_vi->m_pluginMutex.lock(); if( m_vi->m_plugin != NULL ) @@ -478,7 +492,7 @@ extern "C" // neccessary for getting instance out of shared lib plugin * lmms_plugin_main( model *, void * _data ) { - return( new vestigeInstrument( static_cast( _data ) ) ); + return new vestigeInstrument( static_cast( _data ) ); } diff --git a/plugins/vestige/vestige.h b/plugins/vestige/vestige.h index 75d6ed5b3..e5fa7bfa1 100644 --- a/plugins/vestige/vestige.h +++ b/plugins/vestige/vestige.h @@ -50,16 +50,16 @@ public: vestigeInstrument( instrumentTrack * _channel_track ); virtual ~vestigeInstrument(); - virtual void play( sampleFrame * _working_buffer ); - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); virtual void loadSettings( const QDomElement & _this ); - virtual QString nodeName( void ) const; + virtual QString nodeName() const; - virtual void loadFile( const QString & _file ); + virtual void loadResource( const ResourceItem * _item ); - virtual bool isMidiBased( void ) const + virtual void play( sampleFrame * _working_buffer ); + + virtual bool isMidiBased() const { return true; } @@ -71,7 +71,8 @@ public: private: - void closePlugin( void ); + void loadFile( const QString & _file ); + void closePlugin(); int m_runningNotes[NumKeys]; @@ -97,9 +98,9 @@ public: protected slots: - void openPlugin( void ); - void toggleGUI( void ); - void noteOffAll( void ); + void openPlugin(); + void toggleGUI(); + void noteOffAll(); protected: @@ -109,7 +110,7 @@ protected: private: - virtual void modelChanged( void ); + virtual void modelChanged(); static QPixmap * s_artwork;