Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix command line rendering with VSTs #4093

Merged
merged 3 commits into from
Jan 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions plugins/VstEffect/VstEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <QMessageBox>

#include "VstEffect.h"

#include "GuiApplication.h"
#include "Song.h"
#include "TextFloat.h"
#include "VstSubPluginFeatures.h"
Expand Down Expand Up @@ -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<VstPlugin>(new VstPlugin( _plugin ));
Expand Down
5 changes: 4 additions & 1 deletion plugins/VstEffect/VstEffectControlDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
59 changes: 23 additions & 36 deletions plugins/VstEffect/VstEffectControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() ) );
}


Expand All @@ -72,19 +69,13 @@ void VstEffectControls::loadSettings( const QDomElement & _this )
const QMap<QString, QString> & 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 );

Expand All @@ -96,8 +87,6 @@ void VstEffectControls::loadSettings( const QDomElement & _this )
}

connect( knobFModel[i], SIGNAL( dataChanged() ), this, SLOT( setParameter() ) );

vstKnobs[i]->setModel( knobFModel[i] );
}

}
Expand Down Expand Up @@ -358,37 +347,35 @@ manageVSTEffectView::manageVSTEffectView( VstEffect * _eff, VstEffectControls *
const QMap<QString, QString> & 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;
Expand All @@ -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++;
}
Expand Down Expand Up @@ -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" );
}
}
Expand Down Expand Up @@ -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 )
Expand Down
3 changes: 1 addition & 2 deletions plugins/VstEffect/VstEffectControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -133,6 +131,7 @@ protected slots:
QPushButton * m_syncButton;
QPushButton * m_displayAutomatedOnly;
QPushButton * m_closeButton;
Knob ** vstKnobs;

} ;

Expand Down
73 changes: 30 additions & 43 deletions plugins/vestige/vestige.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ vestigeInstrument::vestigeInstrument( InstrumentTrack * _instrument_track ) :
m_pluginMutex(),
m_subWindow( NULL ),
m_scrollArea( NULL ),
vstKnobs( NULL ),
knobFModel( NULL ),
p_subWindow( NULL )
{
Expand Down Expand Up @@ -131,19 +130,13 @@ void vestigeInstrument::loadSettings( const QDomElement & _this )
const QMap<QString, QString> & 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 );

Expand All @@ -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();
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -920,35 +908,34 @@ manageVestigeInstrumentView::manageVestigeInstrumentView( Instrument * _instrume
const QMap<QString, QString> & 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<vestigeInstrument>(), 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;
Expand All @@ -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++;
}
Expand Down Expand Up @@ -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" );
}
}
Expand All @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion plugins/vestige/vestige.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ protected slots:
QString m_pluginDLL;
QMdiSubWindow * m_subWindow;
QScrollArea * m_scrollArea;
Knob ** vstKnobs;
FloatModel ** knobFModel;
QObject * p_subWindow;
int paramCount;
Expand Down Expand Up @@ -130,6 +129,7 @@ protected slots:
QPushButton * m_syncButton;
QPushButton * m_displayAutomatedOnly;
QPushButton * m_closeButton;
Knob ** vstKnobs;

} ;

Expand Down
Loading