BogaudioModules

BogaudioModules for VCV Rack
Log | Files | Refs | README | LICENSE

commit 5a9d37d6d738b243f5d987b0e36d9fb75fb19dfa
parent 8bf86afdf6949f40429b188b89bcc9a5bdf07eba
Author: Matt Demanett <matt@demanett.net>
Date:   Sun, 19 May 2019 23:30:30 -0400

v1: fix widgets, mixers, etc.

Diffstat:
Msrc/Mix1.cpp | 8++++----
Msrc/Mix1.hpp | 30++++++++++++++++--------------
Msrc/Mix4.cpp | 48++++++++++++++++++++++++------------------------
Msrc/Mix4.hpp | 25+++++++++++++++----------
Msrc/Mix8.cpp | 96++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/Mix8.hpp | 45+++++++++++++++++++++++++++------------------
Msrc/mixer.cpp | 49++++++++++++++++++++++---------------------------
Msrc/mixer.hpp | 3+--
Msrc/widgets.cpp | 31+++++++++++++++----------------
Msrc/widgets.hpp | 13+++++--------
10 files changed, 177 insertions(+), 171 deletions(-)

diff --git a/src/Mix1.cpp b/src/Mix1.cpp @@ -2,12 +2,12 @@ #include "Mix1.hpp" void Mix1::onSampleRateChange() { - _channel.setSampleRate(APP->engine->getSampleRate()); + _channel->setSampleRate(APP->engine->getSampleRate()); } void Mix1::process(const ProcessArgs& args) { - _channel.next(false, false); - outputs[OUT_OUTPUT].setVoltage(_channel.out); + _channel->next(false, false); + outputs[OUT_OUTPUT].setVoltage(_channel->out); } struct Mix1Widget : ModuleWidget { @@ -41,7 +41,7 @@ struct Mix1Widget : ModuleWidget { { auto slider = createParam<VUSlider151>(levelParamPosition, module, Mix1::LEVEL_PARAM); if (module) { - dynamic_cast<VUSlider*>(slider)->setVULevel(&module->_channel.rms); + dynamic_cast<VUSlider*>(slider)->setVULevel(&module->_channel->rms); } addParam(slider); } diff --git a/src/Mix1.hpp b/src/Mix1.hpp @@ -33,26 +33,28 @@ struct Mix1 : Module { NUM_LIGHTS }; - MixerChannel _channel; - - Mix1() - : _channel( - params[LEVEL_PARAM], - params[LEVEL_PARAM], // not used - params[MUTE_PARAM], - inputs[IN_INPUT], - inputs[LEVEL_INPUT], - inputs[LEVEL_INPUT], // not used - 1000.0f, - &inputs[MUTE_INPUT] - ) - { + MixerChannel* _channel = NULL; + + Mix1() { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); configParam(LEVEL_PARAM, 0.0f, 1.0f, fabsf(MixerChannel::minDecibels) / (MixerChannel::maxDecibels - MixerChannel::minDecibels), "level"); configParam(MUTE_PARAM, 0.0f, 1.0f, 0.0f, "mute"); + _channel = new MixerChannel( + params[LEVEL_PARAM], + params[LEVEL_PARAM], // not used + params[MUTE_PARAM], + inputs[IN_INPUT], + inputs[LEVEL_INPUT], + inputs[LEVEL_INPUT], // not used + 1000.0f, + &inputs[MUTE_INPUT] + ); onSampleRateChange(); } + virtual ~Mix1() { + delete _channel; + } void onSampleRateChange() override; void process(const ProcessArgs& args) override; diff --git a/src/Mix4.cpp b/src/Mix4.cpp @@ -3,10 +3,10 @@ void Mix4::onSampleRateChange() { float sr = APP->engine->getSampleRate(); - _channel1.setSampleRate(sr); - _channel2.setSampleRate(sr); - _channel3.setSampleRate(sr); - _channel4.setSampleRate(sr); + _channel1->setSampleRate(sr); + _channel2->setSampleRate(sr); + _channel3->setSampleRate(sr); + _channel4->setSampleRate(sr); _slewLimiter.setParams(sr, MixerChannel::levelSlewTimeMS, MixerChannel::maxDecibels - MixerChannel::minDecibels); _rms.setSampleRate(sr); } @@ -18,10 +18,10 @@ void Mix4::process(const ProcessArgs& args) { params[MUTE2_PARAM].getValue() > 1.5f || params[MUTE3_PARAM].getValue() > 1.5f || params[MUTE4_PARAM].getValue() > 1.5f; - _channel1.next(stereo, solo); - _channel2.next(stereo, solo); - _channel3.next(stereo, solo); - _channel4.next(stereo, solo); + _channel1->next(stereo, solo); + _channel2->next(stereo, solo); + _channel3->next(stereo, solo); + _channel4->next(stereo, solo); float level = Amplifier::minDecibels; if (params[MIX_MUTE_PARAM].getValue() < 0.5f) { @@ -35,29 +35,29 @@ void Mix4::process(const ProcessArgs& args) { _amplifier.setLevel(_slewLimiter.next(level)); float mono = 0.0f; - mono += _channel1.out; - mono += _channel2.out; - mono += _channel3.out; - mono += _channel4.out; + mono += _channel1->out; + mono += _channel2->out; + mono += _channel3->out; + mono += _channel4->out; mono = _amplifier.next(mono); mono = _saturator.next(mono); _rmsLevel = _rms.next(mono) / 5.0f; if (stereo) { float left = 0.0f; - left += _channel1.left; - left += _channel2.left; - left += _channel3.left; - left += _channel4.left; + left += _channel1->left; + left += _channel2->left; + left += _channel3->left; + left += _channel4->left; left = _amplifier.next(left); left = _saturator.next(left); outputs[L_OUTPUT].setVoltage(left); float right = 0.0f; - right += _channel1.right; - right += _channel2.right; - right += _channel3.right; - right += _channel4.right; + right += _channel1->right; + right += _channel2->right; + right += _channel3->right; + right += _channel4->right; right = _amplifier.next(right); right = _saturator.next(right); outputs[R_OUTPUT].setVoltage(right); @@ -120,16 +120,16 @@ struct Mix4Widget : ModuleWidget { auto rOutputPosition = Vec(186.5, 325.0); // end generated by svg_widgets.rb - addSlider(level1ParamPosition, module, Mix4::LEVEL1_PARAM, module ? &module->_channel1.rms : NULL); + addSlider(level1ParamPosition, module, Mix4::LEVEL1_PARAM, module ? &module->_channel1->rms : NULL); addParam(createParam<Knob16>(pan1ParamPosition, module, Mix4::PAN1_PARAM)); addParam(createParam<SoloMuteButton>(mute1ParamPosition, module, Mix4::MUTE1_PARAM)); - addSlider(level2ParamPosition, module, Mix4::LEVEL2_PARAM, module ? &module->_channel2.rms : NULL); + addSlider(level2ParamPosition, module, Mix4::LEVEL2_PARAM, module ? &module->_channel2->rms : NULL); addParam(createParam<Knob16>(pan2ParamPosition, module, Mix4::PAN2_PARAM)); addParam(createParam<SoloMuteButton>(mute2ParamPosition, module, Mix4::MUTE2_PARAM)); - addSlider(level3ParamPosition, module, Mix4::LEVEL3_PARAM, module ? &module->_channel3.rms : NULL); + addSlider(level3ParamPosition, module, Mix4::LEVEL3_PARAM, module ? &module->_channel3->rms : NULL); addParam(createParam<Knob16>(pan3ParamPosition, module, Mix4::PAN3_PARAM)); addParam(createParam<SoloMuteButton>(mute3ParamPosition, module, Mix4::MUTE3_PARAM)); - addSlider(level4ParamPosition, module, Mix4::LEVEL4_PARAM, module ? &module->_channel4.rms : NULL); + addSlider(level4ParamPosition, module, Mix4::LEVEL4_PARAM, module ? &module->_channel4->rms : NULL); 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); diff --git a/src/Mix4.hpp b/src/Mix4.hpp @@ -56,22 +56,17 @@ struct Mix4 : Module { NUM_LIGHTS }; - MixerChannel _channel1; - MixerChannel _channel2; - MixerChannel _channel3; - MixerChannel _channel4; + MixerChannel* _channel1; + MixerChannel* _channel2; + MixerChannel* _channel3; + MixerChannel* _channel4; Amplifier _amplifier; bogaudio::dsp::SlewLimiter _slewLimiter; Saturator _saturator; RootMeanSquare _rms; float _rmsLevel = 0.0f; - Mix4() - : _channel1(params[LEVEL1_PARAM], params[PAN1_PARAM], params[MUTE1_PARAM], inputs[IN1_INPUT], inputs[CV1_INPUT], inputs[PAN1_INPUT]) - , _channel2(params[LEVEL2_PARAM], params[PAN2_PARAM], params[MUTE2_PARAM], inputs[IN2_INPUT], inputs[CV2_INPUT], inputs[PAN2_INPUT]) - , _channel3(params[LEVEL3_PARAM], params[PAN3_PARAM], params[MUTE3_PARAM], inputs[IN3_INPUT], inputs[CV3_INPUT], inputs[PAN3_INPUT]) - , _channel4(params[LEVEL4_PARAM], params[PAN4_PARAM], params[MUTE4_PARAM], inputs[IN4_INPUT], inputs[CV4_INPUT], inputs[PAN4_INPUT]) - { + Mix4() { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); float levelDefault = fabsf(MixerChannel::minDecibels) / (MixerChannel::maxDecibels - MixerChannel::minDecibels); configParam(LEVEL1_PARAM, 0.0f, 1.0f, levelDefault); @@ -89,9 +84,19 @@ struct Mix4 : Module { configParam(MIX_PARAM, 0.0f, 1.0f, levelDefault); configParam(MIX_MUTE_PARAM, 0.0f, 3.0f, 0.0); + _channel1 = new MixerChannel(params[LEVEL1_PARAM], params[PAN1_PARAM], params[MUTE1_PARAM], inputs[IN1_INPUT], inputs[CV1_INPUT], inputs[PAN1_INPUT]); + _channel2 = new MixerChannel(params[LEVEL2_PARAM], params[PAN2_PARAM], params[MUTE2_PARAM], inputs[IN2_INPUT], inputs[CV2_INPUT], inputs[PAN2_INPUT]); + _channel3 = new MixerChannel(params[LEVEL3_PARAM], params[PAN3_PARAM], params[MUTE3_PARAM], inputs[IN3_INPUT], inputs[CV3_INPUT], inputs[PAN3_INPUT]); + _channel4 = new MixerChannel(params[LEVEL4_PARAM], params[PAN4_PARAM], params[MUTE4_PARAM], inputs[IN4_INPUT], inputs[CV4_INPUT], inputs[PAN4_INPUT]); onSampleRateChange(); _rms.setSensitivity(0.05f); } + virtual ~Mix4() { + delete _channel1; + delete _channel2; + delete _channel3; + delete _channel4; + } void onSampleRateChange() override; void process(const ProcessArgs& args) override; diff --git a/src/Mix8.cpp b/src/Mix8.cpp @@ -3,14 +3,14 @@ void Mix8::onSampleRateChange() { float sr = APP->engine->getSampleRate(); - _channel1.setSampleRate(sr); - _channel2.setSampleRate(sr); - _channel3.setSampleRate(sr); - _channel4.setSampleRate(sr); - _channel5.setSampleRate(sr); - _channel6.setSampleRate(sr); - _channel7.setSampleRate(sr); - _channel8.setSampleRate(sr); + _channel1->setSampleRate(sr); + _channel2->setSampleRate(sr); + _channel3->setSampleRate(sr); + _channel4->setSampleRate(sr); + _channel5->setSampleRate(sr); + _channel6->setSampleRate(sr); + _channel7->setSampleRate(sr); + _channel8->setSampleRate(sr); _slewLimiter.setParams(sr, MixerChannel::levelSlewTimeMS, MixerChannel::maxDecibels - MixerChannel::minDecibels); _rms.setSampleRate(sr); } @@ -26,14 +26,14 @@ void Mix8::process(const ProcessArgs& args) { params[MUTE6_PARAM].getValue() > 1.5f || params[MUTE7_PARAM].getValue() > 1.5f || params[MUTE8_PARAM].getValue() > 1.5f; - _channel1.next(stereo, solo); - _channel2.next(stereo, solo); - _channel3.next(stereo, solo); - _channel4.next(stereo, solo); - _channel5.next(stereo, solo); - _channel6.next(stereo, solo); - _channel7.next(stereo, solo); - _channel8.next(stereo, solo); + _channel1->next(stereo, solo); + _channel2->next(stereo, solo); + _channel3->next(stereo, solo); + _channel4->next(stereo, solo); + _channel5->next(stereo, solo); + _channel6->next(stereo, solo); + _channel7->next(stereo, solo); + _channel8->next(stereo, solo); float level = Amplifier::minDecibels; if (params[MIX_MUTE_PARAM].getValue() < 0.5f) { @@ -47,41 +47,41 @@ void Mix8::process(const ProcessArgs& args) { _amplifier.setLevel(_slewLimiter.next(level)); float mono = 0.0f; - mono += _channel1.out; - mono += _channel2.out; - mono += _channel3.out; - mono += _channel4.out; - mono += _channel5.out; - mono += _channel6.out; - mono += _channel7.out; - mono += _channel8.out; + mono += _channel1->out; + mono += _channel2->out; + mono += _channel3->out; + mono += _channel4->out; + mono += _channel5->out; + mono += _channel6->out; + mono += _channel7->out; + mono += _channel8->out; mono = _amplifier.next(mono); mono = _saturator.next(mono); _rmsLevel = _rms.next(mono) / 5.0f; if (stereo) { float left = 0.0f; - left += _channel1.left; - left += _channel2.left; - left += _channel3.left; - left += _channel4.left; - left += _channel5.left; - left += _channel6.left; - left += _channel7.left; - left += _channel8.left; + left += _channel1->left; + left += _channel2->left; + left += _channel3->left; + left += _channel4->left; + left += _channel5->left; + left += _channel6->left; + left += _channel7->left; + left += _channel8->left; left = _amplifier.next(left); left = _saturator.next(left); outputs[L_OUTPUT].setVoltage(left); float right = 0.0f; - right += _channel1.right; - right += _channel2.right; - right += _channel3.right; - right += _channel4.right; - right += _channel5.right; - right += _channel6.right; - right += _channel7.right; - right += _channel8.right; + right += _channel1->right; + right += _channel2->right; + right += _channel3->right; + right += _channel4->right; + right += _channel5->right; + right += _channel6->right; + right += _channel7->right; + right += _channel8->right; right = _amplifier.next(right); right = _saturator.next(right); outputs[R_OUTPUT].setVoltage(right); @@ -168,28 +168,28 @@ struct Mix8Widget : ModuleWidget { auto rOutputPosition = Vec(366.5, 325.0); // end generated by svg_widgets.rb - addSlider(level1ParamPosition, module, Mix8::LEVEL1_PARAM, module ? &module->_channel1.rms : NULL); + addSlider(level1ParamPosition, module, Mix8::LEVEL1_PARAM, module ? &module->_channel1->rms : NULL); addParam(createParam<SoloMuteButton>(mute1ParamPosition, module, Mix8::MUTE1_PARAM)); addParam(createParam<Knob16>(pan1ParamPosition, module, Mix8::PAN1_PARAM)); - addSlider(level2ParamPosition, module, Mix8::LEVEL2_PARAM, module ? &module->_channel2.rms : NULL); + addSlider(level2ParamPosition, module, Mix8::LEVEL2_PARAM, module ? &module->_channel2->rms : NULL); addParam(createParam<SoloMuteButton>(mute2ParamPosition, module, Mix8::MUTE2_PARAM)); addParam(createParam<Knob16>(pan2ParamPosition, module, Mix8::PAN2_PARAM)); - addSlider(level3ParamPosition, module, Mix8::LEVEL3_PARAM, module ? &module->_channel3.rms : NULL); + addSlider(level3ParamPosition, module, Mix8::LEVEL3_PARAM, module ? &module->_channel3->rms : NULL); addParam(createParam<SoloMuteButton>(mute3ParamPosition, module, Mix8::MUTE3_PARAM)); addParam(createParam<Knob16>(pan3ParamPosition, module, Mix8::PAN3_PARAM)); - addSlider(level4ParamPosition, module, Mix8::LEVEL4_PARAM, module ? &module->_channel4.rms : NULL); + addSlider(level4ParamPosition, module, Mix8::LEVEL4_PARAM, module ? &module->_channel4->rms : NULL); addParam(createParam<SoloMuteButton>(mute4ParamPosition, module, Mix8::MUTE4_PARAM)); addParam(createParam<Knob16>(pan4ParamPosition, module, Mix8::PAN4_PARAM)); - addSlider(level5ParamPosition, module, Mix8::LEVEL5_PARAM, module ? &module->_channel5.rms : NULL); + addSlider(level5ParamPosition, module, Mix8::LEVEL5_PARAM, module ? &module->_channel5->rms : NULL); addParam(createParam<SoloMuteButton>(mute5ParamPosition, module, Mix8::MUTE5_PARAM)); addParam(createParam<Knob16>(pan5ParamPosition, module, Mix8::PAN5_PARAM)); - addSlider(level6ParamPosition, module, Mix8::LEVEL6_PARAM, module ? &module->_channel6.rms : NULL); + addSlider(level6ParamPosition, module, Mix8::LEVEL6_PARAM, module ? &module->_channel6->rms : NULL); addParam(createParam<SoloMuteButton>(mute6ParamPosition, module, Mix8::MUTE6_PARAM)); addParam(createParam<Knob16>(pan6ParamPosition, module, Mix8::PAN6_PARAM)); - addSlider(level7ParamPosition, module, Mix8::LEVEL7_PARAM, module ? &module->_channel7.rms : NULL); + addSlider(level7ParamPosition, module, Mix8::LEVEL7_PARAM, module ? &module->_channel7->rms : NULL); addParam(createParam<SoloMuteButton>(mute7ParamPosition, module, Mix8::MUTE7_PARAM)); addParam(createParam<Knob16>(pan7ParamPosition, module, Mix8::PAN7_PARAM)); - addSlider(level8ParamPosition, module, Mix8::LEVEL8_PARAM, module ? &module->_channel8.rms : NULL); + addSlider(level8ParamPosition, module, Mix8::LEVEL8_PARAM, module ? &module->_channel8->rms : NULL); 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); diff --git a/src/Mix8.hpp b/src/Mix8.hpp @@ -80,30 +80,21 @@ struct Mix8 : Module { NUM_LIGHTS }; - MixerChannel _channel1; - MixerChannel _channel2; - MixerChannel _channel3; - MixerChannel _channel4; - MixerChannel _channel5; - MixerChannel _channel6; - MixerChannel _channel7; - MixerChannel _channel8; + MixerChannel* _channel1; + MixerChannel* _channel2; + MixerChannel* _channel3; + MixerChannel* _channel4; + MixerChannel* _channel5; + MixerChannel* _channel6; + MixerChannel* _channel7; + MixerChannel* _channel8; Amplifier _amplifier; bogaudio::dsp::SlewLimiter _slewLimiter; Saturator _saturator; RootMeanSquare _rms; float _rmsLevel = 0.0f; - Mix8() - : _channel1(params[LEVEL1_PARAM], params[PAN1_PARAM], params[MUTE1_PARAM], inputs[IN1_INPUT], inputs[CV1_INPUT], inputs[PAN1_INPUT]) - , _channel2(params[LEVEL2_PARAM], params[PAN2_PARAM], params[MUTE2_PARAM], inputs[IN2_INPUT], inputs[CV2_INPUT], inputs[PAN2_INPUT]) - , _channel3(params[LEVEL3_PARAM], params[PAN3_PARAM], params[MUTE3_PARAM], inputs[IN3_INPUT], inputs[CV3_INPUT], inputs[PAN3_INPUT]) - , _channel4(params[LEVEL4_PARAM], params[PAN4_PARAM], params[MUTE4_PARAM], inputs[IN4_INPUT], inputs[CV4_INPUT], inputs[PAN4_INPUT]) - , _channel5(params[LEVEL5_PARAM], params[PAN5_PARAM], params[MUTE5_PARAM], inputs[IN5_INPUT], inputs[CV5_INPUT], inputs[PAN5_INPUT]) - , _channel6(params[LEVEL6_PARAM], params[PAN6_PARAM], params[MUTE6_PARAM], inputs[IN6_INPUT], inputs[CV6_INPUT], inputs[PAN6_INPUT]) - , _channel7(params[LEVEL7_PARAM], params[PAN7_PARAM], params[MUTE7_PARAM], inputs[IN7_INPUT], inputs[CV7_INPUT], inputs[PAN7_INPUT]) - , _channel8(params[LEVEL8_PARAM], params[PAN8_PARAM], params[MUTE8_PARAM], inputs[IN8_INPUT], inputs[CV8_INPUT], inputs[PAN8_INPUT]) - { + Mix8() { config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS); float levelDefault = fabsf(MixerChannel::minDecibels) / (MixerChannel::maxDecibels - MixerChannel::minDecibels); configParam(LEVEL1_PARAM, 0.0f, 1.0f, levelDefault); @@ -133,9 +124,27 @@ struct Mix8 : Module { configParam(MIX_PARAM, 0.0f, 1.0f, levelDefault); configParam(MIX_MUTE_PARAM, 0.0f, 3.0f, 0.0); + _channel1 = new MixerChannel(params[LEVEL1_PARAM], params[PAN1_PARAM], params[MUTE1_PARAM], inputs[IN1_INPUT], inputs[CV1_INPUT], inputs[PAN1_INPUT]); + _channel2 = new MixerChannel(params[LEVEL2_PARAM], params[PAN2_PARAM], params[MUTE2_PARAM], inputs[IN2_INPUT], inputs[CV2_INPUT], inputs[PAN2_INPUT]); + _channel3 = new MixerChannel(params[LEVEL3_PARAM], params[PAN3_PARAM], params[MUTE3_PARAM], inputs[IN3_INPUT], inputs[CV3_INPUT], inputs[PAN3_INPUT]); + _channel4 = new MixerChannel(params[LEVEL4_PARAM], params[PAN4_PARAM], params[MUTE4_PARAM], inputs[IN4_INPUT], inputs[CV4_INPUT], inputs[PAN4_INPUT]); + _channel5 = new MixerChannel(params[LEVEL5_PARAM], params[PAN5_PARAM], params[MUTE5_PARAM], inputs[IN5_INPUT], inputs[CV5_INPUT], inputs[PAN5_INPUT]); + _channel6 = new MixerChannel(params[LEVEL6_PARAM], params[PAN6_PARAM], params[MUTE6_PARAM], inputs[IN6_INPUT], inputs[CV6_INPUT], inputs[PAN6_INPUT]); + _channel7 = new MixerChannel(params[LEVEL7_PARAM], params[PAN7_PARAM], params[MUTE7_PARAM], inputs[IN7_INPUT], inputs[CV7_INPUT], inputs[PAN7_INPUT]); + _channel8 = new MixerChannel(params[LEVEL8_PARAM], params[PAN8_PARAM], params[MUTE8_PARAM], inputs[IN8_INPUT], inputs[CV8_INPUT], inputs[PAN8_INPUT]); onSampleRateChange(); _rms.setSensitivity(0.05f); } + virtual ~Mix8() { + delete _channel1; + delete _channel2; + delete _channel3; + delete _channel4; + delete _channel5; + delete _channel6; + delete _channel7; + delete _channel8; + } void onSampleRateChange() override; void process(const ProcessArgs& args) override; diff --git a/src/mixer.cpp b/src/mixer.cpp @@ -13,7 +13,7 @@ void MixerChannel::setSampleRate(float sampleRate) { } void MixerChannel::next(bool stereo, bool solo) { - if (!_inInput.active) { + if (!_inInput.isConnected()) { rms = out = left = right = 0.0f; return; } @@ -28,7 +28,7 @@ void MixerChannel::next(bool stereo, bool solo) { } else { float level = clamp(_levelParam.value, 0.0f, 1.0f); - if (_levelInput.active) { + if (_levelInput.isConnected()) { level *= clamp(_levelInput.value / 10.0f, 0.0f, 1.0f); } level *= maxDecibels - minDecibels; @@ -40,7 +40,7 @@ void MixerChannel::next(bool stereo, bool solo) { rms = _rms.next(out / 5.0f); if (stereo) { float pan = clamp(_panParam.value, -1.0f, 1.0f); - if (_panInput.active) { + if (_panInput.isConnected()) { pan *= clamp(_panInput.value / 5.0f, -1.0f, 1.0f); } _panner.setPan(_panSL.next(pan)); @@ -69,36 +69,31 @@ SoloMuteButton::SoloMuteButton() { shadow->box.pos = Vec(0.0, 1.0); } -void SoloMuteButton::step() { - // FIXME.v1 FramebufferWidget::step(); -} - void SoloMuteButton::onButton(const event::Button& e) { - // FIXME.v1 - if (!(e.action == GLFW_PRESS /*&& e.button == GLFW_MOUSE_BUTTON_LEFT*/ && (e.mods & RACK_MOD_MASK) == 0)) { + if (!paramQuantity || !(e.action == GLFW_PRESS && (e.mods & RACK_MOD_MASK) == 0)) { return; } - // FIXME.v1 - // if (value >= 2.0f) { - // setValue(value - 2.0f); - // } - // else if (e.button == 1) { // right click - // setValue(value + 2.0f); - // } - // else { - // setValue(value > 0.5f ? 0.0f : 1.0f); - // } - // - // e.consumed = true; - // e.target = this; + float value = paramQuantity->getValue(); + if (value >= 2.0f) { + paramQuantity->setValue(value - 2.0f); + } + else if (e.button == GLFW_MOUSE_BUTTON_RIGHT) { + paramQuantity->setValue(value + 2.0f); + } + else { + paramQuantity->setValue(value > 0.5f ? 0.0f : 1.0f); + } + + e.consume(this); } void SoloMuteButton::onChange(const event::Change& e) { - // FIXME.v1 - // assert(_frames.size() == 4); - // assert(value >= 0.0f && value <= 3.0f); - // _svgWidget->setSvg(_frames[(int)value]); - // dirty = true; + assert(_frames.size() == 4); + if (paramQuantity) { + float value = paramQuantity->getValue(); + assert(value >= 0.0f && value <= 3.0f); + _svgWidget->setSvg(_frames[(int)value]); + } ParamWidget::onChange(e); } diff --git a/src/mixer.hpp b/src/mixer.hpp @@ -65,13 +65,12 @@ struct MuteButton : ToggleButton { } }; -struct SoloMuteButton : ParamWidget /*FIXME.v1 , FramebufferWidget*/ { +struct SoloMuteButton : ParamWidget { std::vector<std::shared_ptr<Svg>> _frames; SvgWidget* _svgWidget; // deleted elsewhere. CircularShadow* shadow = NULL; SoloMuteButton(); - void step() override; void onButton(const event::Button& e) override; void onChange(const event::Change& e) override; }; diff --git a/src/widgets.cpp b/src/widgets.cpp @@ -9,6 +9,7 @@ Button18::Button18() { addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/button_18px_0.svg"))); addFrame(APP->window->loadSvg(asset::plugin(pluginInstance, "res/button_18px_1.svg"))); box.size = Vec(18, 18); + momentary = true; } @@ -100,26 +101,20 @@ StatefulButton::StatefulButton(const char* offSvgPath, const char* onSvgPath) { shadow->box.pos = Vec(0.0, 1.0); } -void StatefulButton::step() { - // FIXME.v1 FramebufferWidget::step(); -} - void StatefulButton::onDragStart(const event::DragStart& e) { - _svgWidget->setSvg(_frames[1]); - // FIXME.v1 - // dirty = true; - // - // if (value >= maxValue) { - // setValue(minValue); - // } - // else { - // setValue(value + 1.0); - // } + if (paramQuantity) { + _svgWidget->setSvg(_frames[1]); + if (paramQuantity->getValue() >= paramQuantity->getMaxValue()) { + paramQuantity->setValue(paramQuantity->getMinValue()); + } + else { + paramQuantity->setValue(paramQuantity->getValue() + 1.0); + } + } } void StatefulButton::onDragEnd(const event::DragEnd& e) { _svgWidget->setSvg(_frames[0]); - // FIXME.v1 dirty = true; } @@ -152,6 +147,10 @@ NVGcolor bogaudio::decibelsToColor(float db) { void VUSlider::draw(const DrawArgs& args) { + if (!paramQuantity) { + return; + } + nvgSave(args.vg); { nvgBeginPath(args.vg); @@ -165,7 +164,7 @@ void VUSlider::draw(const DrawArgs& args) { nvgSave(args.vg); { - // FIXME.v1 nvgTranslate(args.vg, 0, (box.size.y - 13.0f) * (1.0f - value)); + nvgTranslate(args.vg, 0, (box.size.y - 13.0f) * (1.0f - paramQuantity->getValue())); nvgBeginPath(args.vg); nvgRoundedRect(args.vg, 0, 0, 18, 13, 1.5); nvgFillColor(args.vg, nvgRGBA(0x77, 0x77, 0x77, 0xff)); diff --git a/src/widgets.hpp b/src/widgets.hpp @@ -6,9 +6,7 @@ extern Plugin *pluginInstance; namespace bogaudio { -// FIXME.v1: all of this. - -struct Button18 : SvgSwitch /*, MomentarySwitch*/ { +struct Button18 : SvgSwitch { Button18(); }; @@ -52,7 +50,7 @@ struct BlankPort24 : Port24 { BlankPort24(); }; -struct SliderSwitch : SvgSwitch /*, ToggleSwitch*/ { +struct SliderSwitch : SvgSwitch { CircularShadow* shadow = NULL; SliderSwitch(); }; @@ -61,13 +59,12 @@ struct SliderSwitch2State14 : SliderSwitch { SliderSwitch2State14(); }; -struct StatefulButton : ParamWidget /*, FramebufferWidget*/ { +struct StatefulButton : ParamWidget { std::vector<std::shared_ptr<Svg>> _frames; SvgWidget* _svgWidget; // deleted elsewhere. CircularShadow* shadow = NULL; StatefulButton(const char* offSvgPath, const char* onSvgPath); - void step() override; void onDragStart(const event::DragStart& e) override; void onDragEnd(const event::DragEnd& e) override; }; @@ -80,7 +77,7 @@ struct StatefulButton18 : StatefulButton { StatefulButton18(); }; -struct ToggleButton : SvgSwitch /*, ToggleSwitch*/ { +struct ToggleButton : SvgSwitch { }; struct ToggleButton18 : ToggleButton { @@ -89,7 +86,7 @@ struct ToggleButton18 : ToggleButton { NVGcolor decibelsToColor(float db); -struct VUSlider : Knob { +struct VUSlider : SliderKnob { const float slideHeight = 13.0f; float* _vuLevel = NULL;