-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix knob linking / refactor linking #7883
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
base: master
Are you sure you want to change the base?
Changes from 27 commits
3212bd8
247e348
4ba7cbb
74500d8
dba2a5a
57c24b8
eff1d2a
ffaddb1
f4678e9
368d8bf
23c99df
6bb8982
c5f9a04
e008275
db3b11a
675993a
f1f0d04
8ab1bd1
37400d4
33fa252
a8a5b3e
40c231d
f7c1d79
761b385
e89ba7d
71fe1a7
3e396ab
2680d4c
3f2e78e
0558a6b
c53f982
6cfa40c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,8 +77,6 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject | |
| { | ||
| Q_OBJECT | ||
| public: | ||
| using AutoModelVector = std::vector<AutomatableModel*>; | ||
|
|
||
| enum class ScaleType | ||
| { | ||
| Linear, | ||
|
|
@@ -150,22 +148,26 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject | |
| template<class T> | ||
| inline T value( int frameOffset = 0 ) const | ||
| { | ||
| if (m_controllerConnection) | ||
| // TODO | ||
| // The `m_value` should only be updated whenever the Controller value changes, | ||
| // instead of the Model calling `controller->currentValue()` every time. | ||
| // This becomes even worse in the case of linked Models, where it has to | ||
| // loop through the list of all links. | ||
|
|
||
| if (m_useControllerValue) | ||
| { | ||
| if (!m_useControllerValue) | ||
| if (m_controllerConnection) | ||
| { | ||
| return castValue<T>(m_value); | ||
| return castValue<T>(controllerValue(frameOffset)); | ||
| } | ||
| else | ||
| for (auto next = m_nextLink; next != this; next = next->m_nextLink) | ||
| { | ||
| return castValue<T>(controllerValue(frameOffset)); | ||
| if (next->controllerConnection() && next->useControllerValue()) | ||
| { | ||
| return castValue<T>(fittedValue(next->controllerValue(frameOffset))); | ||
| } | ||
| } | ||
| } | ||
| else if (hasLinkedModels()) | ||
| { | ||
| return castValue<T>( controllerValue( frameOffset ) ); | ||
| } | ||
|
|
||
| return castValue<T>( m_value ); | ||
| } | ||
|
|
||
|
|
@@ -211,8 +213,7 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject | |
|
|
||
| void setInitValue( const float value ); | ||
|
|
||
| void setAutomatedValue( const float value ); | ||
| void setValue( const float value ); | ||
| void setValue(const float value, const bool isAutomated = false); | ||
|
|
||
| void incValue( int steps ) | ||
| { | ||
|
|
@@ -249,11 +250,10 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject | |
| m_centerValue = centerVal; | ||
| } | ||
|
|
||
| //! link @p m1 and @p m2, let @p m1 take the values of @p m2 | ||
| static void linkModels( AutomatableModel* m1, AutomatableModel* m2 ); | ||
| static void unlinkModels( AutomatableModel* m1, AutomatableModel* m2 ); | ||
|
|
||
| void unlinkAllModels(); | ||
| //! link this to @p model, copying the value from @p model | ||
| void linkToModel(AutomatableModel* model); | ||
| //! @return number of other models linked to this | ||
| size_t countLinks() const; | ||
|
|
||
| /** | ||
| * @brief Saves settings (value, automation links and controller connections) of AutomatableModel into | ||
|
|
@@ -276,9 +276,9 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject | |
|
|
||
| virtual QString displayValue( const float val ) const = 0; | ||
|
|
||
| bool hasLinkedModels() const | ||
| bool isLinked() const | ||
| { | ||
| return !m_linkedModels.empty(); | ||
| return m_nextLink != this; | ||
| } | ||
|
|
||
| // a way to track changed values in the model and avoid using signals/slots - useful for speed-critical code. | ||
|
|
@@ -311,13 +311,14 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject | |
| s_periodCounter = 0; | ||
| } | ||
|
|
||
| bool useControllerValue() | ||
| bool useControllerValue() const | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is always true as far as I can see... but that's just a side note
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, it's used in |
||
| { | ||
| return m_useControllerValue; | ||
| } | ||
|
|
||
| public slots: | ||
| virtual void reset(); | ||
| void unlink(); | ||
| void unlinkControllerConnection(); | ||
| void setUseControllerValue(bool b = true); | ||
|
|
||
|
|
@@ -367,9 +368,15 @@ public slots: | |
| loadSettings( element, "value" ); | ||
| } | ||
|
|
||
| void linkModel( AutomatableModel* model ); | ||
| void unlinkModel( AutomatableModel* model ); | ||
| void setValueInternal(const float value); | ||
|
|
||
| //! linking is stored in a linked list ring | ||
| //! @return the model whose `m_nextLink` is `this`, | ||
| //! or `this` if there are no linked models | ||
| AutomatableModel* getLastLinkedModel() const; | ||
| //! @return true if the `model` is in the linked list | ||
| bool isLinkedToModel(AutomatableModel* model) const; | ||
|
|
||
| //! @brief Scales @value from linear to logarithmic. | ||
| //! Value should be within [0,1] | ||
| template<class T> T logToLinearScale( T value ) const; | ||
|
|
@@ -389,16 +396,15 @@ public slots: | |
| float m_centerValue; | ||
|
|
||
| bool m_valueChanged; | ||
|
|
||
| // currently unused? | ||
| float m_oldValue; | ||
| int m_setValueDepth; | ||
| float m_oldValue; //!< used by valueBuffer for interpolation | ||
|
|
||
| // used to determine if step size should be applied strictly (ie. always) | ||
| // or only when value set from gui (default) | ||
| bool m_hasStrictStepSize; | ||
|
|
||
| AutoModelVector m_linkedModels; | ||
| //! 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 | ||
| AutomatableModel* m_nextLink; | ||
szeli1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| //! NULL if not appended to controller, otherwise connection info | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1072,8 +1072,8 @@ void ManageVestigeInstrumentView::syncPlugin( void ) | |
| std::snprintf(paramStr.data(), paramStr.size(), "param%d", i); | ||
| s_dumpValues = dump[paramStr.data()].split(":"); | ||
| float f_value = LocaleHelper::toFloat(s_dumpValues.at(2)); | ||
| m_vi->knobFModel[ i ]->setAutomatedValue( f_value ); | ||
| m_vi->knobFModel[ i ]->setInitValue( f_value ); | ||
| m_vi->knobFModel[i]->setValue(f_value, true); | ||
| m_vi->knobFModel[i]->setInitValue(f_value); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the actual difference between
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It didn't journal |
||
| } | ||
| } | ||
| syncParameterText(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.