diff --git a/plugins/VstEffect/VstEffect.cpp b/plugins/VstEffect/VstEffect.cpp index 178aa045619..ea0241a5a31 100644 --- a/plugins/VstEffect/VstEffect.cpp +++ b/plugins/VstEffect/VstEffect.cpp @@ -25,6 +25,8 @@ #include #include "VstEffect.h" + +#include "GuiApplication.h" #include "Song.h" #include "TextFloat.h" #include "VstSubPluginFeatures.h" @@ -122,10 +124,14 @@ bool VstEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) void VstEffect::openPlugin( const QString & _plugin ) { - TextFloat * tf = TextFloat::displayMessage( - VstPlugin::tr( "Loading plugin" ), - VstPlugin::tr( "Please wait while loading VST plugin..." ), - PLUGIN_NAME::getIconPixmap( "logo", 24, 24 ), 0 ); + TextFloat * tf = NULL; + if( gui ) + { + tf = TextFloat::displayMessage( + VstPlugin::tr( "Loading plugin" ), + VstPlugin::tr( "Please wait while loading VST plugin..." ), + PLUGIN_NAME::getIconPixmap( "logo", 24, 24 ), 0 ); + } QMutexLocker ml( &m_pluginMutex ); Q_UNUSED( ml ); m_plugin = QSharedPointer(new VstPlugin( _plugin )); diff --git a/plugins/VstEffect/VstEffectControlDialog.cpp b/plugins/VstEffect/VstEffectControlDialog.cpp index 021fae4900b..34ad097c9cd 100644 --- a/plugins/VstEffect/VstEffectControlDialog.cpp +++ b/plugins/VstEffect/VstEffectControlDialog.cpp @@ -192,7 +192,10 @@ VstEffectControlDialog::VstEffectControlDialog( VstEffectControls * _ctl ) : _ctl->m_selPresetButton->setWhatsThis( tr( "Click here to select presets that are currently loaded in VST." ) ); - _ctl->m_selPresetButton->setMenu(_ctl->menu); + QMenu * menu = new QMenu; + connect( menu, SIGNAL( aboutToShow() ), _ctl, SLOT( updateMenu() ) ); + + _ctl->m_selPresetButton->setMenu(menu); _ctl->m_selPresetButton->setMinimumWidth( 16 ); _ctl->m_selPresetButton->setMaximumWidth( 16 ); diff --git a/plugins/VstEffect/VstEffectControls.cpp b/plugins/VstEffect/VstEffectControls.cpp index ff237943960..92688545be2 100644 --- a/plugins/VstEffect/VstEffectControls.cpp +++ b/plugins/VstEffect/VstEffectControls.cpp @@ -39,13 +39,10 @@ VstEffectControls::VstEffectControls( VstEffect * _eff ) : m_effect( _eff ), m_subWindow( NULL ), knobFModel( NULL ), - vstKnobs( NULL ), ctrHandle( NULL ), lastPosInMenu (0) // m_presetLabel ( NULL ) { - menu = new QMenu; - connect( menu, SIGNAL( aboutToShow() ), this, SLOT( updateMenu() ) ); } @@ -72,19 +69,13 @@ void VstEffectControls::loadSettings( const QDomElement & _this ) const QMap & dump = m_effect->m_plugin->parameterDump(); paramCount = dump.size(); char paramStr[35]; - vstKnobs = new Knob *[ paramCount ]; knobFModel = new FloatModel *[ paramCount ]; QStringList s_dumpValues; - QWidget * widget = new QWidget(); for( int i = 0; i < paramCount; i++ ) { sprintf( paramStr, "param%d", i ); s_dumpValues = dump[ paramStr ].split( ":" ); - vstKnobs[i] = new Knob( knobBright_26, widget, s_dumpValues.at( 1 ) ); - vstKnobs[i]->setHintText( s_dumpValues.at( 1 ) + ":", "" ); - vstKnobs[i]->setLabel( s_dumpValues.at( 1 ).left( 15 ) ); - knobFModel[i] = new FloatModel( 0.0f, 0.0f, 1.0f, 0.01f, this, QString::number(i) ); knobFModel[i]->loadSettings( _this, paramStr ); @@ -96,8 +87,6 @@ void VstEffectControls::loadSettings( const QDomElement & _this ) } connect( knobFModel[i], SIGNAL( dataChanged() ), this, SLOT( setParameter() ) ); - - vstKnobs[i]->setModel( knobFModel[i] ); } } @@ -358,37 +347,35 @@ manageVSTEffectView::manageVSTEffectView( VstEffect * _eff, VstEffectControls * const QMap & dump = m_effect->m_plugin->parameterDump(); m_vi->paramCount = dump.size(); - bool isVstKnobs = true; + vstKnobs = new Knob *[ m_vi->paramCount ]; - - if (m_vi->vstKnobs == NULL) { - m_vi->vstKnobs = new Knob *[ m_vi->paramCount ]; - isVstKnobs = false; - } + bool hasKnobModel = true; if (m_vi->knobFModel == NULL) { m_vi->knobFModel = new FloatModel *[ m_vi->paramCount ]; + hasKnobModel = false; } char paramStr[35]; QStringList s_dumpValues; - if (isVstKnobs == false) { - for( int i = 0; i < m_vi->paramCount; i++ ) - { - sprintf( paramStr, "param%d", i); - s_dumpValues = dump[ paramStr ].split( ":" ); + for( int i = 0; i < m_vi->paramCount; i++ ) + { + sprintf( paramStr, "param%d", i); + s_dumpValues = dump[ paramStr ].split( ":" ); - m_vi->vstKnobs[ i ] = new Knob( knobBright_26, widget, s_dumpValues.at( 1 ) ); - m_vi->vstKnobs[ i ]->setHintText( s_dumpValues.at( 1 ) + ":", "" ); - m_vi->vstKnobs[ i ]->setLabel( s_dumpValues.at( 1 ).left( 15 ) ); + vstKnobs[ i ] = new Knob( knobBright_26, widget, s_dumpValues.at( 1 ) ); + vstKnobs[ i ]->setHintText( s_dumpValues.at( 1 ) + ":", "" ); + vstKnobs[ i ]->setLabel( s_dumpValues.at( 1 ).left( 15 ) ); + if( !hasKnobModel ) + { sprintf( paramStr, "%d", i); m_vi->knobFModel[ i ] = new FloatModel( ( s_dumpValues.at( 2 ) ).toFloat(), 0.0f, 1.0f, 0.01f, _eff, tr( paramStr ) ); - connect( m_vi->knobFModel[ i ], SIGNAL( dataChanged() ), this, - SLOT( setParameter() ) ); - m_vi->vstKnobs[ i ] ->setModel( m_vi->knobFModel[ i ] ); } + connect( m_vi->knobFModel[ i ], SIGNAL( dataChanged() ), this, + SLOT( setParameter() ) ); + vstKnobs[ i ] ->setModel( m_vi->knobFModel[ i ] ); } int i = 0; @@ -398,7 +385,7 @@ manageVSTEffectView::manageVSTEffectView( VstEffect * _eff, VstEffectControls * { if( i < m_vi->paramCount ) { - l->addWidget( m_vi->vstKnobs[i], lrow, lcolumn, Qt::AlignCenter ); + l->addWidget( vstKnobs[i], lrow, lcolumn, Qt::AlignCenter ); } i++; } @@ -466,12 +453,12 @@ void manageVSTEffectView::displayAutomatedOnly( void ) if( !( m_vi2->knobFModel[ i ]->isAutomated() || m_vi2->knobFModel[ i ]->controllerConnection() ) ) { - if( m_vi2->vstKnobs[ i ]->isVisible() == true && isAuto ) + if( vstKnobs[ i ]->isVisible() == true && isAuto ) { - m_vi2->vstKnobs[ i ]->hide(); + vstKnobs[ i ]->hide(); m_displayAutomatedOnly->setText( "All" ); } else { - m_vi2->vstKnobs[ i ]->show(); + vstKnobs[ i ]->show(); m_displayAutomatedOnly->setText( "Automated" ); } } @@ -502,14 +489,14 @@ manageVSTEffectView::~manageVSTEffectView() for( int i = 0; i < m_vi2->paramCount; i++ ) { delete m_vi2->knobFModel[ i ]; - delete m_vi2->vstKnobs[ i ]; + delete vstKnobs[ i ]; } } - if( m_vi2->vstKnobs != NULL ) + if( vstKnobs != NULL ) { - delete [] m_vi2->vstKnobs; - m_vi2->vstKnobs = NULL; + delete [] vstKnobs; + vstKnobs = NULL; } if( m_vi2->knobFModel != NULL ) diff --git a/plugins/VstEffect/VstEffectControls.h b/plugins/VstEffect/VstEffectControls.h index 12e30f08f5f..7328f2f42d6 100644 --- a/plugins/VstEffect/VstEffectControls.h +++ b/plugins/VstEffect/VstEffectControls.h @@ -82,12 +82,10 @@ protected slots: VstEffect * m_effect; QPushButton * m_selPresetButton; - QMenu *menu; QMdiSubWindow * m_subWindow; QScrollArea * m_scrollArea; FloatModel ** knobFModel; - Knob ** vstKnobs; int paramCount; QObject * ctrHandle; @@ -133,6 +131,7 @@ protected slots: QPushButton * m_syncButton; QPushButton * m_displayAutomatedOnly; QPushButton * m_closeButton; + Knob ** vstKnobs; } ; diff --git a/plugins/vestige/vestige.cpp b/plugins/vestige/vestige.cpp index 22cc804f25e..db9cf5bbaf8 100644 --- a/plugins/vestige/vestige.cpp +++ b/plugins/vestige/vestige.cpp @@ -83,7 +83,6 @@ vestigeInstrument::vestigeInstrument( InstrumentTrack * _instrument_track ) : m_pluginMutex(), m_subWindow( NULL ), m_scrollArea( NULL ), - vstKnobs( NULL ), knobFModel( NULL ), p_subWindow( NULL ) { @@ -131,19 +130,13 @@ void vestigeInstrument::loadSettings( const QDomElement & _this ) const QMap & dump = m_plugin->parameterDump(); paramCount = dump.size(); char paramStr[35]; - vstKnobs = new Knob *[ paramCount ]; knobFModel = new FloatModel *[ paramCount ]; QStringList s_dumpValues; - QWidget * widget = new QWidget(); for( int i = 0; i < paramCount; i++ ) { sprintf( paramStr, "param%d", i ); s_dumpValues = dump[ paramStr ].split( ":" ); - vstKnobs[i] = new Knob( knobBright_26, widget, s_dumpValues.at( 1 ) ); - vstKnobs[i]->setHintText( s_dumpValues.at( 1 ) + ":", "" ); - vstKnobs[i]->setLabel( s_dumpValues.at( 1 ).left( 15 ) ); - knobFModel[i] = new FloatModel( 0.0f, 0.0f, 1.0f, 0.01f, this, QString::number(i) ); knobFModel[i]->loadSettings( _this, paramStr ); @@ -154,8 +147,6 @@ void vestigeInstrument::loadSettings( const QDomElement & _this ) } connect( knobFModel[i], SIGNAL( dataChanged() ), this, SLOT( setParameter() ) ); - - vstKnobs[i]->setModel( knobFModel[i] ); } } m_pluginMutex.unlock(); @@ -266,10 +257,14 @@ void vestigeInstrument::loadFile( const QString & _file ) closePlugin(); } m_pluginDLL = SampleBuffer::tryToMakeRelative( _file ); - TextFloat * tf = TextFloat::displayMessage( - tr( "Loading plugin" ), - tr( "Please wait while loading VST-plugin..." ), - PLUGIN_NAME::getIconPixmap( "logo", 24, 24 ), 0 ); + TextFloat * tf = NULL; + if( gui ) + { + tf = TextFloat::displayMessage( + tr( "Loading plugin" ), + tr( "Please wait while loading VST-plugin..." ), + PLUGIN_NAME::getIconPixmap( "logo", 24, 24 ), 0 ); + } m_pluginMutex.lock(); m_plugin = new VstPlugin( m_pluginDLL ); @@ -347,16 +342,9 @@ void vestigeInstrument::closePlugin( void ) for( int i = 0; i < paramCount; i++ ) { delete knobFModel[ i ]; - delete vstKnobs[ i ]; } } - if( vstKnobs != NULL ) - { - delete [] vstKnobs; - vstKnobs = NULL; - } - if( knobFModel != NULL ) { delete [] knobFModel; @@ -920,35 +908,34 @@ manageVestigeInstrumentView::manageVestigeInstrumentView( Instrument * _instrume const QMap & dump = m_vi->m_plugin->parameterDump(); m_vi->paramCount = dump.size(); - bool isVstKnobs = true; + vstKnobs = new Knob *[ m_vi->paramCount ]; - if (m_vi->vstKnobs == NULL) { - m_vi->vstKnobs = new Knob *[ m_vi->paramCount ]; - isVstKnobs = false; - } + bool hasKnobModel = true; if (m_vi->knobFModel == NULL) { m_vi->knobFModel = new FloatModel *[ m_vi->paramCount ]; + hasKnobModel = false; } char paramStr[35]; QStringList s_dumpValues; - if (isVstKnobs == false) { - for( int i = 0; i < m_vi->paramCount; i++ ) - { - sprintf( paramStr, "param%d", i); - s_dumpValues = dump[ paramStr ].split( ":" ); + for( int i = 0; i < m_vi->paramCount; i++ ) + { + sprintf( paramStr, "param%d", i); + s_dumpValues = dump[ paramStr ].split( ":" ); - m_vi->vstKnobs[ i ] = new Knob( knobBright_26, this, s_dumpValues.at( 1 ) ); - m_vi->vstKnobs[ i ]->setHintText( s_dumpValues.at( 1 ) + ":", "" ); - m_vi->vstKnobs[ i ]->setLabel( s_dumpValues.at( 1 ).left( 15 ) ); + vstKnobs[ i ] = new Knob( knobBright_26, this, s_dumpValues.at( 1 ) ); + vstKnobs[ i ]->setHintText( s_dumpValues.at( 1 ) + ":", "" ); + vstKnobs[ i ]->setLabel( s_dumpValues.at( 1 ).left( 15 ) ); + if( !hasKnobModel ) + { sprintf( paramStr, "%d", i); m_vi->knobFModel[ i ] = new FloatModel( (s_dumpValues.at( 2 )).toFloat(), 0.0f, 1.0f, 0.01f, castModel(), tr( paramStr ) ); - connect( m_vi->knobFModel[i], SIGNAL( dataChanged() ), this, SLOT( setParameter() ) ); - m_vi->vstKnobs[i] ->setModel( m_vi->knobFModel[i] ); } + connect( m_vi->knobFModel[i], SIGNAL( dataChanged() ), this, SLOT( setParameter() ) ); + vstKnobs[i] ->setModel( m_vi->knobFModel[i] ); } int i = 0; @@ -958,7 +945,7 @@ manageVestigeInstrumentView::manageVestigeInstrumentView( Instrument * _instrume { if( i < m_vi->paramCount ) { - l->addWidget( m_vi->vstKnobs[i], lrow, lcolumn, Qt::AlignCenter ); + l->addWidget( vstKnobs[i], lrow, lcolumn, Qt::AlignCenter ); } i++; } @@ -1024,12 +1011,12 @@ void manageVestigeInstrumentView::displayAutomatedOnly( void ) if( !( m_vi->knobFModel[ i ]->isAutomated() || m_vi->knobFModel[ i ]->controllerConnection() ) ) { - if( m_vi->vstKnobs[ i ]->isVisible() == true && isAuto ) + if( vstKnobs[ i ]->isVisible() == true && isAuto ) { - m_vi->vstKnobs[ i ]->hide(); + vstKnobs[ i ]->hide(); m_displayAutomatedOnly->setText( "All" ); } else { - m_vi->vstKnobs[ i ]->show(); + vstKnobs[ i ]->show(); m_displayAutomatedOnly->setText( "Automated" ); } } @@ -1044,13 +1031,13 @@ manageVestigeInstrumentView::~manageVestigeInstrumentView() for( int i = 0; i < m_vi->paramCount; i++ ) { delete m_vi->knobFModel[ i ]; - delete m_vi->vstKnobs[ i ]; + delete vstKnobs[ i ]; } } - if (m_vi->vstKnobs != NULL) { - delete []m_vi->vstKnobs; - m_vi->vstKnobs = NULL; + if (vstKnobs != NULL) { + delete []vstKnobs; + vstKnobs = NULL; } if( m_vi->knobFModel != NULL ) diff --git a/plugins/vestige/vestige.h b/plugins/vestige/vestige.h index df076bbb9cb..2c007efc0c4 100644 --- a/plugins/vestige/vestige.h +++ b/plugins/vestige/vestige.h @@ -87,7 +87,6 @@ protected slots: QString m_pluginDLL; QMdiSubWindow * m_subWindow; QScrollArea * m_scrollArea; - Knob ** vstKnobs; FloatModel ** knobFModel; QObject * p_subWindow; int paramCount; @@ -130,6 +129,7 @@ protected slots: QPushButton * m_syncButton; QPushButton * m_displayAutomatedOnly; QPushButton * m_closeButton; + Knob ** vstKnobs; } ; diff --git a/plugins/vst_base/RemoteVstPlugin.cpp b/plugins/vst_base/RemoteVstPlugin.cpp index 1c403576eff..04ff97731f8 100644 --- a/plugins/vst_base/RemoteVstPlugin.cpp +++ b/plugins/vst_base/RemoteVstPlugin.cpp @@ -110,6 +110,7 @@ static VstHostLanguages hlang = LanguageEnglish; static bool EMBED = false; static bool EMBED_X11 = false; static bool EMBED_WIN32 = false; +static bool HEADLESS = false; class RemoteVstPlugin; @@ -335,7 +336,6 @@ class RemoteVstPlugin : public RemotePluginClient int m_windowHeight; bool m_initialized; - bool m_registeredWindowClass; bool m_processing; @@ -387,7 +387,6 @@ RemoteVstPlugin::RemoteVstPlugin( const char * socketPath ) : m_windowWidth( 0 ), m_windowHeight( 0 ), m_initialized( false ), - m_registeredWindowClass( false ), m_processing( false ), m_messageList(), m_shouldGiveIdle( false ), @@ -689,7 +688,7 @@ static void close_check( int fd ) void RemoteVstPlugin::initEditor() { - if( m_window || !( m_plugin->flags & effFlagsHasEditor ) ) + if( HEADLESS || m_window || !( m_plugin->flags & effFlagsHasEditor ) ) { return; } @@ -703,27 +702,6 @@ void RemoteVstPlugin::initEditor() } - if( !m_registeredWindowClass ) - { - WNDCLASS wc; - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = DefWindowProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInst; - wc.hIcon = LoadIcon( NULL, IDI_APPLICATION ); - wc.hCursor = LoadCursor( NULL, IDC_ARROW ); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; - wc.lpszClassName = "LVSL"; - - if( !RegisterClass( &wc ) ) - { - return; - } - m_registeredWindowClass = true; - } - DWORD dwStyle; if (EMBED) { dwStyle = WS_POPUP | WS_SYSMENU | WS_BORDER; @@ -2019,6 +1997,29 @@ int main( int _argc, char * * _argv ) } #endif + HMODULE hInst = GetModuleHandle( NULL ); + if( hInst == NULL ) + { + return -1; + } + + WNDCLASS wc; + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = DefWindowProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInst; + wc.hIcon = LoadIcon( NULL, IDI_APPLICATION ); + wc.hCursor = LoadCursor( NULL, IDC_ARROW ); + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.lpszClassName = "LVSL"; + + if( !RegisterClass( &wc ) ) + { + return -1; + } + { #ifdef SYNC_WITH_SHM_FIFO int embedMethodIndex = 3; @@ -2030,27 +2031,32 @@ int main( int _argc, char * * _argv ) if ( embedMethod == "none" ) { cerr << "Starting detached." << endl; - EMBED = EMBED_X11 = EMBED_WIN32 = false; + EMBED = EMBED_X11 = EMBED_WIN32 = HEADLESS = false; } else if ( embedMethod == "win32" ) { cerr << "Starting using Win32-native embedding." << endl; - EMBED = EMBED_WIN32 = true; EMBED_X11= false; + EMBED = EMBED_WIN32 = true; EMBED_X11 = HEADLESS = false; } else if ( embedMethod == "qt" ) { cerr << "Starting using Qt-native embedding." << endl; - EMBED = true; EMBED_X11 = EMBED_WIN32 = false; + EMBED = true; EMBED_X11 = EMBED_WIN32 = HEADLESS = false; } else if ( embedMethod == "xembed" ) { cerr << "Starting using X11Embed protocol." << endl; - EMBED = EMBED_X11 = true; EMBED_WIN32 = false; + EMBED = EMBED_X11 = true; EMBED_WIN32 = HEADLESS = false; + } + else if ( embedMethod == "headless" ) + { + cerr << "Starting without UI." << endl; + HEADLESS = true; EMBED = EMBED_X11 = EMBED_WIN32 = false; } else { cerr << "Unknown embed method " << embedMethod << ". Starting detached instead." << endl; - EMBED = EMBED_X11 = EMBED_WIN32 = false; + EMBED = EMBED_X11 = EMBED_WIN32 = HEADLESS = false; } } diff --git a/plugins/vst_base/VstPlugin.cpp b/plugins/vst_base/VstPlugin.cpp index a06663a7e95..5c7504dd11d 100644 --- a/plugins/vst_base/VstPlugin.cpp +++ b/plugins/vst_base/VstPlugin.cpp @@ -88,7 +88,9 @@ class vstSubWin : public QMdiSubWindow VstPlugin::VstPlugin( const QString & _plugin ) : m_plugin( _plugin ), m_pluginWindowID( 0 ), - m_embedMethod( ConfigManager::inst()->vstEmbedMethod() ), + m_embedMethod( gui + ? ConfigManager::inst()->vstEmbedMethod() + : "headless" ), m_badDllFormat( false ), m_version( 0 ), m_currentProgram() @@ -575,7 +577,7 @@ void VstPlugin::showUI() { RemotePlugin::showUI(); } - else + else if ( m_embedMethod != "headless" ) { if (! pluginWidget()) { createUI( NULL, false );