LMMS
Loading...
Searching...
No Matches
lmms::AutomatableModel Class Referenceabstract

#include <AutomatableModel.h>

Inheritance diagram for lmms::AutomatableModel:
lmms::Model lmms::JournallingObject lmms::SerializingObject lmms::TypedAutomatableModel< bool > lmms::TypedAutomatableModel< float > lmms::TypedAutomatableModel< int > lmms::TypedAutomatableModel< T > lmms::BoolModel lmms::FloatModel lmms::IntModel lmms::CarlaParamFloatModel lmms::InlineAutomation lmms::SfxrNegPosOneFloatModel lmms::SfxrZeroToOneFloatModel lmms::TempoSyncKnobModel lmms::ComboBoxModel lmms::DetuningHelper

Classes

struct  DCastVisitor
struct  ConstDCastVisitor

Public Types

enum class  ScaleType { Linear , Logarithmic , Decibel }

Public Slots

virtual void reset ()
void unlink ()
void unlinkControllerConnection ()
void setUseControllerValue (bool b=true)

Signals

void initValueChanged (float val)
void destroyed (lmms::jo_id_t id)
Signals inherited from lmms::Model
void dataChanged ()
void dataUnchanged ()
void propertiesChanged ()

Public Member Functions

 ~AutomatableModel () override
virtual void accept (ModelVisitor &v)=0
virtual void accept (ConstModelVisitor &v) const =0
template<class Target>
Target * dynamicCast (bool doThrow=false)
 Return this class casted to Target.
template<class Target>
const Target * dynamicCast (bool doThrow=false) const
 const overload, see overloaded function
bool isAutomated () const
bool isAutomatedOrControlled () const
ControllerConnectioncontrollerConnection () const
void setControllerConnection (ControllerConnection *c)
template<class T>
value (int frameOffset=0) const
float controllerValue (int frameOffset) const
ValueBuffervalueBuffer ()
 Function that returns sample-exact data as a ValueBuffer.
template<class T>
initValue () const
bool isAtInitValue () const
template<class T>
minValue () const
template<class T>
maxValue () const
template<class T>
step () const
float scaledValue (float value) const
 Returns value scaled with the scale type and min/max values of this model.
float inverseScaledValue (float value) const
 Returns value applied with the inverse of this model's scale type.
void setInitValue (const float value)
void setValue (const float value, const bool isAutomated=false)
void incValue (int steps)
float range () const
void setRange (const float min, const float max, const float step=1)
void setScaleType (ScaleType sc)
void setScaleLogarithmic (bool setToTrue=true)
bool isScaleLogarithmic () const
void setStep (const float step)
float centerValue () const
void setCenterValue (const float centerVal)
void linkToModel (AutomatableModel *model)
 link this to model, copying the value from model
size_t countLinks () const
virtual void saveSettings (QDomDocument &doc, QDomElement &element, const QString &name)
 Saves settings (value, automation links and controller connections) of AutomatableModel into specified DOM element using <name> as attribute/node name.
virtual void loadSettings (const QDomElement &element, const QString &name)
 Loads settings (value, automation links and controller connections) of AutomatableModel from specified DOM element using <name> as attribute/node name.
QString nodeName () const override
virtual QString displayValue (const float val) const =0
bool isLinked () const
bool isValueChanged ()
float globalAutomationValueAt (const TimePos &time)
void setStrictStepSize (const bool b)
bool useControllerValue () const
Public Member Functions inherited from lmms::Model
 Model (Model *parent, QString displayName=QString(), bool defaultConstructed=false)
 ~Model () override=default
bool isDefaultConstructed () const
ModelparentModel () const
virtual QString displayName () const
virtual void setDisplayName (const QString &displayName)
virtual QString fullDisplayName () const
Public Member Functions inherited from lmms::JournallingObject
 JournallingObject ()
 ~JournallingObject () override
jo_id_t id () const
void saveJournallingState (const bool newState)
void restoreJournallingState ()
void addJournalCheckPoint ()
QDomElement saveState (QDomDocument &_doc, QDomElement &_parent) override
void restoreState (const QDomElement &_this) override
bool isJournalling () const
void setJournalling (const bool _sr)
bool testAndSetJournalling (const bool newState)
bool isJournallingStateStackEmpty () const
Public Member Functions inherited from lmms::SerializingObject
 SerializingObject ()
virtual ~SerializingObject ()
void setHook (SerializingObjectHook *_hook)
SerializingObjectHookhook ()

Static Public Member Functions

template<class T>
static T castValue (const float v)
template<bool>
static bool castValue (const float v)
static void incrementPeriodCounter ()
static void resetPeriodCounter ()

Protected Member Functions

 AutomatableModel (const float val=0, const float min=0, const float max=0, const float step=0, Model *parent=nullptr, const QString &displayName=QString(), bool defaultConstructed=false)
float fittedValue (float value) const
Protected Member Functions inherited from lmms::JournallingObject
void changeID (jo_id_t _id)

Private Member Functions

void saveSettings (QDomDocument &doc, QDomElement &element) override
void loadSettings (const QDomElement &element) override
void setValueInternal (const float value)
AutomatableModelgetLastLinkedModel () const
bool isLinkedToModel (AutomatableModel *model) const
template<class T>
logToLinearScale (T value) const
 Scales @value from linear to logarithmic. Value should be within [0,1].
template<class T>
void roundAt (T &value, const T &where) const

Static Private Member Functions

static bool mustQuoteName (const QString &name)

Private Attributes

ScaleType m_scaleType
 scale type, linear by default
float m_value
float m_initValue
float m_minValue
float m_maxValue
float m_step
float m_range
float m_centerValue
bool m_valueChanged
float m_oldValue
 used by valueBuffer for interpolation
bool m_hasStrictStepSize
AutomatableModelm_nextLink
ControllerConnectionm_controllerConnection
 NULL if not appended to controller, otherwise connection info.
ValueBuffer m_valueBuffer
long m_lastUpdatedPeriod
bool m_hasSampleExactData
QMutex m_valueBufferMutex
bool m_useControllerValue

Static Private Attributes

static long s_periodCounter = 0

Member Enumeration Documentation

◆ ScaleType

Enumerator
Linear 
Logarithmic 
Decibel 

Constructor & Destructor Documentation

◆ ~AutomatableModel()

lmms::AutomatableModel::~AutomatableModel ( )
override

◆ AutomatableModel()

lmms::AutomatableModel::AutomatableModel ( const float val = 0,
const float min = 0,
const float max = 0,
const float step = 0,
Model * parent = nullptr,
const QString & displayName = QString(),
bool defaultConstructed = false )
protected

Member Function Documentation

◆ accept() [1/2]

virtual void lmms::AutomatableModel::accept ( ConstModelVisitor & v) const
pure virtual

◆ accept() [2/2]

virtual void lmms::AutomatableModel::accept ( ModelVisitor & v)
pure virtual

◆ castValue() [1/2]

template<bool>
bool lmms::AutomatableModel::castValue ( const float v)
inlinestatic

◆ castValue() [2/2]

template<class T>
T lmms::AutomatableModel::castValue ( const float v)
inlinestatic

◆ centerValue()

float lmms::AutomatableModel::centerValue ( ) const
inline

◆ controllerConnection()

ControllerConnection * lmms::AutomatableModel::controllerConnection ( ) const
inline

◆ controllerValue()

float lmms::AutomatableModel::controllerValue ( int frameOffset) const

◆ countLinks()

size_t lmms::AutomatableModel::countLinks ( ) const
Returns
number of other models linked to this

◆ destroyed

void lmms::AutomatableModel::destroyed ( lmms::jo_id_t id)
signal

◆ displayValue()

virtual QString lmms::AutomatableModel::displayValue ( const float val) const
pure virtual

◆ dynamicCast() [1/2]

template<class Target>
Target * lmms::AutomatableModel::dynamicCast ( bool doThrow = false)
inline

Return this class casted to Target.

Test
AutomatableModelTest.cpp
Parameters
doThrowthrow an assertion if the cast fails, instead of returning a nullptr
Returns
the casted class if Target is the exact or a base class of this, nullptr otherwise

◆ dynamicCast() [2/2]

template<class Target>
const Target * lmms::AutomatableModel::dynamicCast ( bool doThrow = false) const
inline

const overload, see overloaded function

◆ fittedValue()

float lmms::AutomatableModel::fittedValue ( float value) const
protected

returns a value which is in range between min() and max() and aligned according to the step size (step size 0.05 -> value 0.12345 becomes 0.10 etc.). You should always call it at the end after doing your own calculations.

◆ getLastLinkedModel()

AutomatableModel * lmms::AutomatableModel::getLastLinkedModel ( ) const
private

linking is stored in a linked list ring

Returns
the model whose m_nextLink is this, or this if there are no linked models

◆ globalAutomationValueAt()

float lmms::AutomatableModel::globalAutomationValueAt ( const TimePos & time)

◆ incrementPeriodCounter()

void lmms::AutomatableModel::incrementPeriodCounter ( )
inlinestatic

◆ incValue()

void lmms::AutomatableModel::incValue ( int steps)
inline

◆ initValue()

template<class T>
T lmms::AutomatableModel::initValue ( ) const
inline

◆ initValueChanged

void lmms::AutomatableModel::initValueChanged ( float val)
signal

◆ inverseScaledValue()

float lmms::AutomatableModel::inverseScaledValue ( float value) const

Returns value applied with the inverse of this model's scale type.

◆ isAtInitValue()

bool lmms::AutomatableModel::isAtInitValue ( ) const
inline

◆ isAutomated()

bool lmms::AutomatableModel::isAutomated ( ) const

◆ isAutomatedOrControlled()

bool lmms::AutomatableModel::isAutomatedOrControlled ( ) const
inline

◆ isLinked()

bool lmms::AutomatableModel::isLinked ( ) const
inline

◆ isLinkedToModel()

bool lmms::AutomatableModel::isLinkedToModel ( AutomatableModel * model) const
private
Returns
true if the model is in the linked list

◆ isScaleLogarithmic()

bool lmms::AutomatableModel::isScaleLogarithmic ( ) const
inline

◆ isValueChanged()

bool lmms::AutomatableModel::isValueChanged ( )
inline

◆ linkToModel()

void lmms::AutomatableModel::linkToModel ( AutomatableModel * model)

link this to model, copying the value from model

◆ loadSettings() [1/2]

void lmms::AutomatableModel::loadSettings ( const QDomElement & element)
inlineoverrideprivatevirtual

Implements lmms::SerializingObject.

Reimplemented in lmms::InlineAutomation.

◆ loadSettings() [2/2]

void lmms::AutomatableModel::loadSettings ( const QDomElement & element,
const QString & name )
virtual

Loads settings (value, automation links and controller connections) of AutomatableModel from specified DOM element using <name> as attribute/node name.

Reimplemented in lmms::CarlaParamFloatModel, lmms::SfxrNegPosOneFloatModel, lmms::SfxrZeroToOneFloatModel, and lmms::TempoSyncKnobModel.

◆ logToLinearScale()

template<class T>
T lmms::AutomatableModel::logToLinearScale ( T value) const
private

Scales @value from linear to logarithmic. Value should be within [0,1].

◆ maxValue()

template<class T>
T lmms::AutomatableModel::maxValue ( ) const
inline

◆ minValue()

template<class T>
T lmms::AutomatableModel::minValue ( ) const
inline

◆ mustQuoteName()

bool lmms::AutomatableModel::mustQuoteName ( const QString & name)
staticprivate

◆ nodeName()

QString lmms::AutomatableModel::nodeName ( void ) const
inlineoverridevirtual

Implements lmms::SerializingObject.

Reimplemented in lmms::DetuningHelper.

◆ range()

float lmms::AutomatableModel::range ( ) const
inline

◆ reset

void lmms::AutomatableModel::reset ( )
virtualslot

◆ resetPeriodCounter()

void lmms::AutomatableModel::resetPeriodCounter ( )
inlinestatic

◆ roundAt()

template<class T>
void lmms::AutomatableModel::roundAt ( T & value,
const T & where ) const
private

rounds value to where if it is close to it

Parameters
valuewill be modified to rounded value

◆ saveSettings() [1/2]

void lmms::AutomatableModel::saveSettings ( QDomDocument & doc,
QDomElement & element )
inlineoverrideprivatevirtual

Implements lmms::SerializingObject.

Reimplemented in lmms::InlineAutomation.

◆ saveSettings() [2/2]

void lmms::AutomatableModel::saveSettings ( QDomDocument & doc,
QDomElement & element,
const QString & name )
virtual

Saves settings (value, automation links and controller connections) of AutomatableModel into specified DOM element using <name> as attribute/node name.

Parameters
docTODO
elementWhere this option shall be saved. Depending on the model, this can be done in an attribute or in a subnode.
nameName to store this model as.

Reimplemented in lmms::CarlaParamFloatModel, and lmms::TempoSyncKnobModel.

◆ scaledValue()

float lmms::AutomatableModel::scaledValue ( float value) const

Returns value scaled with the scale type and min/max values of this model.

◆ setCenterValue()

void lmms::AutomatableModel::setCenterValue ( const float centerVal)
inline

◆ setControllerConnection()

void lmms::AutomatableModel::setControllerConnection ( ControllerConnection * c)

◆ setInitValue()

void lmms::AutomatableModel::setInitValue ( const float value)

◆ setRange()

void lmms::AutomatableModel::setRange ( const float min,
const float max,
const float step = 1 )

◆ setScaleLogarithmic()

void lmms::AutomatableModel::setScaleLogarithmic ( bool setToTrue = true)
inline

◆ setScaleType()

void lmms::AutomatableModel::setScaleType ( ScaleType sc)
inline

◆ setStep()

void lmms::AutomatableModel::setStep ( const float step)

◆ setStrictStepSize()

void lmms::AutomatableModel::setStrictStepSize ( const bool b)
inline

◆ setUseControllerValue

void lmms::AutomatableModel::setUseControllerValue ( bool b = true)
slot

◆ setValue()

void lmms::AutomatableModel::setValue ( const float value,
const bool isAutomated = false )

◆ setValueInternal()

void lmms::AutomatableModel::setValueInternal ( const float value)
private

◆ step()

template<class T>
T lmms::AutomatableModel::step ( ) const
inline

◆ unlink

void lmms::AutomatableModel::unlink ( )
slot

◆ unlinkControllerConnection

void lmms::AutomatableModel::unlinkControllerConnection ( )
slot

◆ useControllerValue()

bool lmms::AutomatableModel::useControllerValue ( ) const
inline

◆ value()

template<class T>
T lmms::AutomatableModel::value ( int frameOffset = 0) const
inline

◆ valueBuffer()

ValueBuffer * lmms::AutomatableModel::valueBuffer ( )

Function that returns sample-exact data as a ValueBuffer.

Returns
pointer to model's valueBuffer when s.ex.data exists, NULL otherwise

Member Data Documentation

◆ m_centerValue

float lmms::AutomatableModel::m_centerValue
private

◆ m_controllerConnection

ControllerConnection* lmms::AutomatableModel::m_controllerConnection
private

NULL if not appended to controller, otherwise connection info.

◆ m_hasSampleExactData

bool lmms::AutomatableModel::m_hasSampleExactData
private

◆ m_hasStrictStepSize

bool lmms::AutomatableModel::m_hasStrictStepSize
private

◆ m_initValue

float lmms::AutomatableModel::m_initValue
private

◆ m_lastUpdatedPeriod

long lmms::AutomatableModel::m_lastUpdatedPeriod
private

◆ m_maxValue

float lmms::AutomatableModel::m_maxValue
private

◆ m_minValue

float lmms::AutomatableModel::m_minValue
private

◆ m_nextLink

AutomatableModel* lmms::AutomatableModel::m_nextLink
private

an AutomatableModel can be linked together with others in a linked list the list has no end, the last model is connected to the first forming a ring

◆ m_oldValue

float lmms::AutomatableModel::m_oldValue
private

used by valueBuffer for interpolation

◆ m_range

float lmms::AutomatableModel::m_range
private

◆ m_scaleType

ScaleType lmms::AutomatableModel::m_scaleType
private

scale type, linear by default

◆ m_step

float lmms::AutomatableModel::m_step
private

◆ m_useControllerValue

bool lmms::AutomatableModel::m_useControllerValue
private

◆ m_value

float lmms::AutomatableModel::m_value
private

◆ m_valueBuffer

ValueBuffer lmms::AutomatableModel::m_valueBuffer
private

◆ m_valueBufferMutex

QMutex lmms::AutomatableModel::m_valueBufferMutex
private

◆ m_valueChanged

bool lmms::AutomatableModel::m_valueChanged
private

◆ s_periodCounter

long lmms::AutomatableModel::s_periodCounter = 0
staticprivate

The documentation for this class was generated from the following files: