From fc53e0cda79754df240ad2e4ed1be8b7ad3444f0 Mon Sep 17 00:00:00 2001 From: regulus79 <117475203+regulus79@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:58:42 -0500 Subject: [PATCH 1/3] Initial fix --- plugins/TripleOscillator/TripleOscillator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/TripleOscillator/TripleOscillator.cpp b/plugins/TripleOscillator/TripleOscillator.cpp index f04cee81835..99ec33a9c26 100644 --- a/plugins/TripleOscillator/TripleOscillator.cpp +++ b/plugins/TripleOscillator/TripleOscillator.cpp @@ -72,7 +72,7 @@ Plugin::Descriptor PLUGIN_EXPORT tripleoscillator_plugin_descriptor = OscillatorObject::OscillatorObject( Model * _parent, int _idx ) : Model( _parent ), m_volumeModel( DefaultVolume / NUM_OF_OSCILLATORS, MinVolume, - MaxVolume, 1.0f, this, tr( "Osc %1 volume" ).arg( _idx+1 ) ), + MaxVolume, 0.001f, this, tr( "Osc %1 volume" ).arg( _idx+1 ) ), m_panModel( DefaultPanning, PanningLeft, PanningRight, 1.0f, this, tr( "Osc %1 panning" ).arg( _idx+1 ) ), m_coarseModel( -_idx*KeysPerOctave, From 6503b7f11060ecdade99b5e602d7aaa3d2982a77 Mon Sep 17 00:00:00 2001 From: regulus79 <117475203+regulus79@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:07:47 -0500 Subject: [PATCH 2/3] Generalize models so that step=0 means continuous --- include/AutomatableModel.h | 5 +++++ src/core/AutomatableModel.cpp | 3 +++ src/gui/widgets/FloatModelEditorBase.cpp | 25 +++++++++++++++++------- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/include/AutomatableModel.h b/include/AutomatableModel.h index 15285e17ab3..44af3b15b7a 100644 --- a/include/AutomatableModel.h +++ b/include/AutomatableModel.h @@ -220,6 +220,11 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject setValue( m_value + steps * m_step ); } + void addValue(float amount) + { + setValue(m_value + amount); + } + float range() const { return m_range; diff --git a/src/core/AutomatableModel.cpp b/src/core/AutomatableModel.cpp index e006be651a4..0812434a0e8 100644 --- a/src/core/AutomatableModel.cpp +++ b/src/core/AutomatableModel.cpp @@ -780,6 +780,7 @@ void AutomatableModel::setUseControllerValue(bool b) float FloatModel::getRoundedValue() const { + if (step() == 0.0f) { return value(); } return std::round(value() / step()) * step(); } @@ -789,6 +790,8 @@ float FloatModel::getRoundedValue() const int FloatModel::getDigitCount() const { auto steptemp = step(); + if (steptemp == 0.0f) { return 10; } + int digits = 0; while ( steptemp < 1 ) { diff --git a/src/gui/widgets/FloatModelEditorBase.cpp b/src/gui/widgets/FloatModelEditorBase.cpp index ebd0d3d9dc7..3dfa7c94c7a 100644 --- a/src/gui/widgets/FloatModelEditorBase.cpp +++ b/src/gui/widgets/FloatModelEditorBase.cpp @@ -311,7 +311,7 @@ void FloatModelEditorBase::wheelEvent(QWheelEvent * we) else if (modKeys == Qt::AltModifier) { // The alt key enables even finer adjustments - numberOfStepsForFullSweep = 2000; + numberOfStepsForFullSweep = 10000; // It seems that on some systems pressing Alt with mess with the directions, // i.e. scrolling the mouse wheel is interpreted as pressing the mouse wheel @@ -331,10 +331,17 @@ void FloatModelEditorBase::wheelEvent(QWheelEvent * we) direction = -direction; } - // Compute the number of steps but make sure that we always do at least one step - const float stepMult = std::max(range / numberOfStepsForFullSweep / step, 1.f); - const int inc = direction * stepMult; - model()->incValue(inc); + if (step != 0.0f) + { + // Compute the number of steps but make sure that we always do at least one step + const float stepMult = std::max(range / numberOfStepsForFullSweep / step, 1.f); + const int inc = direction * stepMult; + model()->incValue(inc); + } + else + { + model()->addValue(direction * range / numberOfStepsForFullSweep); + } s_textFloat->setText(displayValue()); s_textFloat->moveGlobal(this, QPoint(width() + 2, 0)); @@ -359,7 +366,9 @@ void FloatModelEditorBase::setPosition(const QPoint & p) float newValue = value * ratio; if (qAbs(newValue) >= step) { - float roundedValue = qRound((oldValue - value) / step) * step; + float roundedValue = step != 0.0f + ? qRound((oldValue - value) / step) * step + : oldValue - value; model()->setValue(roundedValue); m_leftOver = 0.0f; } @@ -373,7 +382,9 @@ void FloatModelEditorBase::setPosition(const QPoint & p) { if (qAbs(value) >= step) { - float roundedValue = qRound((oldValue - value) / step) * step; + float roundedValue = step != 0.0f + ? qRound((oldValue - value) / step) * step + : oldValue - value; model()->setValue(roundedValue); m_leftOver = 0.0f; } From da038b6df2efb0c10fd42744293fef6b6597a79b Mon Sep 17 00:00:00 2001 From: regulus79 <117475203+regulus79@users.noreply.github.com> Date: Wed, 18 Dec 2024 18:10:17 -0500 Subject: [PATCH 3/3] Forgot to commit tripleosc volume model stepsize change --- plugins/TripleOscillator/TripleOscillator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/TripleOscillator/TripleOscillator.cpp b/plugins/TripleOscillator/TripleOscillator.cpp index 99ec33a9c26..8b356677a5b 100644 --- a/plugins/TripleOscillator/TripleOscillator.cpp +++ b/plugins/TripleOscillator/TripleOscillator.cpp @@ -72,7 +72,7 @@ Plugin::Descriptor PLUGIN_EXPORT tripleoscillator_plugin_descriptor = OscillatorObject::OscillatorObject( Model * _parent, int _idx ) : Model( _parent ), m_volumeModel( DefaultVolume / NUM_OF_OSCILLATORS, MinVolume, - MaxVolume, 0.001f, this, tr( "Osc %1 volume" ).arg( _idx+1 ) ), + MaxVolume, 0.0f, this, tr( "Osc %1 volume" ).arg( _idx+1 ) ), m_panModel( DefaultPanning, PanningLeft, PanningRight, 1.0f, this, tr( "Osc %1 panning" ).arg( _idx+1 ) ), m_coarseModel( -_idx*KeysPerOctave,