From 8d04882e84a1adf53e79e284d250bdc5c8bbb255 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Tue, 17 Aug 2021 21:21:55 -0400 Subject: [PATCH] Add some 'const' in parameter space Addresses #3808 but see the problem in #4861 --- src/common/FilterConfiguration.h | 39 +++++---- src/common/Parameter.cpp | 49 ++++++----- src/common/Parameter.h | 87 ++++++++++--------- src/common/SurgePatch.cpp | 4 +- src/common/SurgeStorage.h | 2 +- src/common/dsp/effects/NimbusEffect.cpp | 6 +- .../dsp/effects/ParametricEQ3BandEffect.cpp | 4 +- src/common/dsp/effects/PhaserEffect.cpp | 2 +- .../dsp/effects/airwindows/AirWindowsEffect.h | 18 ++-- src/common/dsp/effects/chowdsp/TapeEffect.cpp | 4 +- .../dsp/oscillators/AliasOscillator.cpp | 18 ++-- src/common/dsp/oscillators/AliasOscillator.h | 2 +- .../dsp/oscillators/ModernOscillator.cpp | 2 +- .../dsp/oscillators/TwistOscillator.cpp | 22 +++-- 14 files changed, 137 insertions(+), 122 deletions(-) diff --git a/src/common/FilterConfiguration.h b/src/common/FilterConfiguration.h index 5e94921c5a5..a2626dd8c97 100644 --- a/src/common/FilterConfiguration.h +++ b/src/common/FilterConfiguration.h @@ -377,20 +377,23 @@ struct FilterSelectorMapper : public ParameterDiscreteIndexRemapper std::cout << "BAD MAPPING TYPES" << std::endl; } - virtual int remapStreamedIndexToDisplayIndex(int i) override { return inverseMapping[i]; } - virtual std::string nameAtStreamedIndex(int i) override { return fut_menu_names[i]; } - virtual bool hasGroupNames() override { return true; }; + virtual int remapStreamedIndexToDisplayIndex(int i) const override + { + return inverseMapping.at(i); + } + virtual std::string nameAtStreamedIndex(int i) const override { return fut_menu_names[i]; } + virtual bool hasGroupNames() const override { return true; }; - virtual std::string groupNameAtStreamedIndex(int i) override + virtual std::string groupNameAtStreamedIndex(int i) const override { - return mapping[inverseMapping[i]].second; + return mapping[inverseMapping.at(i)].second; } - virtual bool sortGroupNames() override { return false; } - bool useRemappedOrderingForGroupsIfNotSorted() override { return true; } + virtual bool sortGroupNames() const override { return false; } + bool useRemappedOrderingForGroupsIfNotSorted() const override { return true; } - virtual bool supportsTotalIndexOrdering() override { return true; } - virtual const std::vector totalIndexOrdering() override + virtual bool supportsTotalIndexOrdering() const override { return true; } + virtual const std::vector totalIndexOrdering() const override { auto res = std::vector(); for (auto m : mapping) @@ -626,20 +629,20 @@ struct WaveShaperSelectorMapper : public ParameterDiscreteIndexRemapper std::cout << "BAD MAPPING TYPES" << std::endl; } - int remapStreamedIndexToDisplayIndex(int i) override { return inverseMapping[i]; } - std::string nameAtStreamedIndex(int i) override { return wst_names[i]; } - bool hasGroupNames() override { return true; }; + int remapStreamedIndexToDisplayIndex(int i) const override { return inverseMapping.at(i); } + std::string nameAtStreamedIndex(int i) const override { return wst_names[i]; } + bool hasGroupNames() const override { return true; }; - std::string groupNameAtStreamedIndex(int i) override + std::string groupNameAtStreamedIndex(int i) const override { - return mapping[inverseMapping[i]].second; + return mapping[inverseMapping.at(i)].second; } - bool sortGroupNames() override { return false; } - bool useRemappedOrderingForGroupsIfNotSorted() override { return true; } + bool sortGroupNames() const override { return false; } + bool useRemappedOrderingForGroupsIfNotSorted() const override { return true; } - bool supportsTotalIndexOrdering() override { return true; } - const std::vector totalIndexOrdering() override + bool supportsTotalIndexOrdering() const override { return true; } + const std::vector totalIndexOrdering() const override { auto res = std::vector(); for (auto m : mapping) diff --git a/src/common/Parameter.cpp b/src/common/Parameter.cpp index cebe06c505d..0e48e4ec7c7 100644 --- a/src/common/Parameter.cpp +++ b/src/common/Parameter.cpp @@ -73,7 +73,7 @@ void get_prefix(char *txt, ControlGroup ctrlgroup, int ctrlgroup_entry, int scen } void Parameter::create_fullname(const char *dn, char *fn, ControlGroup ctrlgroup, - int ctrlgroup_entry, const char *lfoPrefixOverride) + int ctrlgroup_entry, const char *lfoPrefixOverride) const { char prefix[PREFIX_SIZE]; bool useprefix = true; @@ -233,7 +233,7 @@ void Parameter::clear_flags() porta_curve = porta_lin; } -bool Parameter::can_temposync() +bool Parameter::can_temposync() const { switch (ctrltype) { @@ -249,7 +249,7 @@ bool Parameter::can_temposync() return false; } -bool Parameter::can_extend_range() +bool Parameter::can_extend_range() const { switch (ctrltype) { @@ -280,7 +280,7 @@ bool Parameter::can_extend_range() return false; } -bool Parameter::can_be_absolute() +bool Parameter::can_be_absolute() const { switch (ctrltype) { @@ -293,7 +293,7 @@ bool Parameter::can_be_absolute() return false; } -bool Parameter::can_deactivate() +bool Parameter::can_deactivate() const { switch (ctrltype) { @@ -314,7 +314,7 @@ bool Parameter::can_deactivate() return false; } -bool Parameter::has_portaoptions() +bool Parameter::has_portaoptions() const { if (ctrltype == ct_portatime) return true; @@ -322,7 +322,7 @@ bool Parameter::has_portaoptions() return false; } -bool Parameter::has_deformoptions() +bool Parameter::has_deformoptions() const { switch (ctrltype) { @@ -338,7 +338,7 @@ bool Parameter::has_deformoptions() return false; } -bool Parameter::is_bipolar() +bool Parameter::is_bipolar() const { if (dynamicBipolar != nullptr) { @@ -390,7 +390,7 @@ bool Parameter::is_bipolar() return res; } -bool Parameter::is_discrete_selection() +bool Parameter::is_discrete_selection() const { switch (ctrltype) { @@ -417,7 +417,7 @@ bool Parameter::is_discrete_selection() return false; } -bool Parameter::is_nonlocal_on_change() +bool Parameter::is_nonlocal_on_change() const { switch (ctrltype) { @@ -431,7 +431,7 @@ bool Parameter::is_nonlocal_on_change() return false; } -bool Parameter::appears_deactivated() +bool Parameter::appears_deactivated() const { if (dynamicDeactivation) return dynamicDeactivation->getValue(this); @@ -442,7 +442,7 @@ bool Parameter::appears_deactivated() return false; } -Parameter *Parameter::get_primary_deactivation_driver() +Parameter *Parameter::get_primary_deactivation_driver() const { if (dynamicDeactivation) return dynamicDeactivation->getPrimaryDeactivationDriver(this); @@ -1758,7 +1758,7 @@ void Parameter::bound_value(bool force_integer) }; } -bool Parameter::supportsDynamicName() +bool Parameter::supportsDynamicName() const { switch (ctrltype) { @@ -1776,7 +1776,7 @@ bool Parameter::supportsDynamicName() } return false; } -const char *Parameter::get_name() +const char *Parameter::get_name() const { // We only even want to try this for specific types we know support it if (supportsDynamicName() && dynamicName) @@ -1785,7 +1785,7 @@ const char *Parameter::get_name() return dispname; } -const char *Parameter::get_full_name() +const char *Parameter::get_full_name() const { if (supportsDynamicName() && dynamicName) { @@ -1802,7 +1802,7 @@ const char *Parameter::get_internal_name() const { return name; } const char *Parameter::get_storage_name() const { return name_storage; } -char *Parameter::get_storage_value(char *str) +char *Parameter::get_storage_value(char *str) const { switch (valtype) { @@ -1857,6 +1857,7 @@ float Parameter::get_extended(float f) { case ct_freq_reson_band1: { + // Why the heck are we modifying this here? val_max.f = -6.6305f; // 300 Hz return f; } @@ -1936,7 +1937,7 @@ float Parameter::get_extended(float f) } } -std::string Parameter::tempoSyncNotationValue(float f) +std::string Parameter::tempoSyncNotationValue(float f) const { float a, b = modff(f, &a); @@ -2601,7 +2602,7 @@ void Parameter::get_display_of_modulation_depth(char *txt, float modulationDepth } } -float Parameter::quantize_modulation(float inputval) +float Parameter::quantize_modulation(float inputval) const { float res; @@ -2732,7 +2733,7 @@ float Parameter::quantize_modulation(float inputval) return res; } -void Parameter::get_display_alt(char *txt, bool external, float ef) +void Parameter::get_display_alt(char *txt, bool external, float ef) const { txt[0] = 0; @@ -3507,7 +3508,7 @@ void Parameter::get_display(char *txt, bool external, float ef) }; } -float Parameter::get_value_f01() +float Parameter::get_value_f01() const { if (ctrltype == ct_none) return 0; @@ -3526,7 +3527,7 @@ float Parameter::get_value_f01() return 0; } -float Parameter::normalized_to_value(float value) +float Parameter::normalized_to_value(float value) const { switch (valtype) { @@ -3543,7 +3544,7 @@ float Parameter::normalized_to_value(float value) return 0; } -float Parameter::value_to_normalized(float value) +float Parameter::value_to_normalized(float value) const { switch (valtype) { @@ -3562,7 +3563,7 @@ float Parameter::value_to_normalized(float value) const wchar_t *Parameter::getUnit() const { return L""; } -float Parameter::get_default_value_f01() +float Parameter::get_default_value_f01() const { if (ctrltype == ct_none) return 0; @@ -3672,7 +3673,7 @@ void Parameter::morph(Parameter *a, Parameter *b, float x) } } -bool Parameter::can_setvalue_from_string() +bool Parameter::can_setvalue_from_string() const { switch (ctrltype) { diff --git a/src/common/Parameter.h b/src/common/Parameter.h index 92fba9f90d5..158bdf42dd9 100644 --- a/src/common/Parameter.h +++ b/src/common/Parameter.h @@ -206,39 +206,42 @@ struct ParamUserData struct CountedSetUserData : public ParamUserData { - virtual int getCountedSetSize() = 0; // A constant time answer to the count of the set + virtual int getCountedSetSize() const = 0; // A constant time answer to the count of the set }; class Parameter; struct ParameterExternalFormatter : public ParamUserData { - virtual bool formatValue(Parameter *p, float value, char *txt, int txtlen) = 0; - virtual bool formatAltValue(Parameter *p, float value, char *txt, int txtlen) + virtual bool formatValue(const Parameter *p, float value, char *txt, int txtlen) const = 0; + virtual bool formatAltValue(const Parameter *p, float value, char *txt, int txtlen) const { txt[0] = 0; return true; } - virtual bool stringToValue(Parameter *p, const char *txt, float &outVal) = 0; + virtual bool stringToValue(const Parameter *p, const char *txt, float &outVal) const = 0; }; struct ParameterDiscreteIndexRemapper : public ParamUserData { - virtual int remapStreamedIndexToDisplayIndex(int i) = 0; - virtual std::string nameAtStreamedIndex(int i) = 0; - virtual bool hasGroupNames() { return false; } - virtual std::string groupNameAtStreamedIndex(int i) { return ""; } // If you want menu grouping - virtual bool sortGroupNames() { return true; } - virtual bool useRemappedOrderingForGroupsIfNotSorted() { return false; } - - virtual bool supportsTotalIndexOrdering() { return false; } - virtual const std::vector totalIndexOrdering() { return std::vector(); } + virtual int remapStreamedIndexToDisplayIndex(int i) const = 0; + virtual std::string nameAtStreamedIndex(int i) const = 0; + virtual bool hasGroupNames() const { return false; } + virtual std::string groupNameAtStreamedIndex(int i) const + { + return ""; + } // If you want menu grouping + virtual bool sortGroupNames() const { return true; } + virtual bool useRemappedOrderingForGroupsIfNotSorted() const { return false; } + + virtual bool supportsTotalIndexOrdering() const { return false; } + virtual const std::vector totalIndexOrdering() const { return std::vector(); } }; class Parameter; struct ParameterDynamicNameFunction { - virtual const char *getName(Parameter *p) = 0; + virtual const char *getName(const Parameter *p) const = 0; }; /* * The DBF binds to a couple of properties (deactivate, bipolar) so have a general @@ -246,12 +249,12 @@ struct ParameterDynamicNameFunction */ struct ParameterDynamicBoolFunction { - virtual const bool getValue(Parameter *p) = 0; + virtual const bool getValue(const Parameter *p) const = 0; }; struct ParameterDynamicDeactivationFunction : public ParameterDynamicBoolFunction { - virtual Parameter *getPrimaryDeactivationDriver(Parameter *p) { return nullptr; }; + virtual Parameter *getPrimaryDeactivationDriver(const Parameter *p) const { return nullptr; }; }; /* @@ -354,18 +357,18 @@ class Parameter bool defaultDeactivation = true); virtual ~Parameter(); - bool can_temposync(); - bool can_extend_range(); - bool can_be_absolute(); - bool can_deactivate(); - bool can_setvalue_from_string(); + bool can_temposync() const; + bool can_extend_range() const; + bool can_be_absolute() const; + bool can_deactivate() const; + bool can_setvalue_from_string() const; void clear_flags(); - bool has_portaoptions(); - bool has_deformoptions(); - bool is_bipolar(); - bool is_discrete_selection(); // basically a hint to use a dropdown not a slider - bool is_nonlocal_on_change(); // basically a change to me means other vals change so redraw - // everyone else too + bool has_portaoptions() const; + bool has_deformoptions() const; + bool is_bipolar() const; + bool is_discrete_selection() const; // basically a hint to use a dropdown not a slider + bool is_nonlocal_on_change() const; // basically a change to me means other vals change so + // redraw everyone else too /* * Why "appears deactivated" vs "is_deactivated". Well we have primary items @@ -380,15 +383,15 @@ class Parameter * basically meaning that the menu on B can toggle the decativated state on A by * having B be able to locate A (A being the 'primary deactivation driver') */ - bool appears_deactivated(); - Parameter *get_primary_deactivation_driver(); + bool appears_deactivated() const; + Parameter *get_primary_deactivation_driver() const; void set_type(int ctrltype); void morph(Parameter *a, Parameter *b, float x); // void morph(parameter *b, float x); pdata morph(Parameter *b, float x); - const char *get_name(); - const char *get_full_name(); + const char *get_name() const; + const char *get_full_name() const; void set_name(const char *n); // never change name_storage as it is used for storage/recall const char *get_internal_name() const; const char *get_storage_name() const; @@ -404,15 +407,15 @@ class Parameter void get_display_of_modulation_depth(char *txt, float modulationDepth, bool isBipolar, ModulationDisplayMode mode, ModulationDisplayInfoWindowStrings *iw = nullptr); - void get_display_alt(char *txt, bool external = false, float ef = 0.f); - char *get_storage_value(char *); + void get_display_alt(char *txt, bool external = false, float ef = 0.f) const; + char *get_storage_value(char *) const; void set_storage_value(int i); void set_storage_value(float f); float get_extended(float f); - float get_value_f01(); - float normalized_to_value(float value); - float value_to_normalized(float value); - float get_default_value_f01(); + float get_value_f01() const; + float normalized_to_value(float value) const; + float value_to_normalized(float value) const; + float get_default_value_f01() const; void set_value_f01(float v, bool force_integer = false); bool set_value_from_string(const std::string &s); bool set_value_from_string_onto(const std::string &s, pdata &ontoThis); @@ -427,12 +430,12 @@ class Parameter float calculate_modulation_value_from_string(const std::string &s, bool &valid); void bound_value(bool force_integer = false); - std::string tempoSyncNotationValue(float f); - float quantize_modulation(float modvalue); // given a mod-value hand it back rounded to a - // 'reasonable' step size (used in ctrl-drag) + std::string tempoSyncNotationValue(float f) const; + float quantize_modulation(float modvalue) const; // given a mod-value hand it back rounded to a + // 'reasonable' step size (used in ctrl-drag) void create_fullname(const char *dn, char *fn, ControlGroup ctrlgroup, int ctrlgroup_entry, - const char *lfoPrefixOverride = nullptr); + const char *lfoPrefixOverride = nullptr) const; pdata val{}, val_default{}, val_min{}, val_max{}; // You might be tempted to use a non-fixed-size member here, like a std::string, but @@ -507,7 +510,7 @@ class Parameter void set_user_data(ParamUserData *ud); // I take a shallow copy and don't assume ownership and // assume i am referencable - bool supportsDynamicName(); + bool supportsDynamicName() const; ParameterDynamicNameFunction *dynamicName = nullptr; /* diff --git a/src/common/SurgePatch.cpp b/src/common/SurgePatch.cpp index 84576783719..4ac56493177 100644 --- a/src/common/SurgePatch.cpp +++ b/src/common/SurgePatch.cpp @@ -483,7 +483,7 @@ SurgePatch::SurgePatch(SurgeStorage *storage) // Assign the dynamic name handlers static struct : public ParameterDynamicNameFunction { - const char *getName(Parameter *p) + const char *getName(const Parameter *p) const override { static char res[TXT_SIZE]; if (p && p->storage) @@ -518,7 +518,7 @@ SurgePatch::SurgePatch(SurgeStorage *storage) static struct LfoRatePhaseDeact : public ParameterDynamicDeactivationFunction { - const bool getValue(Parameter *p) override + const bool getValue(const Parameter *p) const override { auto cge = p->ctrlgroup_entry - ms_lfo1; auto lf = &(p->storage->getPatch().scene[p->scene - 1].lfo[cge]); diff --git a/src/common/SurgeStorage.h b/src/common/SurgeStorage.h index 04bb1fca44c..37165af1f8a 100644 --- a/src/common/SurgeStorage.h +++ b/src/common/SurgeStorage.h @@ -495,7 +495,7 @@ struct OscillatorStorage : public CountedSetUserData // The counted set is the w float data[max_config]; } extraConfig; - virtual int getCountedSetSize() { return wt.n_tables; } + virtual int getCountedSetSize() const { return wt.n_tables; } }; struct FilterStorage diff --git a/src/common/dsp/effects/NimbusEffect.cpp b/src/common/dsp/effects/NimbusEffect.cpp index ae4de8b33f4..fca05286af2 100644 --- a/src/common/dsp/effects/NimbusEffect.cpp +++ b/src/common/dsp/effects/NimbusEffect.cpp @@ -252,7 +252,7 @@ void NimbusEffect::init_ctrltypes() static struct DynTexDynamicNameBip : public ParameterDynamicNameFunction, ParameterDynamicBoolFunction { - const char *getName(Parameter *p) override + const char *getName(const Parameter *p) const override { auto fx = &(p->storage->getPatch().fx[p->ctrlgroup_entry]); auto idx = p - fx->p; @@ -292,7 +292,7 @@ void NimbusEffect::init_ctrltypes() return res; } - const bool getValue(Parameter *p) override + const bool getValue(const Parameter *p) const override { auto fx = &(p->storage->getPatch().fx[p->ctrlgroup_entry]); auto idx = p - fx->p; @@ -323,7 +323,7 @@ void NimbusEffect::init_ctrltypes() static struct SpreadDeactivator : public ParameterDynamicDeactivationFunction { - const bool getValue(Parameter *p) + const bool getValue(const Parameter *p) const { auto fx = &(p->storage->getPatch().fx[p->ctrlgroup_entry]); auto mode = fx->p[nmb_mode].val.i; diff --git a/src/common/dsp/effects/ParametricEQ3BandEffect.cpp b/src/common/dsp/effects/ParametricEQ3BandEffect.cpp index c845321c049..2bfdc73a772 100644 --- a/src/common/dsp/effects/ParametricEQ3BandEffect.cpp +++ b/src/common/dsp/effects/ParametricEQ3BandEffect.cpp @@ -135,7 +135,7 @@ void ParametricEQ3BandEffect::init_ctrltypes() */ static struct EQD : public ParameterDynamicDeactivationFunction { - const bool getValue(Parameter *p) override + const bool getValue(const Parameter *p) const override { auto fx = &(p->storage->getPatch().fx[p->ctrlgroup_entry]); auto idx = p - fx->p; @@ -155,7 +155,7 @@ void ParametricEQ3BandEffect::init_ctrltypes() return false; } - Parameter *getPrimaryDeactivationDriver(Parameter *p) override + Parameter *getPrimaryDeactivationDriver(const Parameter *p) const override { auto fx = &(p->storage->getPatch().fx[p->ctrlgroup_entry]); auto idx = p - fx->p; diff --git a/src/common/dsp/effects/PhaserEffect.cpp b/src/common/dsp/effects/PhaserEffect.cpp index 55c034c37b4..831f2bd3720 100644 --- a/src/common/dsp/effects/PhaserEffect.cpp +++ b/src/common/dsp/effects/PhaserEffect.cpp @@ -198,7 +198,7 @@ void PhaserEffect::init_ctrltypes() { static struct PhaserDeactivate : public ParameterDynamicDeactivationFunction { - const bool getValue(Parameter *p) override + const bool getValue(const Parameter *p) const override { auto fx = &(p->storage->getPatch().fx[p->ctrlgroup_entry]); auto idx = p - fx->p; diff --git a/src/common/dsp/effects/airwindows/AirWindowsEffect.h b/src/common/dsp/effects/airwindows/AirWindowsEffect.h index f0151100aea..fa11799a2f5 100644 --- a/src/common/dsp/effects/airwindows/AirWindowsEffect.h +++ b/src/common/dsp/effects/airwindows/AirWindowsEffect.h @@ -58,28 +58,29 @@ class alignas(16) AirWindowsEffect : public Effect { AWFxSelectorMapper(AirWindowsEffect *fx) { this->fx = fx; }; - virtual int remapStreamedIndexToDisplayIndex(int i) override + virtual int remapStreamedIndexToDisplayIndex(int i) const override { return fx->fxreg[i].displayOrder; } - virtual std::string nameAtStreamedIndex(int i) override { return fx->fxreg[i].name; } - virtual bool hasGroupNames() override { return true; } + virtual std::string nameAtStreamedIndex(int i) const override { return fx->fxreg[i].name; } + virtual bool hasGroupNames() const override { return true; } - virtual std::string groupNameAtStreamedIndex(int i) override + virtual std::string groupNameAtStreamedIndex(int i) const override { return fx->fxreg[i].groupName; } - bool supportsTotalIndexOrdering() override { return true; } + bool supportsTotalIndexOrdering() const override { return true; } - const std::vector totalIndexOrdering() override { return fx->fxregOrdering; } + const std::vector totalIndexOrdering() const override { return fx->fxregOrdering; } AirWindowsEffect *fx; }; struct AWFxParamFormatter : public ParameterExternalFormatter { AWFxParamFormatter(AirWindowsEffect *fx, int i) : fx(fx), idx(i) {} - virtual bool formatValue(Parameter *p, float value, char *txt, int txtlen) override + virtual bool formatValue(const Parameter *p, float value, char *txt, + int txtlen) const override { if (fx && fx->airwin) { @@ -119,7 +120,8 @@ class alignas(16) AirWindowsEffect : public Effect return true; } - virtual bool stringToValue(Parameter *p, const char *txt, float &outVal) override + virtual bool stringToValue(const Parameter *p, const char *txt, + float &outVal) const override { if (fx && fx->airwin) { diff --git a/src/common/dsp/effects/chowdsp/TapeEffect.cpp b/src/common/dsp/effects/chowdsp/TapeEffect.cpp index 984a083d51c..9aa0f71ace6 100644 --- a/src/common/dsp/effects/chowdsp/TapeEffect.cpp +++ b/src/common/dsp/effects/chowdsp/TapeEffect.cpp @@ -144,7 +144,7 @@ void TapeEffect::init_ctrltypes() */ static struct TapeEffectDeact : public ParameterDynamicDeactivationFunction { - const bool getValue(Parameter *p) override + const bool getValue(const Parameter *p) const override { auto fx = &(p->storage->getPatch().fx[p->ctrlgroup_entry]); auto idx = p - fx->p; @@ -166,7 +166,7 @@ void TapeEffect::init_ctrltypes() return false; } - Parameter *getPrimaryDeactivationDriver(Parameter *p) override + Parameter *getPrimaryDeactivationDriver(const Parameter *p) const override { auto fx = &(p->storage->getPatch().fx[p->ctrlgroup_entry]); auto idx = p - fx->p; diff --git a/src/common/dsp/oscillators/AliasOscillator.cpp b/src/common/dsp/oscillators/AliasOscillator.cpp index f6cab9c1eee..b3d3db8eab8 100644 --- a/src/common/dsp/oscillators/AliasOscillator.cpp +++ b/src/common/dsp/oscillators/AliasOscillator.cpp @@ -459,10 +459,10 @@ void AliasOscillator::init_ctrltypes() { static struct WaveRemapper : public ParameterDiscreteIndexRemapper { - bool hasGroupNames() override { return true; } - bool supportsTotalIndexOrdering() override { return true; }; - bool sortGroupNames() override { return false; } - bool useRemappedOrderingForGroupsIfNotSorted() override { return true; } + bool hasGroupNames() const override { return true; } + bool supportsTotalIndexOrdering() const override { return true; }; + bool sortGroupNames() const override { return false; } + bool useRemappedOrderingForGroupsIfNotSorted() const override { return true; } std::vector> mapping; std::unordered_map inverseMapping; @@ -504,7 +504,7 @@ void AliasOscillator::init_ctrltypes() } } - int remapStreamedIndexToDisplayIndex(int i) override + int remapStreamedIndexToDisplayIndex(int i) const override { switch ((ao_waves)i) { @@ -539,7 +539,7 @@ void AliasOscillator::init_ctrltypes() } } - std::string nameAtStreamedIndex(int i) override + std::string nameAtStreamedIndex(int i) const override { if (i <= aow_noise) return alias_wave_name[i]; @@ -571,12 +571,12 @@ void AliasOscillator::init_ctrltypes() } } - std::string groupNameAtStreamedIndex(int i) override + std::string groupNameAtStreamedIndex(int i) const override { - return mapping[inverseMapping[i]].second; + return mapping.at(inverseMapping.at(i)).second; } - const std::vector totalIndexOrdering() override + const std::vector totalIndexOrdering() const override { auto res = std::vector(); diff --git a/src/common/dsp/oscillators/AliasOscillator.h b/src/common/dsp/oscillators/AliasOscillator.h index 062fd163b02..6cb08a2f2fd 100644 --- a/src/common/dsp/oscillators/AliasOscillator.h +++ b/src/common/dsp/oscillators/AliasOscillator.h @@ -139,7 +139,7 @@ class AliasOscillator : public Oscillator struct Always255CountedSet : public CountedSetUserData // Something to feed to a ct_countedset_percent control { - virtual int getCountedSetSize() { return 255; } + virtual int getCountedSetSize() const { return 255; } }; const Always255CountedSet ALWAYS255COUNTEDSET; diff --git a/src/common/dsp/oscillators/ModernOscillator.cpp b/src/common/dsp/oscillators/ModernOscillator.cpp index 85182432212..2d26c2b5816 100644 --- a/src/common/dsp/oscillators/ModernOscillator.cpp +++ b/src/common/dsp/oscillators/ModernOscillator.cpp @@ -536,7 +536,7 @@ void ModernOscillator::process_block(float pitch, float drift, bool stereo, bool static struct ModernTriName : public ParameterDynamicNameFunction { - virtual const char *getName(Parameter *p) + const char *getName(const Parameter *p) const override { auto flag = p->deform_type; int mt = flag & 0xF; diff --git a/src/common/dsp/oscillators/TwistOscillator.cpp b/src/common/dsp/oscillators/TwistOscillator.cpp index 45e13da0013..fefcb09f4dc 100644 --- a/src/common/dsp/oscillators/TwistOscillator.cpp +++ b/src/common/dsp/oscillators/TwistOscillator.cpp @@ -112,7 +112,7 @@ static struct EngineDynamicName : public ParameterDynamicNameFunction engineLabels.push_back({"Tone<>Noise", "Low Cut", "Decay Time", "Variation"}); } - const char *getName(Parameter *p) override + const char *getName(const Parameter *p) const override { auto oscs = &(p->storage->getPatch().scene[p->scene - 1].osc[p->ctrlgroup_entry]); @@ -176,7 +176,7 @@ static struct EngineDynamicBipolar : public ParameterDynamicBoolFunction engineBipolars.push_back({true, false, false, true}); // Analog Hi-Hat } - const bool getValue(Parameter *p) override + const bool getValue(const Parameter *p) const override { auto oscs = &(p->storage->getPatch().scene[p->scene - 1].osc[p->ctrlgroup_entry]); @@ -197,7 +197,7 @@ static struct EngineDynamicBipolar : public ParameterDynamicBoolFunction } auto idx = (p - engp); - auto res = engineBipolars[eng][idx - 1]; + bool res = engineBipolars[eng][idx - 1]; if (idx == TwistOscillator::twist_aux_mix) res = p->extend_range; @@ -207,9 +207,15 @@ static struct EngineDynamicBipolar : public ParameterDynamicBoolFunction static struct EngineDisplayFormatter : ParameterExternalFormatter { - bool formatValue(Parameter *p, float value, char *txt, int txtlen) override { return false; } - bool stringToValue(Parameter *p, const char *txt, float &outVal) override { return false; } - bool formatAltValue(Parameter *p, float value, char *txt, int txtlen) override + bool formatValue(const Parameter *p, float value, char *txt, int txtlen) const override + { + return false; + } + bool stringToValue(const Parameter *p, const char *txt, float &outVal) const override + { + return false; + } + bool formatAltValue(const Parameter *p, float value, char *txt, int txtlen) const override { auto oscs = &(p->storage->getPatch().scene[p->scene - 1].osc[p->ctrlgroup_entry]); @@ -253,13 +259,13 @@ static struct EngineDynamicDeact : public ParameterDynamicDeactivationFunction { EngineDynamicDeact() noexcept {} - const bool getValue(Parameter *p) override + const bool getValue(const Parameter *p) const override { auto oscs = &(p->storage->getPatch().scene[p->scene - 1].osc[p->ctrlgroup_entry]); return oscs->p[TwistOscillator::twist_lpg_response].deactivated; } - Parameter *getPrimaryDeactivationDriver(Parameter *p) override + Parameter *getPrimaryDeactivationDriver(const Parameter *p) const override { auto oscs = &(p->storage->getPatch().scene[p->scene - 1].osc[p->ctrlgroup_entry]); return &(oscs->p[TwistOscillator::twist_lpg_response]);