Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
30 changes: 30 additions & 0 deletions include/CustomTextKnob.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Text customizable knob */
#ifndef CUSTOM_TEXT_KNOB_H
#define CUSTOM_TEXT_KNOB_H

#include "Knob.h"

class LMMS_EXPORT CustomTextKnob : public Knob
{
protected:
inline void setHintText( const QString & _txt_before, const QString & _txt_after ) {} // inaccessible
public:
CustomTextKnob( knobTypes _knob_num, QWidget * _parent = NULL, const QString & _name = QString(), const QString & _value_text = QString() );

CustomTextKnob( QWidget * _parent = NULL, const QString & _name = QString(), const QString & _value_text = QString() ); //!< default ctor

CustomTextKnob( const Knob& other ) = delete;

inline void setValueText(const QString & _value_text)
{
m_value_text = _value_text;
}

private:
virtual QString displayValue() const;

protected:
QString m_value_text;
} ;

#endif
2 changes: 1 addition & 1 deletion include/Knob.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private slots:
void toggleScale();

private:
QString displayValue() const;
virtual QString displayValue() const;

void doConnections() override;

Expand Down
2 changes: 2 additions & 0 deletions include/aeffectx.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ const int effClose = 1; // currently unused
const int effSetProgram = 2; // currently unused
const int effGetProgram = 3; // currently unused
const int effGetProgramName = 5; // currently unused
const int effGetParamLabel = 6;
const int effGetParamDisplay = 7;
const int effGetParamName = 8; // currently unused
const int effSetSampleRate = 10;
const int effSetBlockSize = 11;
Expand Down
25 changes: 22 additions & 3 deletions plugins/VstEffect/VstEffectControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ manageVSTEffectView::manageVSTEffectView( VstEffect * _eff, VstEffectControls *
const QMap<QString, QString> & dump = m_effect->m_plugin->parameterDump();
m_vi->paramCount = dump.size();

vstKnobs = new Knob *[ m_vi->paramCount ];
vstKnobs = new CustomTextKnob *[ m_vi->paramCount ];

bool hasKnobModel = true;
if (m_vi->knobFModel == NULL) {
Expand All @@ -366,8 +366,8 @@ manageVSTEffectView::manageVSTEffectView( VstEffect * _eff, VstEffectControls *
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 ] = new CustomTextKnob( knobBright_26, widget, s_dumpValues.at( 1 ) );
vstKnobs[ i ]->setDescription( s_dumpValues.at( 1 ) + ":" );
vstKnobs[ i ]->setLabel( s_dumpValues.at( 1 ).left( 15 ) );

if( !hasKnobModel )
Expand All @@ -382,6 +382,7 @@ manageVSTEffectView::manageVSTEffectView( VstEffect * _eff, VstEffectControls *
[this, model]() { setParameter( model ); }, Qt::DirectConnection);
vstKnobs[ i ] ->setModel( model );
}
syncParameterText();

int i = 0;
for( int lrow = 1; lrow < ( int( m_vi->paramCount / 10 ) + 1 ) + 1; lrow++ )
Expand Down Expand Up @@ -444,6 +445,7 @@ void manageVSTEffectView::syncPlugin( void )
m_vi2->knobFModel[ i ]->setInitValue( f_value );
}
}
syncParameterText();
}


Expand Down Expand Up @@ -479,9 +481,26 @@ void manageVSTEffectView::setParameter( Model * action )

if ( m_effect->m_plugin != NULL ) {
m_effect->m_plugin->setParam( knobUNID, m_vi2->knobFModel[knobUNID]->value() );
syncParameterText();
}
}

void manageVSTEffectView::syncParameterText()
{
m_effect->m_plugin->loadParameterLabels();
m_effect->m_plugin->loadParameterDisplays();

QString paramLabelStr = m_effect->m_plugin->allParameterLabels();
QString paramDisplayStr = m_effect->m_plugin->allParameterDisplays();

QStringList paramLabelList = paramLabelStr.split("|");
QStringList paramDisplayList = paramDisplayStr.split("|");

for( int i = 0; i < paramLabelList.size(); ++i )
{
vstKnobs[i]->setValueText(paramDisplayList[i] + ' ' + paramLabelList[i]);
}
}



Expand Down
5 changes: 3 additions & 2 deletions plugins/VstEffect/VstEffectControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#include <QMdiSubWindow>
#include <QScrollArea>
#include "Knob.h"
#include "CustomTextKnob.h"
#include <QLayout>
#include <QPainter>
#include <QObject>
Expand Down Expand Up @@ -111,6 +111,7 @@ protected slots:
void syncPlugin( void );
void displayAutomatedOnly( void );
void setParameter( Model * action );
void syncParameterText();
void closeWindow();

private:
Expand All @@ -129,7 +130,7 @@ protected slots:
QPushButton * m_syncButton;
QPushButton * m_displayAutomatedOnly;
QPushButton * m_closeButton;
Knob ** vstKnobs;
CustomTextKnob ** vstKnobs;

} ;

Expand Down
28 changes: 25 additions & 3 deletions plugins/vestige/vestige.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#include <QMenu>
#include <QDomElement>

#include <string>

#include "ConfigManager.h"
#include "BufferManager.h"
#include "ConfigManager.h"
Expand Down Expand Up @@ -951,7 +953,7 @@ manageVestigeInstrumentView::manageVestigeInstrumentView( Instrument * _instrume
const QMap<QString, QString> & dump = m_vi->m_plugin->parameterDump();
m_vi->paramCount = dump.size();

vstKnobs = new Knob *[ m_vi->paramCount ];
vstKnobs = new CustomTextKnob *[ m_vi->paramCount ];

bool hasKnobModel = true;
if (m_vi->knobFModel == NULL) {
Expand All @@ -967,8 +969,8 @@ manageVestigeInstrumentView::manageVestigeInstrumentView( Instrument * _instrume
sprintf( paramStr, "param%d", i);
s_dumpValues = dump[ paramStr ].split( ":" );

vstKnobs[ i ] = new Knob( knobBright_26, this, s_dumpValues.at( 1 ) );
vstKnobs[ i ]->setHintText( s_dumpValues.at( 1 ) + ":", "" );
vstKnobs[ i ] = new CustomTextKnob( knobBright_26, this, s_dumpValues.at( 1 ) );
vstKnobs[ i ]->setDescription( s_dumpValues.at( 1 ) + ":" );
vstKnobs[ i ]->setLabel( s_dumpValues.at( 1 ).left( 15 ) );

if( !hasKnobModel )
Expand All @@ -983,6 +985,7 @@ manageVestigeInstrumentView::manageVestigeInstrumentView( Instrument * _instrume
[this, model]() { setParameter( model ); }, Qt::DirectConnection);
vstKnobs[i] ->setModel( model );
}
syncParameterText();

int i = 0;
for( int lrow = 1; lrow < ( int( m_vi->paramCount / 10 ) + 1 ) + 1; lrow++ )
Expand Down Expand Up @@ -1043,6 +1046,7 @@ void manageVestigeInstrumentView::syncPlugin( void )
m_vi->knobFModel[ i ]->setInitValue( f_value );
}
}
syncParameterText();
}


Expand Down Expand Up @@ -1118,6 +1122,24 @@ void manageVestigeInstrumentView::setParameter( Model * action )

if ( m_vi->m_plugin != NULL ) {
m_vi->m_plugin->setParam( knobUNID, m_vi->knobFModel[knobUNID]->value() );
syncParameterText();
}
}

void manageVestigeInstrumentView::syncParameterText()
{
m_vi->m_plugin->loadParameterLabels();
m_vi->m_plugin->loadParameterDisplays();

QString paramLabelStr = m_vi->m_plugin->allParameterLabels();
QString paramDisplayStr = m_vi->m_plugin->allParameterDisplays();

QStringList paramLabelList = paramLabelStr.split("|");
QStringList paramDisplayList = paramDisplayStr.split("|");

for( int i = 0; i < paramLabelList.size(); ++i )
{
vstKnobs[i]->setValueText(paramDisplayList[i] + ' ' + paramLabelList[i]);
}
}

Expand Down
5 changes: 3 additions & 2 deletions plugins/vestige/vestige.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "Instrument.h"
#include "InstrumentView.h"
#include "Note.h"
#include "Knob.h"
#include "CustomTextKnob.h"
#include "SubWindow.h"
#include "AutomatableModel.h"

Expand Down Expand Up @@ -109,6 +109,7 @@ protected slots:
void syncPlugin( void );
void displayAutomatedOnly( void );
void setParameter( Model * action );
void syncParameterText();
void closeWindow();


Expand All @@ -128,7 +129,7 @@ protected slots:
QPushButton * m_syncButton;
QPushButton * m_displayAutomatedOnly;
QPushButton * m_closeButton;
Knob ** vstKnobs;
CustomTextKnob ** vstKnobs;

} ;

Expand Down
52 changes: 52 additions & 0 deletions plugins/vst_base/RemoteVstPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#include <queue>
#include <string>
#include <iostream>
#include <string>

#include <aeffectx.h>

Expand Down Expand Up @@ -223,6 +224,10 @@ class RemoteVstPlugin : public RemotePluginClient
// determine name of current program
const char * programName();

void getParameterDisplays();

void getParameterLabels();

// send name of current program back to host
void sendCurrentProgramName();

Expand Down Expand Up @@ -660,6 +665,14 @@ bool RemoteVstPlugin::processMessage( const message & _m )
//sendMessage( IdVstSetParameter );
break;

case IdVstParameterDisplays:
getParameterDisplays();
break;

case IdVstParameterLabels:
getParameterLabels();
break;


case IdVstIdleUpdate:
{
Expand Down Expand Up @@ -1068,6 +1081,45 @@ const char * RemoteVstPlugin::programName()



// join the ParameterDisplays (stringified values without units) and send them to host
void RemoteVstPlugin::getParameterDisplays()
{
std::string presName;
static char buf[9]; // buffer for getting string
for (int i=0; i< m_plugin->numParams; ++i)
{
memset( buf, 0, sizeof( buf ) ); // fill with '\0' because got string may not to be ended with '\0'
pluginDispatch( effGetParamDisplay, i, 0, buf );
buf[8] = 0;
if (i != 0) presName += '|';
presName += buf;
}

sendMessage( message( IdVstParameterDisplays ).addString( presName.c_str() ) );
}



// join the ParameterLabels (units) and send them to host
void RemoteVstPlugin::getParameterLabels()
{
std::string presName;
static char buf[9]; // buffer for getting string
for (int i=0; i< m_plugin->numParams; ++i)
{
memset( buf, 0, sizeof( buf ) ); // fill with '\0' because got string may not to be ended with '\0'
pluginDispatch( effGetParamLabel, i, 0, buf );
buf[8] = 0;
if (i != 0) presName += '|';
presName += buf;
}

sendMessage( message( IdVstParameterLabels ).addString( presName.c_str() ) );
}




void RemoteVstPlugin::sendCurrentProgramName()
{
char presName[64];
Expand Down
30 changes: 30 additions & 0 deletions plugins/vst_base/VstPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,14 @@ bool VstPlugin::processMessage( const message & _m )
m_allProgramNames = _m.getQString();
break;

case IdVstParameterLabels:
m_allParameterLabels = _m.getQString();
break;

case IdVstParameterDisplays:
m_allParameterDisplays = _m.getQString();
break;

case IdVstPluginUniqueID:
// TODO: display graphically in case of failure
printf("unique ID: %s\n", _m.getString().c_str() );
Expand Down Expand Up @@ -531,6 +539,28 @@ void VstPlugin::loadProgramNames()



void VstPlugin::loadParameterLabels()
{
lock();
sendMessage( message( IdVstParameterLabels ) );
waitForMessage( IdVstParameterLabels, true );
unlock();
}




void VstPlugin::loadParameterDisplays()
{
lock();
sendMessage( message( IdVstParameterDisplays ) );
waitForMessage( IdVstParameterDisplays, true );
unlock();
}




void VstPlugin::savePreset( )
{
QString presName = currentProgramName().isEmpty() ? tr(": default") : currentProgramName();
Expand Down
14 changes: 14 additions & 0 deletions plugins/vst_base/VstPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ class VSTBASE_EXPORT VstPlugin : public RemotePlugin, public JournallingObject
return m_allProgramNames;
}

inline const QString& allParameterLabels() const
{
return m_allParameterLabels;
}

inline const QString& allParameterDisplays() const
{
return m_allParameterDisplays;
}

int currentProgram();

const QMap<QString, QString> & parameterDump();
Expand Down Expand Up @@ -120,6 +130,8 @@ public slots:
void setProgram( int index );
void rotateProgram( int offset );
void loadProgramNames();
void loadParameterLabels();
void loadParameterDisplays();
void savePreset( void );
void setParam( int i, float f );
void idleUpdate();
Expand Down Expand Up @@ -148,6 +160,8 @@ public slots:
QString m_productString;
QString m_currentProgramName;
QString m_allProgramNames;
QString m_allParameterLabels;
QString m_allParameterDisplays;

QString p_name;

Expand Down
Loading