commit d54d936478fa365dc97d3c0495a05de1ee9c2504
parent e5313eadfa5acdacc435c2f8d9dc94c846b7e7c2
Author: Matt Demanett <matt@demanett.net>
Date: Tue, 28 Sep 2021 23:21:27 -0400
Rack2: fix custom randomization on MIX4/8.
Diffstat:
5 files changed, 36 insertions(+), 23 deletions(-)
diff --git a/src/Mix4.cpp b/src/Mix4.cpp
@@ -3,6 +3,13 @@
#define POLY_OFFSET "poly_channel_offset"
+void Mix4::onRandomize(const RandomizeEvent& e) {
+ Module::onRandomize(e);
+ for (int i = 0; i < 4; ++i) {
+ getParamQuantity(MUTE1_PARAM + 3*i)->setValue(random::uniform() > 0.5f);
+ }
+}
+
json_t* Mix4::saveToJson(json_t* root) {
root = DimmableMixerModule::saveToJson(root);
json_object_set_new(root, POLY_OFFSET, json_integer(_polyChannelOffset));
@@ -228,16 +235,8 @@ struct Mix4Widget : DimmableMixerWidget {
addParam(createParam<Knob16>(pan4ParamPosition, module, Mix4::PAN4_PARAM));
addParam(createParam<SoloMuteButton>(mute4ParamPosition, module, Mix4::MUTE4_PARAM));
addSlider(mixParamPosition, module, Mix4::MIX_PARAM, module ? &module->_rmsLevel : NULL);
- {
- auto b = createParam<MuteButton>(mixMuteParamPosition, module, Mix4::MIX_MUTE_PARAM);
- b->setRandomize(false);
- addParam(b);
- }
- {
- auto b = createParam<MuteButton>(mixDimParamPosition, module, Mix4::MIX_DIM_PARAM);
- b->setRandomize(false);
- addParam(b);
- }
+ addParam(createParam<MuteButton>(mixMuteParamPosition, module, Mix4::MIX_MUTE_PARAM));
+ addParam(createParam<MuteButton>(mixDimParamPosition, module, Mix4::MIX_DIM_PARAM));
addInput(createInput<Port24>(cv1InputPosition, module, Mix4::CV1_INPUT));
addInput(createInput<Port24>(pan1InputPosition, module, Mix4::PAN1_INPUT));
diff --git a/src/Mix4.hpp b/src/Mix4.hpp
@@ -81,6 +81,12 @@ struct Mix4 : ExpandableModule<Mix4ExpanderMessage, DimmableMixerModule> {
configParam(MIX_PARAM, 0.0f, 1.0f, levelDefault, "Master level", " dB", 0.0f, MixerChannel::maxDecibels - MixerChannel::minDecibels, MixerChannel::minDecibels);
configParam(MIX_MUTE_PARAM, 0.0f, 1.0f, 0.0f, "Master mute");
configParam(MIX_DIM_PARAM, 0.0f, 1.0f, 0.0f, "Master dim");
+ getParamQuantity(MUTE1_PARAM)->randomizeEnabled = false;
+ getParamQuantity(MUTE2_PARAM)->randomizeEnabled = false;
+ getParamQuantity(MUTE3_PARAM)->randomizeEnabled = false;
+ getParamQuantity(MUTE4_PARAM)->randomizeEnabled = false;
+ getParamQuantity(MIX_MUTE_PARAM)->randomizeEnabled = false;
+ getParamQuantity(MIX_DIM_PARAM)->randomizeEnabled = false;
_channels[0] = new MixerChannel(params[LEVEL1_PARAM], params[MUTE1_PARAM], inputs[CV1_INPUT]);
_channels[1] = new MixerChannel(params[LEVEL2_PARAM], params[MUTE2_PARAM], inputs[CV2_INPUT]);
@@ -97,6 +103,7 @@ struct Mix4 : ExpandableModule<Mix4ExpanderMessage, DimmableMixerModule> {
}
}
+ void onRandomize(const RandomizeEvent& e) override;
json_t* saveToJson(json_t* root) override;
void loadFromJson(json_t* root) override;
void sampleRateChange() override;
diff --git a/src/Mix8.cpp b/src/Mix8.cpp
@@ -3,6 +3,13 @@
#define POLY_OFFSET "poly_channel_offset"
+void Mix8::onRandomize(const RandomizeEvent& e) {
+ Module::onRandomize(e);
+ for (int i = 0; i < 8; ++i) {
+ getParamQuantity(MUTE1_PARAM + 3*i)->setValue(random::uniform() > 0.5f);
+ }
+}
+
json_t* Mix8::saveToJson(json_t* root) {
root = DimmableMixerModule::saveToJson(root);
json_object_set_new(root, POLY_OFFSET, json_integer(_polyChannelOffset));
@@ -272,16 +279,8 @@ struct Mix8Widget : DimmableMixerWidget {
addParam(createParam<SoloMuteButton>(mute8ParamPosition, module, Mix8::MUTE8_PARAM));
addParam(createParam<Knob16>(pan8ParamPosition, module, Mix8::PAN8_PARAM));
addSlider(mixParamPosition, module, Mix8::MIX_PARAM, module ? &module->_rmsLevel : NULL);
- {
- auto b = createParam<MuteButton>(mixMuteParamPosition, module, Mix8::MIX_MUTE_PARAM);
- b->setRandomize(false);
- addParam(b);
- }
- {
- auto b = createParam<MuteButton>(mixDimParamPosition, module, Mix8::MIX_DIM_PARAM);
- b->setRandomize(false);
- addParam(b);
- }
+ addParam(createParam<MuteButton>(mixMuteParamPosition, module, Mix8::MIX_MUTE_PARAM));
+ addParam(createParam<MuteButton>(mixDimParamPosition, module, Mix8::MIX_DIM_PARAM));
addInput(createInput<Port24>(cv1InputPosition, module, Mix8::CV1_INPUT));
addInput(createInput<Port24>(pan1InputPosition, module, Mix8::PAN1_INPUT));
diff --git a/src/Mix8.hpp b/src/Mix8.hpp
@@ -117,6 +117,16 @@ struct Mix8 : ExpandableModule<Mix8ExpanderMessage, DimmableMixerModule> {
configParam(MIX_PARAM, 0.0f, 1.0f, levelDefault, "Master level", " dB", 0.0f, MixerChannel::maxDecibels - MixerChannel::minDecibels, MixerChannel::minDecibels);
configParam(MIX_MUTE_PARAM, 0.0f, 1.0f, 0.0f, "Master mute");
configParam(MIX_DIM_PARAM, 0.0f, 1.0f, 0.0f, "Master dim");
+ getParamQuantity(MUTE1_PARAM)->randomizeEnabled = false;
+ getParamQuantity(MUTE2_PARAM)->randomizeEnabled = false;
+ getParamQuantity(MUTE3_PARAM)->randomizeEnabled = false;
+ getParamQuantity(MUTE4_PARAM)->randomizeEnabled = false;
+ getParamQuantity(MUTE5_PARAM)->randomizeEnabled = false;
+ getParamQuantity(MUTE6_PARAM)->randomizeEnabled = false;
+ getParamQuantity(MUTE7_PARAM)->randomizeEnabled = false;
+ getParamQuantity(MUTE8_PARAM)->randomizeEnabled = false;
+ getParamQuantity(MIX_MUTE_PARAM)->randomizeEnabled = false;
+ getParamQuantity(MIX_DIM_PARAM)->randomizeEnabled = false;
_channels[0] = new MixerChannel(params[LEVEL1_PARAM], params[MUTE1_PARAM], inputs[CV1_INPUT]);
_channels[1] = new MixerChannel(params[LEVEL2_PARAM], params[MUTE2_PARAM], inputs[CV2_INPUT]);
@@ -137,6 +147,7 @@ struct Mix8 : ExpandableModule<Mix8ExpanderMessage, DimmableMixerModule> {
}
}
+ void onRandomize(const RandomizeEvent& e) override;
json_t* saveToJson(json_t* root) override;
void loadFromJson(json_t* root) override;
void sampleRateChange() override;
diff --git a/src/mixer.hpp b/src/mixer.hpp
@@ -72,14 +72,11 @@ struct DimmableMixerWidget : LinearCVMixerWidget {
};
struct MuteButton : ToggleButton {
- bool _randomize = true;
-
MuteButton() {
addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/button_18px_0.svg")));
addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/button_18px_1_orange.svg")));
}
- inline void setRandomize(bool randomize) { _randomize = randomize; }
void onButton(const event::Button& e) override;
void draw(const DrawArgs& args) override;
};