Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3212bd8
ModelView_adding_error_message_for_model_nullptr
szeli1 Apr 9, 2025
247e348
ModelView_adding_assert_to_model_also
szeli1 Apr 10, 2025
4ba7cbb
AutomatableModel_refactoring_linking_part_1
szeli1 May 9, 2025
74500d8
LapsdaControl_updating_functions
szeli1 May 9, 2025
dba2a5a
Song_updating_automation_functions
szeli1 May 9, 2025
57c24b8
AutomatableModel_refactoring_part_2
szeli1 May 9, 2025
eff1d2a
AutomatableModel_moving_funcion_to_private
szeli1 May 9, 2025
ffaddb1
ModelView_reveting_changes
szeli1 May 9, 2025
f4678e9
AutomatableModel_removing_unused_code
szeli1 May 9, 2025
368d8bf
Song_removing_unused_code
szeli1 May 9, 2025
23c99df
Vestige_replace_setAutomatedValue
szeli1 May 9, 2025
6bb8982
VstEffectControls_replace_setAutomatedValue
szeli1 May 9, 2025
c5f9a04
AutomatableModel_fixing_issues
szeli1 May 9, 2025
e008275
AutomatableModelTest_updating_test
szeli1 May 9, 2025
db3b11a
AutomatatbleModel adding comments and assert
szeli1 May 23, 2025
675993a
edit_unlink adding new svg
szeli1 May 24, 2025
f1f0d04
AutomatableModelView fixing unlink picture
szeli1 May 24, 2025
8ab1bd1
AutomatableModel removing unused function
szeli1 Jun 4, 2025
37400d4
edit_unlink replacing with better image
szeli1 Jun 9, 2025
33fa252
MULTIPLE FILES applying style suggestions
szeli1 Jun 9, 2025
a8a5b3e
AutomatableModel updating while loops
szeli1 Jun 27, 2025
40c231d
AutomatableModel fixing value buffers causing crash
szeli1 Jun 29, 2025
f7c1d79
Remove const_cast and simiplify linking functions
allejok96 Jul 7, 2025
761b385
Clarify for, add assert, revert setUseControllerValue, remove comments
allejok96 Jul 13, 2025
e89ba7d
Add comments about design flaws
allejok96 Jul 18, 2025
71fe1a7
Remove const_cast and simiplify linking functions
szeli1 Aug 5, 2025
3e396ab
Merge branch 'LMMS:master' into fix_model_returning_nullptr
szeli1 Oct 25, 2025
2680d4c
AutomatableModel style fixes
szeli1 Oct 25, 2025
3f2e78e
FloatModelEditorBase fixing format
szeli1 Dec 6, 2025
0558a6b
LinkedModelGroups fixing link order
szeli1 Dec 6, 2025
c53f982
LinkedModelGroups fixing bug
szeli1 Dec 6, 2025
6cfa40c
LinkedModelGroups fixing bug 2
szeli1 Dec 6, 2025
6789da4
AutomatableModel removing emit
szeli1 Dec 21, 2025
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
121 changes: 121 additions & 0 deletions data/themes/classic/edit_unlink.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
121 changes: 121 additions & 0 deletions data/themes/default/edit_unlink.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 24 additions & 31 deletions include/AutomatableModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject
{
Q_OBJECT
public:
using AutoModelVector = std::vector<AutomatableModel*>;

enum class ScaleType
{
Linear,
Expand Down Expand Up @@ -151,22 +149,12 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject
template<class T>
inline T value( int frameOffset = 0 ) const
{
if (m_controllerConnection)
{
if (!m_useControllerValue)
{
return castValue<T>(m_value);
}
else
{
return castValue<T>(controllerValue(frameOffset));
}
}
else if (hasLinkedModels())
if (m_controllerConnection && m_useControllerValue)
{
return castValue<T>( controllerValue( frameOffset ) );
// workaround to update linked models
AutomatableModel* thisModel = const_cast<AutomatableModel*>(this);
thisModel->setValue(controllerValue(frameOffset));
}

return castValue<T>( m_value );
}

Expand Down Expand Up @@ -212,8 +200,8 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject

void setInitValue( const float value );

void setAutomatedValue( const float value );
void setValue( const float value );
void setAutomatedValue(float value);
void setValue(float value, bool isAutomated = false);

void incValue( int steps )
{
Expand Down Expand Up @@ -252,9 +240,9 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject

//! 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();
//! @return 0 if not connected, never 1, 2 if connected to 1 model
size_t countLinks() const;

/**
* @brief Saves settings (value, automation links and controller connections) of AutomatableModel into
Expand All @@ -277,9 +265,9 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject

virtual QString displayValue( const float val ) const = 0;

bool hasLinkedModels() const
constexpr bool hasLinkedModels() const
{
return !m_linkedModels.empty();
return m_nextLink != nullptr;
}

// a way to track changed values in the model and avoid using signals/slots - useful for speed-critical code.
Expand Down Expand Up @@ -312,7 +300,7 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject
s_periodCounter = 0;
}

bool useControllerValue()
bool useControllerValue() const
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor

@allejok96 allejok96 Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it's used in Song::processAutomations, my bad

{
return m_useControllerValue;
}
Expand Down Expand Up @@ -340,6 +328,7 @@ public slots:


private:
void setValueInternal(float value, bool isAutomated);
// dynamicCast implementation
template<class Target>
struct DCastVisitor : public ModelVisitor
Expand Down Expand Up @@ -368,9 +357,14 @@ public slots:
loadSettings( element, "value" );
}

void linkModel( AutomatableModel* model );
void unlinkModel( AutomatableModel* model );

void linkModel(AutomatableModel* model);
void unlinkModel();
//! linking is stored in a linked list ring
//! @return the model that's `m_nextLink` is `this`
AutomatableModel* getLastLinkedModel() const;
//! @return true if the `model` is in the linked list
bool isModelLinked(AutomatableModel* model) const;

//! @brief Scales @value from linear to logarithmic.
//! Value should be within [0,1]
template<class T> T logToLinearScale( T value ) const;
Expand All @@ -390,16 +384,15 @@ public slots:
float m_centerValue;

bool m_valueChanged;

// currently unused?
float m_oldValue;
int m_setValueDepth;
float m_oldValue; //!< used 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;


//! NULL if not appended to controller, otherwise connection info
Expand Down
2 changes: 1 addition & 1 deletion plugins/Vestige/Vestige.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ 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 ]->setValue(f_value, true);
m_vi->knobFModel[ i ]->setInitValue( f_value );
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/VstEffect/VstEffectControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ void ManageVSTEffectView::syncPlugin()
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_vi2->knobFModel[ i ]->setAutomatedValue( f_value );
m_vi2->knobFModel[ i ]->setValue(f_value, true);
m_vi2->knobFModel[ i ]->setInitValue( f_value );
}
}
Expand Down
Loading
Loading