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

Handle automation on processing thread #4692

Merged
merged 1 commit into from
Nov 12, 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
17 changes: 17 additions & 0 deletions include/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ class EXPORT Model : public QObject
m_displayName( _display_name ),
m_defaultConstructed( _default_constructed )
{
#if QT_VERSION < 0x050000
connect( this, SIGNAL( dataChanged() ), this,
SLOT( thisDataChanged() ), Qt::DirectConnection );
#endif
}

virtual ~Model()
Expand Down Expand Up @@ -85,6 +89,19 @@ class EXPORT Model : public QObject
// emitted if properties of the model (e.g. ranges) have changed
void propertiesChanged();

#if QT_VERSION < 0x050000
// emitted along with dataChanged(), but with this model as an argument
// workaround for when QObject::sender() and Qt5 are unavailable
void dataChanged( Model * );

private slots:
void thisDataChanged()
{
emit dataChanged( this );
}

signals:
#endif
} ;


Expand Down
29 changes: 19 additions & 10 deletions plugins/VstEffect/VstEffectControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ void VstEffectControls::loadSettings( const QDomElement & _this )
knobFModel[ i ]->setInitValue(LocaleHelper::toFloat(s_dumpValues.at(2)));
}

connect( knobFModel[i], SIGNAL( dataChanged() ), this, SLOT( setParameter() ) );
#if QT_VERSION < 0x050000
connect( knobFModel[i], SIGNAL( dataChanged( Model * ) ),
this, SLOT( setParameter( Model * ) ), Qt::DirectConnection );
#else
connect( knobFModel[i], &FloatModel::dataChanged, this,
[this, i]() { setParameter( knobFModel[i] ); }, Qt::DirectConnection);
#endif
}

}
Expand All @@ -100,10 +106,8 @@ void VstEffectControls::loadSettings( const QDomElement & _this )



void VstEffectControls::setParameter( void )
void VstEffectControls::setParameter( Model * action )
{

Model *action = qobject_cast<Model *>(sender());
int knobUNID = action->displayName().toInt();

if ( m_effect->m_plugin != NULL ) {
Expand Down Expand Up @@ -385,9 +389,16 @@ manageVSTEffectView::manageVSTEffectView( VstEffect * _eff, VstEffectControls *
m_vi->knobFModel[ i ] = new FloatModel( LocaleHelper::toFloat(s_dumpValues.at(2)),
0.0f, 1.0f, 0.01f, _eff, tr( paramStr ) );
}
connect( m_vi->knobFModel[ i ], SIGNAL( dataChanged() ), this,
SLOT( setParameter() ) );
vstKnobs[ i ] ->setModel( m_vi->knobFModel[ i ] );

FloatModel * model = m_vi->knobFModel[i];
#if QT_VERSION < 0x050000
connect( model, SIGNAL( dataChanged( Model * ) ), this,
SLOT( setParameter( Model * ) ), Qt::DirectConnection );
#else
connect( model, &FloatModel::dataChanged, this,
[this, model]() { setParameter( model ); }, Qt::DirectConnection);
#endif
vstKnobs[ i ] ->setModel( model );
}

int i = 0;
Expand Down Expand Up @@ -480,10 +491,8 @@ void manageVSTEffectView::displayAutomatedOnly( void )



void manageVSTEffectView::setParameter( void )
void manageVSTEffectView::setParameter( Model * action )
{

Model *action = qobject_cast<Model *>(sender());
int knobUNID = action->displayName().toInt();

if ( m_effect->m_plugin != NULL ) {
Expand Down
4 changes: 2 additions & 2 deletions plugins/VstEffect/VstEffectControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected slots:
void rollPreset( void );
void rolrPreset( void );
void selPreset( void );
void setParameter( void );
void setParameter( Model * action );

protected:
virtual void paintEvent( QPaintEvent * _pe );
Expand Down Expand Up @@ -110,7 +110,7 @@ class manageVSTEffectView : public QObject
protected slots:
void syncPlugin( void );
void displayAutomatedOnly( void );
void setParameter( void );
void setParameter( Model * action );
void closeWindow();

private:
Expand Down
28 changes: 19 additions & 9 deletions plugins/vestige/vestige.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,13 @@ void vestigeInstrument::loadSettings( const QDomElement & _this )
knobFModel[ i ]->setInitValue(LocaleHelper::toFloat(s_dumpValues.at(2)));
}

connect( knobFModel[i], SIGNAL( dataChanged() ), this, SLOT( setParameter() ) );
#if QT_VERSION < 0x050000
connect( knobFModel[i], SIGNAL( dataChanged( Model * ) ),
this, SLOT( setParameter( Model * ) ), Qt::DirectConnection );
#else
connect( knobFModel[i], &FloatModel::dataChanged, this,
[this, i]() { setParameter( knobFModel[i] ); }, Qt::DirectConnection);
#endif
}
}
m_pluginMutex.unlock();
Expand All @@ -218,10 +224,8 @@ void vestigeInstrument::loadSettings( const QDomElement & _this )



void vestigeInstrument::setParameter( void )
void vestigeInstrument::setParameter( Model * action )
{

Model *action = qobject_cast<Model *>(sender());
int knobUNID = action->displayName().toInt();

if ( m_plugin != NULL ) {
Expand Down Expand Up @@ -996,8 +1000,16 @@ manageVestigeInstrumentView::manageVestigeInstrumentView( Instrument * _instrume
m_vi->knobFModel[ i ] = new FloatModel( LocaleHelper::toFloat(s_dumpValues.at(2)),
0.0f, 1.0f, 0.01f, castModel<vestigeInstrument>(), tr( paramStr ) );
}
connect( m_vi->knobFModel[i], SIGNAL( dataChanged() ), this, SLOT( setParameter() ) );
vstKnobs[i] ->setModel( m_vi->knobFModel[i] );

FloatModel * model = m_vi->knobFModel[i];
#if QT_VERSION < 0x050000
connect( model, SIGNAL( dataChanged( Model * ) ), this,
SLOT( setParameter( Model * ) ), Qt::DirectConnection );
#else
connect( model, &FloatModel::dataChanged, this,
[this, model]() { setParameter( model ); }, Qt::DirectConnection);
#endif
vstKnobs[i] ->setModel( model );
}

int i = 0;
Expand Down Expand Up @@ -1128,10 +1140,8 @@ manageVestigeInstrumentView::~manageVestigeInstrumentView()



void manageVestigeInstrumentView::setParameter( void )
void manageVestigeInstrumentView::setParameter( Model * action )
{

Model *action = qobject_cast<Model *>(sender());
int knobUNID = action->displayName().toInt();

if ( m_vi->m_plugin != NULL ) {
Expand Down
4 changes: 2 additions & 2 deletions plugins/vestige/vestige.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class vestigeInstrument : public Instrument
virtual PluginView * instantiateView( QWidget * _parent );

protected slots:
void setParameter( void );
void setParameter( Model * action );
void handleConfigChange( QString cls, QString attr, QString value );
void reloadPlugin();

Expand Down Expand Up @@ -109,7 +109,7 @@ class manageVestigeInstrumentView : public InstrumentView
protected slots:
void syncPlugin( void );
void displayAutomatedOnly( void );
void setParameter( void );
void setParameter( Model * action );
void closeWindow();


Expand Down
4 changes: 3 additions & 1 deletion plugins/vst_base/RemoteVstPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,9 @@ DWORD WINAPI RemoteVstPlugin::processingThread( LPVOID _param )
RemotePluginClient::message m;
while( ( m = _this->receiveMessage() ).id != IdQuit )
{
if( m.id == IdStartProcessing || m.id == IdMidiEvent )
if( m.id == IdStartProcessing
|| m.id == IdMidiEvent
|| m.id == IdVstSetParameter )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! 👍

{
_this->processMessage( m );
}
Expand Down
23 changes: 15 additions & 8 deletions plugins/zynaddsubfx/ZynAddSubFx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,20 @@ ZynAddSubFxInstrument::ZynAddSubFxInstrument(
{
initPlugin();

connect( &m_portamentoModel, SIGNAL( dataChanged() ), this, SLOT( updatePortamento() ) );
connect( &m_filterFreqModel, SIGNAL( dataChanged() ), this, SLOT( updateFilterFreq() ) );
connect( &m_filterQModel, SIGNAL( dataChanged() ), this, SLOT( updateFilterQ() ) );
connect( &m_bandwidthModel, SIGNAL( dataChanged() ), this, SLOT( updateBandwidth() ) );
connect( &m_fmGainModel, SIGNAL( dataChanged() ), this, SLOT( updateFmGain() ) );
connect( &m_resCenterFreqModel, SIGNAL( dataChanged() ), this, SLOT( updateResCenterFreq() ) );
connect( &m_resBandwidthModel, SIGNAL( dataChanged() ), this, SLOT( updateResBandwidth() ) );
connect( &m_portamentoModel, SIGNAL( dataChanged() ),
this, SLOT( updatePortamento() ), Qt::DirectConnection );
connect( &m_filterFreqModel, SIGNAL( dataChanged() ),
this, SLOT( updateFilterFreq() ), Qt::DirectConnection );
connect( &m_filterQModel, SIGNAL( dataChanged() ),
this, SLOT( updateFilterQ() ), Qt::DirectConnection );
connect( &m_bandwidthModel, SIGNAL( dataChanged() ),
this, SLOT( updateBandwidth() ), Qt::DirectConnection );
connect( &m_fmGainModel, SIGNAL( dataChanged() ),
this, SLOT( updateFmGain() ), Qt::DirectConnection );
connect( &m_resCenterFreqModel, SIGNAL( dataChanged() ),
this, SLOT( updateResCenterFreq() ), Qt::DirectConnection );
connect( &m_resBandwidthModel, SIGNAL( dataChanged() ),
this, SLOT( updateResBandwidth() ), Qt::DirectConnection );

// now we need a play-handle which cares for calling play()
InstrumentPlayHandle * iph = new InstrumentPlayHandle( this, _instrumentTrack );
Expand All @@ -138,7 +145,7 @@ ZynAddSubFxInstrument::ZynAddSubFxInstrument(
this, SLOT( reloadPlugin() ) );

connect( instrumentTrack()->pitchRangeModel(), SIGNAL( dataChanged() ),
this, SLOT( updatePitchRange() ) );
this, SLOT( updatePitchRange() ), Qt::DirectConnection );
}


Expand Down
6 changes: 4 additions & 2 deletions src/core/AutomatableModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@ void AutomatableModel::linkModel( AutomatableModel* model )

if( !model->hasLinkedModels() )
{
QObject::connect( this, SIGNAL( dataChanged() ), model, SIGNAL( dataChanged() ) );
QObject::connect( this, SIGNAL( dataChanged() ),
model, SIGNAL( dataChanged() ), Qt::DirectConnection );
}
}
}
Expand Down Expand Up @@ -476,7 +477,8 @@ void AutomatableModel::setControllerConnection( ControllerConnection* c )
m_controllerConnection = c;
if( c )
{
QObject::connect( m_controllerConnection, SIGNAL( valueChanged() ), this, SIGNAL( dataChanged() ) );
QObject::connect( m_controllerConnection, SIGNAL( valueChanged() ),
this, SIGNAL( dataChanged() ), Qt::DirectConnection );
QObject::connect( m_controllerConnection, SIGNAL( destroyed() ), this, SLOT( unlinkControllerConnection() ) );
m_valueChanged = true;
emit dataChanged();
Expand Down
2 changes: 1 addition & 1 deletion src/core/ControllerConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void ControllerConnection::setController( Controller * _controller )
{
_controller->addConnection( this );
QObject::connect( _controller, SIGNAL( valueChanged() ),
this, SIGNAL( valueChanged() ) );
this, SIGNAL( valueChanged() ), Qt::DirectConnection );
}

m_ownsController =
Expand Down
12 changes: 8 additions & 4 deletions src/tracks/InstrumentTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,14 @@ InstrumentTrack::InstrumentTrack( TrackContainer* tc ) :

setName( tr( "Default preset" ) );

connect( &m_baseNoteModel, SIGNAL( dataChanged() ), this, SLOT( updateBaseNote() ) );
connect( &m_pitchModel, SIGNAL( dataChanged() ), this, SLOT( updatePitch() ) );
connect( &m_pitchRangeModel, SIGNAL( dataChanged() ), this, SLOT( updatePitchRange() ) );
connect( &m_effectChannelModel, SIGNAL( dataChanged() ), this, SLOT( updateEffectChannel() ) );
connect( &m_baseNoteModel, SIGNAL( dataChanged() ),
this, SLOT( updateBaseNote() ), Qt::DirectConnection );
connect( &m_pitchModel, SIGNAL( dataChanged() ),
this, SLOT( updatePitch() ), Qt::DirectConnection );
connect( &m_pitchRangeModel, SIGNAL( dataChanged() ),
this, SLOT( updatePitchRange() ), Qt::DirectConnection );
connect( &m_effectChannelModel, SIGNAL( dataChanged() ),
this, SLOT( updateEffectChannel() ), Qt::DirectConnection );
}


Expand Down