AutomatableModel: renamed to controllerConnection() + coding style fixes
Renamed getControllerConnection() to controllerConnection().
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* AutomatableModel.h - declaration of class AutomatableModel
|
||||
*
|
||||
* Copyright (c) 2007-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
* Copyright (c) 2007-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -39,9 +39,9 @@
|
||||
return (type) modelname->value(); \
|
||||
} \
|
||||
public slots: \
|
||||
inline void setfunc( const type _val ) \
|
||||
inline void setfunc( const type val ) \
|
||||
{ \
|
||||
modelname->setValue( _val ); \
|
||||
modelname->setValue( val ); \
|
||||
}
|
||||
|
||||
#define mapPropertyFromModel(type,getfunc,setfunc,modelname) \
|
||||
@@ -51,9 +51,9 @@
|
||||
return (type) modelname.value(); \
|
||||
} \
|
||||
public slots: \
|
||||
inline void setfunc( const type _val ) \
|
||||
inline void setfunc( const type val ) \
|
||||
{ \
|
||||
modelname.setValue( (float) _val ); \
|
||||
modelname.setValue( (float) val ); \
|
||||
}
|
||||
|
||||
|
||||
@@ -74,60 +74,59 @@ public:
|
||||
Bool
|
||||
} ;
|
||||
|
||||
AutomatableModel( DataType _type,
|
||||
const float _val = 0,
|
||||
const float _min = 0,
|
||||
const float _max = 0,
|
||||
const float _step = 0,
|
||||
::Model * _parent = NULL,
|
||||
const QString & _display_name = QString(),
|
||||
bool _default_constructed = false );
|
||||
AutomatableModel( DataType type,
|
||||
const float val = 0,
|
||||
const float min = 0,
|
||||
const float max = 0,
|
||||
const float step = 0,
|
||||
Model* parent = NULL,
|
||||
const QString& display_name = QString(),
|
||||
bool default_constructed = false );
|
||||
|
||||
virtual ~AutomatableModel();
|
||||
|
||||
|
||||
static inline float copiedValue()
|
||||
static float copiedValue()
|
||||
{
|
||||
return __copiedValue;
|
||||
return s_copiedValue;
|
||||
}
|
||||
|
||||
bool isAutomated() const;
|
||||
|
||||
inline ControllerConnection * getControllerConnection() const
|
||||
inline ControllerConnection* controllerConnection() const
|
||||
{
|
||||
return m_controllerConnection;
|
||||
}
|
||||
|
||||
|
||||
void setControllerConnection( ControllerConnection * _c );
|
||||
void setControllerConnection( ControllerConnection* c );
|
||||
|
||||
|
||||
template<class T>
|
||||
static inline T castValue( const float _v )
|
||||
static inline T castValue( const float v )
|
||||
{
|
||||
return (T)( _v );
|
||||
return (T)( v );
|
||||
}
|
||||
|
||||
template<bool>
|
||||
static inline bool castValue( const float _v )
|
||||
static inline bool castValue( const float v )
|
||||
{
|
||||
return ( qRound( _v ) != 0 );
|
||||
return ( qRound( v ) != 0 );
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T value( int _frameOffset = 0 ) const
|
||||
inline T value( int frameOffset = 0 ) const
|
||||
{
|
||||
if( unlikely( m_hasLinkedModels ||
|
||||
m_controllerConnection != NULL ) )
|
||||
if( unlikely( m_hasLinkedModels || m_controllerConnection != NULL ) )
|
||||
{
|
||||
return castValue<T>( controllerValue( _frameOffset ) );
|
||||
return castValue<T>( controllerValue( frameOffset ) );
|
||||
}
|
||||
|
||||
return castValue<T>( m_value );
|
||||
}
|
||||
|
||||
float controllerValue( int _frameOffset ) const;
|
||||
float controllerValue( int frameOffset ) const;
|
||||
|
||||
|
||||
template<class T>
|
||||
@@ -155,14 +154,14 @@ public:
|
||||
}
|
||||
|
||||
|
||||
void setInitValue( const float _value );
|
||||
void setInitValue( const float value );
|
||||
|
||||
void setAutomatedValue( const float _value );
|
||||
void setValue( const float _value );
|
||||
void setAutomatedValue( const float value );
|
||||
void setValue( const float value );
|
||||
|
||||
inline void incValue( int _steps )
|
||||
inline void incValue( int steps )
|
||||
{
|
||||
setValue( m_value + _steps * m_step );
|
||||
setValue( m_value + steps * m_step );
|
||||
}
|
||||
|
||||
inline float range() const
|
||||
@@ -170,24 +169,19 @@ public:
|
||||
return m_range;
|
||||
}
|
||||
|
||||
void setRange( const float _min, const float _max,
|
||||
const float _step = 1 );
|
||||
void setRange( const float min, const float max, const float step = 1 );
|
||||
|
||||
void setStep( const float _step );
|
||||
void setStep( const float step );
|
||||
|
||||
static void linkModels( AutomatableModel * _m1,
|
||||
AutomatableModel * _m2 );
|
||||
static void unlinkModels( AutomatableModel * _m1,
|
||||
AutomatableModel * _m2 );
|
||||
static void linkModels( AutomatableModel* m1, AutomatableModel* m2 );
|
||||
static void unlinkModels( AutomatableModel* m1, AutomatableModel* m2 );
|
||||
|
||||
void unlinkAllModels();
|
||||
|
||||
virtual void saveSettings( QDomDocument & _doc,
|
||||
QDomElement & _this,
|
||||
const QString & _name = QString( "value" ) );
|
||||
virtual void saveSettings( QDomDocument& doc, QDomElement& element,
|
||||
const QString& name = QString( "value" ) );
|
||||
|
||||
virtual void loadSettings( const QDomElement & _this,
|
||||
const QString & _name = QString( "value" ) );
|
||||
virtual void loadSettings( const QDomElement& element, const QString& name = QString( "value" ) );
|
||||
|
||||
virtual QString nodeName() const
|
||||
{
|
||||
@@ -199,13 +193,13 @@ public:
|
||||
void addJournalEntryFromOldToCurVal();
|
||||
|
||||
|
||||
QString displayValue( const float _val ) const
|
||||
QString displayValue( const float val ) const
|
||||
{
|
||||
switch( m_dataType )
|
||||
{
|
||||
case Float: return QString::number( castValue<float>( _val ) );
|
||||
case Integer: return QString::number( castValue<int>( _val ) );
|
||||
case Bool: return QString::number( castValue<bool>( _val ) );
|
||||
case Float: return QString::number( castValue<float>( val ) );
|
||||
case Integer: return QString::number( castValue<int>( val ) );
|
||||
case Bool: return QString::number( castValue<bool>( val ) );
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
@@ -224,15 +218,15 @@ public slots:
|
||||
|
||||
|
||||
protected:
|
||||
virtual void redoStep( JournalEntry & _je );
|
||||
virtual void undoStep( JournalEntry & _je );
|
||||
virtual void redoStep( JournalEntry& je );
|
||||
virtual void undoStep( JournalEntry& je );
|
||||
|
||||
float fittedValue( float _value ) const;
|
||||
float fittedValue( float value ) const;
|
||||
|
||||
|
||||
private:
|
||||
void linkModel( AutomatableModel * _model );
|
||||
void unlinkModel( AutomatableModel * _model );
|
||||
void linkModel( AutomatableModel* model );
|
||||
void unlinkModel( AutomatableModel* model );
|
||||
|
||||
|
||||
DataType m_dataType;
|
||||
@@ -253,15 +247,15 @@ private:
|
||||
bool m_hasLinkedModels;
|
||||
|
||||
|
||||
ControllerConnection * m_controllerConnection;
|
||||
ControllerConnection* m_controllerConnection;
|
||||
|
||||
|
||||
static float __copiedValue;
|
||||
static float s_copiedValue;
|
||||
|
||||
|
||||
signals:
|
||||
void initValueChanged( float _val );
|
||||
void destroyed( jo_id_t _id );
|
||||
void initValueChanged( float val );
|
||||
void destroyed( jo_id_t id );
|
||||
|
||||
} ;
|
||||
|
||||
@@ -270,9 +264,9 @@ signals:
|
||||
|
||||
|
||||
#define defaultTypedMethods(type) \
|
||||
inline type value( int _frameOffset = 0 ) const \
|
||||
inline type value( int frameOffset = 0 ) const \
|
||||
{ \
|
||||
return AutomatableModel::value<type>( _frameOffset ); \
|
||||
return AutomatableModel::value<type>( frameOffset ); \
|
||||
} \
|
||||
\
|
||||
inline type initValue() const \
|
||||
@@ -296,12 +290,11 @@ signals:
|
||||
class FloatModel : public AutomatableModel
|
||||
{
|
||||
public:
|
||||
FloatModel( float _val = 0, float _min = 0, float _max = 0,
|
||||
float _step = 0, ::Model * _parent = NULL,
|
||||
const QString & _display_name = QString(),
|
||||
bool _default_constructed = false ) :
|
||||
AutomatableModel( Float, _val, _min, _max, _step,
|
||||
_parent, _display_name, _default_constructed )
|
||||
FloatModel( float val = 0, float min = 0, float max = 0, float step = 0,
|
||||
Model * parent = NULL,
|
||||
const QString& displayName = QString(),
|
||||
bool defaultConstructed = false ) :
|
||||
AutomatableModel( Float, val, min, max, step, parent, displayName, defaultConstructed )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -313,12 +306,11 @@ public:
|
||||
class IntModel : public AutomatableModel
|
||||
{
|
||||
public:
|
||||
IntModel( int _val = 0, int _min = 0, int _max = 0,
|
||||
::Model * _parent = NULL,
|
||||
const QString & _display_name = QString(),
|
||||
bool _default_constructed = false ) :
|
||||
AutomatableModel( Integer, _val, _min, _max, 1,
|
||||
_parent, _display_name, _default_constructed )
|
||||
IntModel( int val = 0, int min = 0, int max = 0,
|
||||
Model* parent = NULL,
|
||||
const QString& displayName = QString(),
|
||||
bool defaultConstructed = false ) :
|
||||
AutomatableModel( Integer, val, min, max, 1, parent, displayName, defaultConstructed )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -330,11 +322,11 @@ public:
|
||||
class BoolModel : public AutomatableModel
|
||||
{
|
||||
public:
|
||||
BoolModel( const bool _val = false, ::Model * _parent = NULL,
|
||||
const QString & _display_name = QString(),
|
||||
bool _default_constructed = false ) :
|
||||
AutomatableModel( Bool, _val, false, true, 1,
|
||||
_parent, _display_name, _default_constructed )
|
||||
BoolModel( const bool val = false,
|
||||
Model* parent = NULL,
|
||||
const QString& displayName = QString(),
|
||||
bool defaultConstructed = false ) :
|
||||
AutomatableModel( Bool, val, false, true, 1, parent, displayName, defaultConstructed )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* vestige.cpp - instrument-plugin for hosting VST-instruments
|
||||
*
|
||||
* Copyright (c) 2005-2013 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
* Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -135,8 +135,7 @@ void vestigeInstrument::loadSettings( const QDomElement & _this )
|
||||
knobFModel[i] = new FloatModel( 0.0f, 0.0f, 1.0f, 0.01f, this, QString::number(i) );
|
||||
knobFModel[i]->loadSettings( _this, paramStr );
|
||||
|
||||
if( !( knobFModel[ i ]->isAutomated() ||
|
||||
knobFModel[ i ]->getControllerConnection() ) )
|
||||
if( !( knobFModel[ i ]->isAutomated() || knobFModel[ i ]->controllerConnection() ) )
|
||||
{
|
||||
knobFModel[ i ]->setValue( ( s_dumpValues.at( 2 )).toFloat() );
|
||||
knobFModel[ i ]->setInitValue( ( s_dumpValues.at( 2 )).toFloat() );
|
||||
@@ -190,7 +189,7 @@ void vestigeInstrument::saveSettings( QDomDocument & _doc, QDomElement & _this )
|
||||
char paramStr[35];
|
||||
for( int i = 0; i < paramCount; i++ )
|
||||
{
|
||||
if (knobFModel[i]->isAutomated() || knobFModel[i]->getControllerConnection()) {
|
||||
if (knobFModel[i]->isAutomated() || knobFModel[i]->controllerConnection()) {
|
||||
sprintf( paramStr, "param%d", i);
|
||||
knobFModel[i]->saveSettings( _doc, _this, paramStr );
|
||||
}
|
||||
@@ -200,7 +199,7 @@ void vestigeInstrument::saveSettings( QDomDocument & _doc, QDomElement & _this )
|
||||
me.setAttribute( "value", knobFModel[i]->value() );
|
||||
_this.appendChild( me );
|
||||
|
||||
ControllerConnection * m_controllerConnection = knobFModel[i]->getControllerConnection();
|
||||
ControllerConnection * m_controllerConnection = knobFModel[i]->controllerConnection();
|
||||
if (m_controllerConnection) {
|
||||
QDomElement controller_element;
|
||||
QDomNode node = _this.namedItem( "connection" );
|
||||
@@ -1016,8 +1015,7 @@ void manageVestigeInstrumentView::syncPlugin( void )
|
||||
{
|
||||
// only not automated knobs are synced from VST
|
||||
// those auto-setted values are not jurnaled, tracked for undo / redo
|
||||
if( !( m_vi->knobFModel[ i ]->isAutomated() ||
|
||||
m_vi->knobFModel[ i ]->getControllerConnection() ) )
|
||||
if( !( m_vi->knobFModel[ i ]->isAutomated() || m_vi->knobFModel[ i ]->controllerConnection() ) )
|
||||
{
|
||||
sprintf( paramStr, "param%d", i );
|
||||
s_dumpValues = dump[ paramStr ].split( ":" );
|
||||
@@ -1038,8 +1036,7 @@ void manageVestigeInstrumentView::displayAutomatedOnly( void )
|
||||
for( int i = 0; i< m_vi->paramCount; i++ )
|
||||
{
|
||||
|
||||
if( !( m_vi->knobFModel[ i ]->isAutomated() ||
|
||||
m_vi->knobFModel[ i ]->getControllerConnection() ) )
|
||||
if( !( m_vi->knobFModel[ i ]->isAutomated() || m_vi->knobFModel[ i ]->controllerConnection() ) )
|
||||
{
|
||||
if( m_vi->vstKnobs[ i ]->isVisible() == true && isAuto )
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* VstEffectControls.cpp - controls for VST effect plugins
|
||||
*
|
||||
* Copyright (c) 2008-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
* Copyright (c) 2008-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -88,7 +88,7 @@ void VstEffectControls::loadSettings( const QDomElement & _this )
|
||||
knobFModel[i]->loadSettings( _this, paramStr );
|
||||
|
||||
if( !( knobFModel[ i ]->isAutomated() ||
|
||||
knobFModel[ i ]->getControllerConnection() ) )
|
||||
knobFModel[ i ]->controllerConnection() ) )
|
||||
{
|
||||
knobFModel[ i ]->setValue( (s_dumpValues.at( 2 ) ).toFloat() );
|
||||
knobFModel[ i ]->setInitValue( (s_dumpValues.at( 2 ) ).toFloat() );
|
||||
@@ -133,7 +133,7 @@ void VstEffectControls::saveSettings( QDomDocument & _doc, QDomElement & _this )
|
||||
char paramStr[35];
|
||||
for( int i = 0; i < paramCount; i++ )
|
||||
{
|
||||
if (knobFModel[i]->isAutomated() || knobFModel[i]->getControllerConnection()) {
|
||||
if (knobFModel[i]->isAutomated() || knobFModel[i]->controllerConnection()) {
|
||||
sprintf( paramStr, "param%d", i);
|
||||
knobFModel[i]->saveSettings( _doc, _this, paramStr );
|
||||
}
|
||||
@@ -443,7 +443,7 @@ void manageVSTEffectView::syncPlugin( void )
|
||||
// only not automated knobs are synced from VST
|
||||
// those auto-setted values are not jurnaled, tracked for undo / redo
|
||||
if( !( m_vi2->knobFModel[ i ]->isAutomated() ||
|
||||
m_vi2->knobFModel[ i ]->getControllerConnection() ) )
|
||||
m_vi2->knobFModel[ i ]->controllerConnection() ) )
|
||||
{
|
||||
sprintf( paramStr, "param%d", i );
|
||||
s_dumpValues = dump[ paramStr ].split( ":" );
|
||||
@@ -464,7 +464,7 @@ void manageVSTEffectView::displayAutomatedOnly( void )
|
||||
{
|
||||
|
||||
if( !( m_vi2->knobFModel[ i ]->isAutomated() ||
|
||||
m_vi2->knobFModel[ i ]->getControllerConnection() ) )
|
||||
m_vi2->knobFModel[ i ]->controllerConnection() ) )
|
||||
{
|
||||
if( m_vi2->vstKnobs[ i ]->isVisible() == true && isAuto )
|
||||
{
|
||||
|
||||
@@ -29,33 +29,28 @@
|
||||
#include "ControllerConnection.h"
|
||||
|
||||
|
||||
float AutomatableModel::__copiedValue = 0;
|
||||
float AutomatableModel::s_copiedValue = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
AutomatableModel::AutomatableModel( DataType _type,
|
||||
const float _val,
|
||||
const float _min,
|
||||
const float _max,
|
||||
const float _step,
|
||||
::Model * _parent,
|
||||
const QString & _display_name,
|
||||
bool _default_constructed ) :
|
||||
Model( _parent, _display_name, _default_constructed ),
|
||||
m_dataType( _type ),
|
||||
m_value( _val ),
|
||||
m_initValue( _val ),
|
||||
m_minValue( _min ),
|
||||
m_maxValue( _max ),
|
||||
m_step( _step ),
|
||||
m_range( _max - _min ),
|
||||
AutomatableModel::AutomatableModel( DataType type,
|
||||
const float val, const float min, const float max, const float step,
|
||||
Model* parent, const QString & displayName, bool defaultConstructed ) :
|
||||
Model( parent, displayName, defaultConstructed ),
|
||||
m_dataType( type ),
|
||||
m_value( val ),
|
||||
m_initValue( val ),
|
||||
m_minValue( min ),
|
||||
m_maxValue( max ),
|
||||
m_step( step ),
|
||||
m_range( max - min ),
|
||||
m_journalEntryReady( false ),
|
||||
m_setValueDepth( 0 ),
|
||||
m_hasLinkedModels( false ),
|
||||
m_controllerConnection( NULL )
|
||||
{
|
||||
setInitValue( _val );
|
||||
setInitValue( val );
|
||||
}
|
||||
|
||||
|
||||
@@ -88,55 +83,54 @@ bool AutomatableModel::isAutomated() const
|
||||
|
||||
|
||||
|
||||
void AutomatableModel::saveSettings( QDomDocument & _doc, QDomElement & _this,
|
||||
const QString & _name )
|
||||
void AutomatableModel::saveSettings( QDomDocument& doc, QDomElement& element, const QString& name )
|
||||
{
|
||||
if( isAutomated() )
|
||||
{
|
||||
QDomElement me = _doc.createElement( _name );
|
||||
QDomElement me = doc.createElement( name );
|
||||
me.setAttribute( "id", id() );
|
||||
me.setAttribute( "value", m_value );
|
||||
_this.appendChild( me );
|
||||
element.appendChild( me );
|
||||
}
|
||||
else
|
||||
{
|
||||
_this.setAttribute( _name, m_value );
|
||||
element.setAttribute( name, m_value );
|
||||
}
|
||||
|
||||
if( m_controllerConnection )
|
||||
{
|
||||
QDomElement controller_element;
|
||||
QDomNode node = _this.namedItem( "connection" );
|
||||
QDomElement controllerElement;
|
||||
QDomNode node = element.namedItem( "connection" );
|
||||
if( node.isElement() )
|
||||
{
|
||||
controller_element = node.toElement();
|
||||
controllerElement = node.toElement();
|
||||
}
|
||||
else
|
||||
{
|
||||
controller_element = _doc.createElement( "connection" );
|
||||
_this.appendChild( controller_element );
|
||||
controllerElement = doc.createElement( "connection" );
|
||||
element.appendChild( controllerElement );
|
||||
}
|
||||
QDomElement element = _doc.createElement( _name );
|
||||
m_controllerConnection->saveSettings( _doc, element );
|
||||
controller_element.appendChild( element );
|
||||
|
||||
QDomElement element = doc.createElement( name );
|
||||
m_controllerConnection->saveSettings( doc, element );
|
||||
|
||||
controllerElement.appendChild( element );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AutomatableModel::loadSettings( const QDomElement & _this,
|
||||
const QString & _name )
|
||||
void AutomatableModel::loadSettings( const QDomElement& element, const QString& name )
|
||||
{
|
||||
// compat code
|
||||
QDomNode node = _this.namedItem( AutomationPattern::classNodeName() );
|
||||
QDomNode node = element.namedItem( AutomationPattern::classNodeName() );
|
||||
if( node.isElement() )
|
||||
{
|
||||
node = node.namedItem( _name );
|
||||
node = node.namedItem( name );
|
||||
if( node.isElement() )
|
||||
{
|
||||
AutomationPattern * p = AutomationPattern::
|
||||
globalAutomationPattern( this );
|
||||
AutomationPattern * p = AutomationPattern::globalAutomationPattern( this );
|
||||
p->loadSettings( node.toElement() );
|
||||
setValue( p->valueAt( 0 ) );
|
||||
// in older projects we sometimes have odd automations
|
||||
@@ -149,7 +143,7 @@ void AutomatableModel::loadSettings( const QDomElement & _this,
|
||||
}
|
||||
}
|
||||
|
||||
node = _this.namedItem( _name );
|
||||
node = element.namedItem( name );
|
||||
if( node.isElement() )
|
||||
{
|
||||
changeID( node.toElement().attribute( "id" ).toInt() );
|
||||
@@ -157,10 +151,10 @@ void AutomatableModel::loadSettings( const QDomElement & _this,
|
||||
return;
|
||||
}
|
||||
|
||||
node = _this.namedItem( "connection" );
|
||||
node = element.namedItem( "connection" );
|
||||
if( node.isElement() )
|
||||
{
|
||||
node = node.namedItem( _name );
|
||||
node = node.namedItem( name );
|
||||
if( node.isElement() )
|
||||
{
|
||||
setControllerConnection( new ControllerConnection( (Controller*)NULL ) );
|
||||
@@ -169,9 +163,9 @@ void AutomatableModel::loadSettings( const QDomElement & _this,
|
||||
}
|
||||
}
|
||||
|
||||
if( _this.hasAttribute( _name ) )
|
||||
if( element.hasAttribute( name ) )
|
||||
{
|
||||
setInitValue( _this.attribute( _name ).toFloat() );
|
||||
setInitValue( element.attribute( name ).toFloat() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -182,29 +176,24 @@ void AutomatableModel::loadSettings( const QDomElement & _this,
|
||||
|
||||
|
||||
|
||||
void AutomatableModel::setValue( const float _value )
|
||||
void AutomatableModel::setValue( const float value )
|
||||
{
|
||||
++m_setValueDepth;
|
||||
const float old_val = m_value;
|
||||
|
||||
m_value = fittedValue( _value );
|
||||
m_value = fittedValue( value );
|
||||
if( old_val != m_value )
|
||||
{
|
||||
// add changes to history so user can undo it
|
||||
addJournalEntry( JournalEntry( 0, m_value - old_val ) );
|
||||
|
||||
// notify linked models
|
||||
for( AutoModelVector::Iterator it =
|
||||
m_linkedModels.begin();
|
||||
it != m_linkedModels.end(); ++it )
|
||||
for( AutoModelVector::Iterator it = m_linkedModels.begin(); it != m_linkedModels.end(); ++it )
|
||||
{
|
||||
if( (*it)->m_setValueDepth < 1 &&
|
||||
(*it)->fittedValue( _value ) !=
|
||||
(*it)->m_value )
|
||||
if( (*it)->m_setValueDepth < 1 && (*it)->fittedValue( value ) != (*it)->m_value )
|
||||
{
|
||||
bool journalling = (*it)->testAndSetJournalling(
|
||||
isJournalling() );
|
||||
(*it)->setValue( _value );
|
||||
bool journalling = (*it)->testAndSetJournalling( isJournalling() );
|
||||
(*it)->setValue( value );
|
||||
(*it)->setJournalling( journalling );
|
||||
}
|
||||
}
|
||||
@@ -220,13 +209,13 @@ void AutomatableModel::setValue( const float _value )
|
||||
|
||||
|
||||
|
||||
void AutomatableModel::setAutomatedValue( const float _value )
|
||||
void AutomatableModel::setAutomatedValue( const float value )
|
||||
{
|
||||
++m_setValueDepth;
|
||||
const float old_val = m_value;
|
||||
const float oldValue = m_value;
|
||||
|
||||
m_value = fittedValue( _value );
|
||||
if( old_val != m_value )
|
||||
m_value = fittedValue( value );
|
||||
if( oldValue != m_value )
|
||||
{
|
||||
// notify linked models
|
||||
for( AutoModelVector::Iterator it = m_linkedModels.begin();
|
||||
@@ -247,19 +236,20 @@ void AutomatableModel::setAutomatedValue( const float _value )
|
||||
|
||||
|
||||
|
||||
void AutomatableModel::setRange( const float _min, const float _max,
|
||||
const float _step )
|
||||
void AutomatableModel::setRange( const float min, const float max,
|
||||
const float step )
|
||||
{
|
||||
if( ( m_maxValue != _max ) || ( m_minValue != _min ) )
|
||||
if( ( m_maxValue != max ) || ( m_minValue != min ) )
|
||||
{
|
||||
m_minValue = _min;
|
||||
m_maxValue = _max;
|
||||
m_minValue = min;
|
||||
m_maxValue = max;
|
||||
if( m_minValue > m_maxValue )
|
||||
{
|
||||
qSwap<float>( m_minValue, m_maxValue );
|
||||
}
|
||||
m_range = m_maxValue - m_minValue;
|
||||
setStep( _step );
|
||||
|
||||
setStep( step );
|
||||
|
||||
// re-adjust value
|
||||
setInitValue( value<float>() );
|
||||
@@ -271,11 +261,11 @@ void AutomatableModel::setRange( const float _min, const float _max,
|
||||
|
||||
|
||||
|
||||
void AutomatableModel::setStep( const float _step )
|
||||
void AutomatableModel::setStep( const float step )
|
||||
{
|
||||
if( m_step != _step )
|
||||
if( m_step != step )
|
||||
{
|
||||
m_step = _step;
|
||||
m_step = step;
|
||||
emit propertiesChanged();
|
||||
}
|
||||
}
|
||||
@@ -283,63 +273,61 @@ void AutomatableModel::setStep( const float _step )
|
||||
|
||||
|
||||
|
||||
float AutomatableModel::fittedValue( float _value ) const
|
||||
float AutomatableModel::fittedValue( float value ) const
|
||||
{
|
||||
_value = tLimit<float>( _value, m_minValue, m_maxValue );
|
||||
value = tLimit<float>( value, m_minValue, m_maxValue );
|
||||
|
||||
if( m_step != 0 )
|
||||
{
|
||||
_value = roundf( _value / m_step ) * m_step;
|
||||
value = roundf( value / m_step ) * m_step;
|
||||
}
|
||||
else
|
||||
{
|
||||
_value = m_minValue;
|
||||
value = m_minValue;
|
||||
}
|
||||
|
||||
// correct rounding error at the border
|
||||
if( qAbs<float>( _value - m_maxValue ) <
|
||||
typeInfo<float>::minEps() * qAbs<float>( m_step ) )
|
||||
if( qAbs<float>( value - m_maxValue ) < typeInfo<float>::minEps() * qAbs<float>( m_step ) )
|
||||
{
|
||||
_value = m_maxValue;
|
||||
value = m_maxValue;
|
||||
}
|
||||
|
||||
// correct rounding error if value = 0
|
||||
if( qAbs<float>( _value ) < typeInfo<float>::minEps() *
|
||||
qAbs<float>( m_step ) )
|
||||
if( qAbs<float>( value ) < typeInfo<float>::minEps() * qAbs<float>( m_step ) )
|
||||
{
|
||||
_value = 0;
|
||||
value = 0;
|
||||
}
|
||||
|
||||
if( _value < m_minValue )
|
||||
if( value < m_minValue )
|
||||
{
|
||||
return m_minValue;
|
||||
}
|
||||
else if( _value > m_maxValue )
|
||||
else if( value > m_maxValue )
|
||||
{
|
||||
return m_maxValue;
|
||||
}
|
||||
|
||||
return _value;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void AutomatableModel::redoStep( JournalEntry & _je )
|
||||
void AutomatableModel::redoStep( JournalEntry& je )
|
||||
{
|
||||
bool journalling = testAndSetJournalling( false );
|
||||
setValue( value<float>() + (float) _je.data().toDouble() );
|
||||
setValue( value<float>() + (float) je.data().toDouble() );
|
||||
setJournalling( journalling );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AutomatableModel::undoStep( JournalEntry & _je )
|
||||
void AutomatableModel::undoStep( JournalEntry& je )
|
||||
{
|
||||
JournalEntry je( _je.actionID(), -_je.data().toDouble() );
|
||||
redoStep( je );
|
||||
JournalEntry inv( je.actionID(), -je.data().toDouble() );
|
||||
redoStep( inv );
|
||||
}
|
||||
|
||||
|
||||
@@ -362,8 +350,7 @@ void AutomatableModel::addJournalEntryFromOldToCurVal()
|
||||
restoreJournallingState();
|
||||
if( value<float>() != m_oldValue )
|
||||
{
|
||||
addJournalEntry( JournalEntry( 0, value<float>() -
|
||||
m_oldValue ) );
|
||||
addJournalEntry( JournalEntry( 0, value<float>() - m_oldValue ) );
|
||||
}
|
||||
m_journalEntryReady = false;
|
||||
}
|
||||
@@ -372,16 +359,16 @@ void AutomatableModel::addJournalEntryFromOldToCurVal()
|
||||
|
||||
|
||||
|
||||
void AutomatableModel::linkModel( AutomatableModel * _model )
|
||||
void AutomatableModel::linkModel( AutomatableModel* model )
|
||||
{
|
||||
if( !m_linkedModels.contains( _model ) )
|
||||
if( !m_linkedModels.contains( model ) )
|
||||
{
|
||||
m_linkedModels.push_back( _model );
|
||||
m_linkedModels.push_back( model );
|
||||
m_hasLinkedModels = true;
|
||||
if( !_model->m_hasLinkedModels )
|
||||
|
||||
if( !model->hasLinkedModels() )
|
||||
{
|
||||
QObject::connect( this, SIGNAL( dataChanged() ),
|
||||
_model, SIGNAL( dataChanged() ) );
|
||||
QObject::connect( this, SIGNAL( dataChanged() ), model, SIGNAL( dataChanged() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -389,10 +376,9 @@ void AutomatableModel::linkModel( AutomatableModel * _model )
|
||||
|
||||
|
||||
|
||||
void AutomatableModel::unlinkModel( AutomatableModel * _model )
|
||||
void AutomatableModel::unlinkModel( AutomatableModel* model )
|
||||
{
|
||||
AutoModelVector::Iterator it =
|
||||
qFind( m_linkedModels.begin(), m_linkedModels.end(), _model );
|
||||
AutoModelVector::Iterator it = qFind( m_linkedModels.begin(), m_linkedModels.end(), model );
|
||||
if( it != m_linkedModels.end() )
|
||||
{
|
||||
m_linkedModels.erase( it );
|
||||
@@ -405,21 +391,19 @@ void AutomatableModel::unlinkModel( AutomatableModel * _model )
|
||||
|
||||
|
||||
|
||||
void AutomatableModel::linkModels( AutomatableModel * _model1,
|
||||
AutomatableModel * _model2 )
|
||||
void AutomatableModel::linkModels( AutomatableModel* model1, AutomatableModel* model2 )
|
||||
{
|
||||
_model1->linkModel( _model2 );
|
||||
_model2->linkModel( _model1 );
|
||||
model1->linkModel( model2 );
|
||||
model2->linkModel( model1 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AutomatableModel::unlinkModels( AutomatableModel * _model1,
|
||||
AutomatableModel * _model2 )
|
||||
void AutomatableModel::unlinkModels( AutomatableModel* model1, AutomatableModel* model2 )
|
||||
{
|
||||
_model1->unlinkModel( _model2 );
|
||||
_model2->unlinkModel( _model1 );
|
||||
model1->unlinkModel( model2 );
|
||||
model2->unlinkModel( model1 );
|
||||
}
|
||||
|
||||
|
||||
@@ -438,41 +422,37 @@ void AutomatableModel::unlinkAllModels()
|
||||
|
||||
|
||||
|
||||
void AutomatableModel::setControllerConnection( ControllerConnection * _c )
|
||||
void AutomatableModel::setControllerConnection( ControllerConnection* c )
|
||||
{
|
||||
m_controllerConnection = _c;
|
||||
if( _c )
|
||||
m_controllerConnection = c;
|
||||
if( c )
|
||||
{
|
||||
QObject::connect( m_controllerConnection,
|
||||
SIGNAL( valueChanged() ),
|
||||
this, SIGNAL( dataChanged() ) );
|
||||
QObject::connect( m_controllerConnection,
|
||||
SIGNAL( destroyed() ),
|
||||
this, SLOT( unlinkControllerConnection() ) );
|
||||
QObject::connect( m_controllerConnection, SIGNAL( valueChanged() ), this, SIGNAL( dataChanged() ) );
|
||||
QObject::connect( m_controllerConnection, SIGNAL( destroyed() ), this, SLOT( unlinkControllerConnection() ) );
|
||||
emit dataChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
float AutomatableModel::controllerValue( int _frameOffset ) const
|
||||
float AutomatableModel::controllerValue( int frameOffset ) const
|
||||
{
|
||||
if( m_controllerConnection )
|
||||
{
|
||||
const float v = m_minValue +
|
||||
( m_range * m_controllerConnection->currentValue(
|
||||
_frameOffset ) );
|
||||
const float v = minValue<float>() + ( range() * controllerConnection()->currentValue( frameOffset ) );
|
||||
if( typeInfo<float>::isEqual( m_step, 1 ) )
|
||||
{
|
||||
return qRound( v );
|
||||
}
|
||||
return v;
|
||||
}
|
||||
AutomatableModel * lm = m_linkedModels.first();
|
||||
if( lm->m_controllerConnection )
|
||||
|
||||
AutomatableModel* lm = m_linkedModels.first();
|
||||
if( lm->controllerConnection() )
|
||||
{
|
||||
return lm->controllerValue( _frameOffset );
|
||||
return lm->controllerValue( frameOffset );
|
||||
}
|
||||
|
||||
return lm->m_value;
|
||||
}
|
||||
|
||||
@@ -492,13 +472,13 @@ void AutomatableModel::unlinkControllerConnection()
|
||||
|
||||
|
||||
|
||||
void AutomatableModel::setInitValue( const float _value )
|
||||
void AutomatableModel::setInitValue( const float value )
|
||||
{
|
||||
m_initValue = fittedValue( _value );
|
||||
m_initValue = fittedValue( value );
|
||||
bool journalling = testAndSetJournalling( false );
|
||||
setValue( _value );
|
||||
setValue( value );
|
||||
setJournalling( journalling );
|
||||
emit initValueChanged( _value );
|
||||
emit initValueChanged( value );
|
||||
}
|
||||
|
||||
|
||||
@@ -514,7 +494,7 @@ void AutomatableModel::reset()
|
||||
|
||||
void AutomatableModel::copyValue()
|
||||
{
|
||||
__copiedValue = value<float>();
|
||||
s_copiedValue = value<float>();
|
||||
}
|
||||
|
||||
|
||||
@@ -522,7 +502,7 @@ void AutomatableModel::copyValue()
|
||||
|
||||
void AutomatableModel::pasteValue()
|
||||
{
|
||||
setValue( __copiedValue );
|
||||
setValue( copiedValue() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ bool Controller::hasModel( const Model * m )
|
||||
return true;
|
||||
}
|
||||
|
||||
ControllerConnection * cc = am->getControllerConnection();
|
||||
ControllerConnection * cc = am->controllerConnection();
|
||||
if( cc != NULL )
|
||||
{
|
||||
if( cc->getController()->hasModel( m ) )
|
||||
|
||||
@@ -102,9 +102,9 @@ void AutomatableModelView::addDefaultActions( QMenu* menu )
|
||||
}
|
||||
|
||||
QString controllerTxt;
|
||||
if( model->getControllerConnection() )
|
||||
if( model->controllerConnection() )
|
||||
{
|
||||
Controller* cont = model->getControllerConnection()->getController();
|
||||
Controller* cont = model->controllerConnection()->getController();
|
||||
if( cont )
|
||||
{
|
||||
controllerTxt = AutomatableModel::tr( "Connected to %1" ).arg( cont->name() );
|
||||
@@ -185,9 +185,9 @@ void AutomatableModelViewSlots::execConnectionDialog()
|
||||
if( d.chosenController() )
|
||||
{
|
||||
// Update
|
||||
if( m->getControllerConnection() )
|
||||
if( m->controllerConnection() )
|
||||
{
|
||||
m->getControllerConnection()->setController( d.chosenController() );
|
||||
m->controllerConnection()->setController( d.chosenController() );
|
||||
}
|
||||
// New
|
||||
else
|
||||
@@ -212,9 +212,9 @@ void AutomatableModelViewSlots::removeConnection()
|
||||
{
|
||||
AutomatableModel* m = m_amv->modelUntyped();
|
||||
|
||||
if( m->getControllerConnection() )
|
||||
if( m->controllerConnection() )
|
||||
{
|
||||
delete m->getControllerConnection();
|
||||
delete m->controllerConnection();
|
||||
m->setControllerConnection( NULL );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@
|
||||
class AutoDetectMidiController : public MidiController
|
||||
{
|
||||
public:
|
||||
AutoDetectMidiController( Model * _parent ) :
|
||||
MidiController( _parent ),
|
||||
AutoDetectMidiController( Model* parent ) :
|
||||
MidiController( parent ),
|
||||
m_detectedMidiChannel( 0 ),
|
||||
m_detectedMidiController( 0 )
|
||||
{
|
||||
@@ -63,17 +63,14 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual void processInEvent( const midiEvent & _me,
|
||||
const midiTime & _time )
|
||||
virtual void processInEvent( const midiEvent& event, const midiTime& time )
|
||||
{
|
||||
if( _me.m_type == MidiControlChange &&
|
||||
( m_midiPort.inputChannel() == _me.m_channel + 1 ||
|
||||
m_midiPort.inputChannel() == 0 ) )
|
||||
if( event.m_type == MidiControlChange &&
|
||||
( m_midiPort.inputChannel() == event.m_channel + 1 || m_midiPort.inputChannel() == 0 ) )
|
||||
{
|
||||
m_detectedMidiChannel = _me.m_channel + 1;
|
||||
m_detectedMidiController = ( _me.m_data.m_bytes[0] & 0x7F ) + 1;
|
||||
m_detectedMidiPort =
|
||||
engine::mixer()->midiClient()->sourcePortName( _me );
|
||||
m_detectedMidiChannel = event.m_channel + 1;
|
||||
m_detectedMidiController = ( event.m_data.m_bytes[0] & 0x7F ) + 1;
|
||||
m_detectedMidiPort = engine::mixer()->midiClient()->sourcePortName( event );
|
||||
|
||||
emit valueChanged();
|
||||
}
|
||||
@@ -82,9 +79,9 @@ public:
|
||||
|
||||
// Would be a nice copy ctor, but too hard to add copy ctor because
|
||||
// model has none.
|
||||
MidiController * copyToMidiController( Model * _parent )
|
||||
MidiController* copyToMidiController( Model* parent )
|
||||
{
|
||||
MidiController * c = new MidiController( _parent );
|
||||
MidiController* c = new MidiController( parent );
|
||||
c->m_midiPort.setInputChannel( m_midiPort.inputChannel() );
|
||||
c->m_midiPort.setInputController( m_midiPort.inputController() );
|
||||
c->subscribeReadablePorts( m_midiPort.readablePorts() );
|
||||
@@ -98,12 +95,12 @@ public:
|
||||
{
|
||||
m_midiPort.setInputChannel( m_detectedMidiChannel );
|
||||
m_midiPort.setInputController( m_detectedMidiController );
|
||||
MidiPort::Map map = m_midiPort.readablePorts();
|
||||
for( MidiPort::Map::Iterator it = map.begin(); it != map.end(); ++it )
|
||||
|
||||
const MidiPort::Map& map = m_midiPort.readablePorts();
|
||||
for( MidiPort::Map::ConstIterator it = map.begin(); it != map.end(); ++it )
|
||||
{
|
||||
m_midiPort.subscribeReadablePort( it.key(),
|
||||
m_detectedMidiPort.isEmpty() ||
|
||||
( it.key() == m_detectedMidiPort ) );
|
||||
m_detectedMidiPort.isEmpty() || ( it.key() == m_detectedMidiPort ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,31 +240,25 @@ ControllerConnectionDialog::ControllerConnectionDialog( QWidget * _parent,
|
||||
ControllerConnection * cc = NULL;
|
||||
if( m_targetModel )
|
||||
{
|
||||
cc = m_targetModel->getControllerConnection();
|
||||
cc = m_targetModel->controllerConnection();
|
||||
|
||||
if( cc && cc->getController()->type() !=
|
||||
Controller::DummyController && engine::getSong() )
|
||||
if( cc && cc->getController()->type() != Controller::DummyController && engine::getSong() )
|
||||
{
|
||||
if ( cc->getController()->type() ==
|
||||
Controller::MidiController )
|
||||
if ( cc->getController()->type() == Controller::MidiController )
|
||||
{
|
||||
m_midiGroupBox->model()->setValue( true );
|
||||
// ensure controller is created
|
||||
midiToggled();
|
||||
|
||||
MidiController * cont =
|
||||
(MidiController*)( cc->getController() );
|
||||
m_midiChannelSpinBox->model()->setValue(
|
||||
cont->m_midiPort.inputChannel() );
|
||||
m_midiControllerSpinBox->model()->setValue(
|
||||
cont->m_midiPort.inputController() );
|
||||
MidiController * cont = (MidiController*)( cc->getController() );
|
||||
m_midiChannelSpinBox->model()->setValue( cont->m_midiPort.inputChannel() );
|
||||
m_midiControllerSpinBox->model()->setValue( cont->m_midiPort.inputController() );
|
||||
|
||||
m_midiController->subscribeReadablePorts( static_cast<MidiController*>( cc->getController() )->m_midiPort.readablePorts() );
|
||||
}
|
||||
else
|
||||
{
|
||||
int idx = engine::getSong()->controllers().indexOf(
|
||||
cc->getController() );
|
||||
int idx = engine::getSong()->controllers().indexOf( cc->getController() );
|
||||
|
||||
if( idx >= 0 )
|
||||
{
|
||||
@@ -293,8 +284,7 @@ ControllerConnectionDialog::~ControllerConnectionDialog()
|
||||
{
|
||||
delete m_readablePorts;
|
||||
|
||||
if( m_midiController )
|
||||
delete m_midiController;
|
||||
delete m_midiController;
|
||||
}
|
||||
|
||||
|
||||
@@ -308,8 +298,7 @@ void ControllerConnectionDialog::selectController()
|
||||
if( m_midiControllerSpinBox->model()->value() > 0 )
|
||||
{
|
||||
MidiController * mc;
|
||||
mc = m_midiController->copyToMidiController(
|
||||
engine::getSong() );
|
||||
mc = m_midiController->copyToMidiController( engine::getSong() );
|
||||
|
||||
/*
|
||||
if( m_targetModel->getTrack() &&
|
||||
@@ -367,24 +356,21 @@ void ControllerConnectionDialog::midiToggled()
|
||||
m_midiController = new AutoDetectMidiController( engine::getSong() );
|
||||
|
||||
MidiPort::Map map = m_midiController->m_midiPort.readablePorts();
|
||||
for( MidiPort::Map::Iterator it = map.begin();
|
||||
it != map.end(); ++it )
|
||||
for( MidiPort::Map::Iterator it = map.begin(); it != map.end(); ++it )
|
||||
{
|
||||
it.value() = true;
|
||||
}
|
||||
m_midiController->subscribeReadablePorts( map );
|
||||
|
||||
m_midiChannelSpinBox->setModel(
|
||||
&m_midiController->m_midiPort.m_inputChannelModel );
|
||||
m_midiControllerSpinBox->setModel(
|
||||
&m_midiController->m_midiPort.m_inputControllerModel );
|
||||
m_midiChannelSpinBox->setModel( &m_midiController->m_midiPort.m_inputChannelModel );
|
||||
m_midiControllerSpinBox->setModel( &m_midiController->m_midiPort.m_inputControllerModel );
|
||||
|
||||
if( m_readablePorts )
|
||||
{
|
||||
m_readablePorts->setModel( &m_midiController->m_midiPort );
|
||||
}
|
||||
|
||||
connect( m_midiController, SIGNAL( valueChanged() ),
|
||||
this, SLOT( midiValueChanged() ) );
|
||||
connect( m_midiController, SIGNAL( valueChanged() ), this, SLOT( midiValueChanged() ) );
|
||||
}
|
||||
}
|
||||
m_midiAutoDetect.setValue( enabled );
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* knob.cpp - powerful knob-widget
|
||||
*
|
||||
* Copyright (c) 2004-2011 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
* Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -635,9 +635,8 @@ void knob::enterValue()
|
||||
|
||||
void knob::friendlyUpdate()
|
||||
{
|
||||
if( model()->getControllerConnection() == NULL ||
|
||||
model()->getControllerConnection()->getController()->
|
||||
frequentUpdates() == false ||
|
||||
if( model()->controllerConnection() == NULL ||
|
||||
model()->controllerConnection()->getController()->frequentUpdates() == false ||
|
||||
Controller::runningFrames() % (256*4) == 0 )
|
||||
{
|
||||
update();
|
||||
|
||||
Reference in New Issue
Block a user