From 3e19bc8ddbc23b3e7a0411d5a21588444af46784 Mon Sep 17 00:00:00 2001 From: Vesa Date: Sun, 16 Nov 2014 14:14:35 +0200 Subject: [PATCH] Add a method to track value changes in AutomatableModel - this can be used by DSP code instead of signals/slots to improve performance --- include/AutomatableModel.h | 16 ++++++++++++++-- src/core/AutomatableModel.cpp | 4 ++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/AutomatableModel.h b/include/AutomatableModel.h index cc2764974..e8acac390 100644 --- a/include/AutomatableModel.h +++ b/include/AutomatableModel.h @@ -25,7 +25,7 @@ #ifndef AUTOMATABLE_MODEL_H #define AUTOMATABLE_MODEL_H -#include +#include "lmms_math.h" #include "JournallingObject.h" #include "Model.h" @@ -70,7 +70,8 @@ public: enum ScaleType { Linear, - Logarithmic + Logarithmic, + Decibel }; enum DataType @@ -239,6 +240,15 @@ public: return m_hasLinkedModels; } + bool isValueChanged() + { + if( m_valueChanged ) + { + m_valueChanged = false; + return true; + } + } + float globalAutomationValueAt( const MidiTime& time ); public slots: @@ -288,6 +298,8 @@ private: float m_step; float m_range; float m_centerValue; + + bool m_valueChanged; // most objects will need this temporarily (until sampleExact is // standard) diff --git a/src/core/AutomatableModel.cpp b/src/core/AutomatableModel.cpp index 12240d3b0..f2721a50a 100644 --- a/src/core/AutomatableModel.cpp +++ b/src/core/AutomatableModel.cpp @@ -47,6 +47,7 @@ AutomatableModel::AutomatableModel( DataType type, m_step( step ), m_range( max - min ), m_centerValue( m_minValue ), + m_valueChanged( false ), m_setValueDepth( 0 ), m_hasLinkedModels( false ), m_controllerConnection( NULL ) @@ -234,6 +235,7 @@ void AutomatableModel::setValue( const float value ) (*it)->setJournalling( journalling ); } } + m_valueChanged = true; emit dataChanged(); } else @@ -327,6 +329,7 @@ void AutomatableModel::setAutomatedValue( const float value ) (*it)->setAutomatedValue( value ); } } + m_valueChanged = true; emit dataChanged(); } --m_setValueDepth; @@ -471,6 +474,7 @@ void AutomatableModel::setControllerConnection( ControllerConnection* c ) { QObject::connect( m_controllerConnection, SIGNAL( valueChanged() ), this, SIGNAL( dataChanged() ) ); QObject::connect( m_controllerConnection, SIGNAL( destroyed() ), this, SLOT( unlinkControllerConnection() ) ); + m_valueChanged = true; emit dataChanged(); } }