StoneyVCV v2
StoneyDSP Modules for VCV Rack 2.
Loading...
Searching...
No Matches
VCA.hpp
Go to the documentation of this file.
1
31#pragma once
32
33#define STONEYVCV_VCA_HPP_INCLUDED 1
34
35#if defined (STONEYVCV_BUILD_VCA)
36
37//==============================================================================
38
39#include <StoneyVCV.hpp>
44#include <StoneyVCV/plugin.hpp>
45
46//==============================================================================
47
48#include <rack.hpp>
49#include <StoneyDSP/Core.hpp>
50#include <StoneyDSP/DSP.hpp>
51#include <StoneyDSP/SIMD.hpp>
52
53//==============================================================================
54
55#include <array>
56
57//==============================================================================
58
59namespace StoneyDSP
60{
65//==============================================================================
66
67namespace StoneyVCV
68{
73//==============================================================================
74
82namespace VCA
83{
88//==============================================================================
89
94template<typename T>
96{
97 //==========================================================================
98
99public:
100
101 //==========================================================================
102
104
106
107 //==========================================================================
108
110
112
114
116
118
119 //==========================================================================
120
121private:
122
123 //==========================================================================
124
130
136
139};
140
141//==============================================================================
142
147struct VCAModule final : virtual ::rack::engine::Module
148{
149
150 //==========================================================================
151
152public:
153
154 //==========================================================================
155
158 NUM_PARAMS
159 };
160
164 NUM_INPUTS
165 };
166
169 NUM_OUTPUTS
170 };
171
173 //BLINK_LIGHT,
175 NUM_LIGHTS
176 };
177
178 //==========================================================================
179
185
191
192 //==========================================================================
193
199 virtual void process(const ::StoneyDSP::StoneyVCV::VCA::VCAModule::ProcessArgs &args) override;
200
201 //==========================================================================
202
207
212
213 //==========================================================================
214
216
217 ::std::size_t getCvInputNumChannels() noexcept;
218
225 ::std::size_t getMinNumChannels() noexcept;
226
227 ::rack::engine::Input &getVcaInput() noexcept;
228
229 ::rack::engine::Input &getCvInput() noexcept;
230
231 ::rack::engine::Param &getGainParam() noexcept;
232
233 ::rack::engine::Output &getVcaOutput() noexcept;
234
235 ::rack::engine::Light &getBlinkLight() noexcept;
236
237 //==========================================================================
238
239private:
240
241 //==========================================================================
242
243 using ProcessArgs = ::rack::engine::Module::ProcessArgs;
244
245 //==========================================================================
246
251 ::rack::dsp::ClockDivider lightDivider;
252
257 ::std::array<::StoneyDSP::StoneyVCV::VCA::VCAEngine<float>, 16> engine;
258
263 ::std::array<float, 16> lightGains;
264
265 //==========================================================================
266
271 const ::StoneyDSP::float_t &vNominal = ::StoneyDSP::StoneyVCV::Tools::vNominal;
272
277 const ::StoneyDSP::float_t &vFloor = ::StoneyDSP::StoneyVCV::Tools::vFloor;
278
279 //==========================================================================
280
281 ::rack::engine::Input* vcaInputPtr = NULL;
282
283 ::rack::engine::Input* cvInputPtr = NULL;
284
285 ::rack::engine::Param* gainParamPtr = NULL;
286
287 ::rack::engine::Output* vcaOutputPtr = NULL;
288
289 ::rack::engine::Light* blinkLightPtr = NULL;
290
291 //==========================================================================
292
295};
296
297//==============================================================================
298
303struct VCAPanelWidget final : virtual ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget
304{
305
306 //==========================================================================
307
308public:
309
311
312 //==========================================================================
313
318 VCAPanelWidget(::rack::math::Rect newBox);
319
325
326 //==========================================================================
327
332 virtual void step() override;
333
340 virtual void draw(const ::StoneyDSP::StoneyVCV::VCA::VCAPanelWidget::DrawArgs &args) override;
341
342 //==========================================================================
343
344private:
345
346 //==========================================================================
347
351};
352
353//==============================================================================
354
359struct VCAModuleWidget final : virtual ::rack::app::ModuleWidget
360{
361
362 //==========================================================================
363
364public:
365
366 using DrawArgs = ::rack::app::ModuleWidget::DrawArgs;
367
368 //==========================================================================
369
377
383
384 //==========================================================================
385
391 virtual void step() override;
392
398 virtual void draw(const ::StoneyDSP::StoneyVCV::VCA::VCAModuleWidget::DrawArgs &args) override;
399
400 //==========================================================================
401
407 struct PrefersDarkPanelsChangeEvent : ::rack::widget::Widget::BaseEvent {
409 };
410
420
425
426 //==========================================================================
427
428 struct PixelRatioChangeEvent : ::rack::widget::Widget::BaseEvent {
429 float newPixelRatio = APP->window->pixelRatio;
430 };
431
441
447
448 //==========================================================================
449
450private:
451
452 //==========================================================================
453
458 ::rack::app::ThemedSvgPanel *svgPanelWidget = NULL;
459
464 ::StoneyDSP::StoneyVCV::VCA::VCAPanelWidget *panelWidget = NULL;
465
470 ::StoneyDSP::StoneyVCV::ComponentLibrary::FramebufferWidget *fb = NULL;
471
472 //==========================================================================
473
478 ::StoneyDSP::StoneyVCV::ComponentLibrary::RoundHugeBlackKnob *knobGain = NULL;
479
480 // ::rack::componentlibrary::VCVLightSlider<::rack::componentlibrary::YellowLight>* gainSlider = NULL;
481
482 //==========================================================================
483
488 ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortWidget *portInputCv = NULL;
489
494 ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortWidget *portInputVca = NULL;
495
500 ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortWidget *portOutputVca = NULL;
501
507
508 // ::rack::componentlibrary::MediumLight<::rack::componentlibrary::RedLight> *lightVca = NULL;
509
510
511 //==========================================================================
512
517 bool lastPrefersDarkPanels = {::rack::settings::preferDarkPanels};
518
523 const bool *prefersDarkPanelsPtr = NULL;
524
525 //==========================================================================
526
531 float lastPixelRatio = {APP->window->pixelRatio};
532
537 const float *pixelRatioPtr = NULL;
538
539 //==========================================================================
540
543};
544
545//==============================================================================
546
558 ::std::string name = "",
559 ::std::string description = "",
560 ::std::string manualUrl = "",
561 bool hidden = true
562) noexcept(false); // STONEYDSP_NOEXCEPT(false);
563
564//==============================================================================
565
567} // namespace VCA
568
569//==============================================================================
570
572} // namespace VCVRack
573
574//==============================================================================
575
577} // namespace StoneyDSP
578
579//==============================================================================
580
581#endif // defined (STONEYVCV_BUILD_VCA)
582
583//==============================================================================
StoneyDSP Modules for VCV Rack 2.
StoneyDSP Modules for VCV Rack 2.
StoneyDSP Modules for VCV Rack 2.
StoneyDSP Modules for VCV Rack 2.
::rack::plugin::Model * createModelVCA(::std::string name="", ::std::string description="", ::std::string manualUrl="", bool hidden=true) noexcept(false)
The StoneyDSP namespace.
Definition StoneyVCV.hpp:78
StoneyDSP Modules for VCV Rack 2.
::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedWidget::DrawArgs DrawArgs
Definition PanelWidget.hpp:243
Definition StoneyVCV.hpp:125
Engine()
Definition StoneyVCV.hpp:133
The VCAEngine struct.
Definition VCA.hpp:96
T lastGain
Definition VCA.hpp:135
void setGain(const T &newGain)
void processSampleSimd(::StoneyDSP::SIMD::float_4 *v)
void processSample(T *sample) override
T gain
Definition VCA.hpp:129
Occurs after the prefersDarkPanels setting is changed.
Definition VCA.hpp:407
The VCAModuleWidget struct.
Definition VCA.hpp:360
const bool & getPrefersDarkPanels() const noexcept
::rack::app::ModuleWidget::DrawArgs DrawArgs
Definition VCA.hpp:366
virtual ~VCAModuleWidget() noexcept
Destroys the VCAModuleWidget object.
virtual void onPrefersDarkPanelsChange(const PrefersDarkPanelsChangeEvent &e)
Called after the prefersDarkPanels setting is changed.
VCAModuleWidget(::StoneyDSP::StoneyVCV::VCA::VCAModule *module)
Construct a new VCAModuleWidget object.
virtual void onPixelRatioChange(const PixelRatioChangeEvent &e)
Called after the App->window->pixelRatio setting is changed.
const float & getPixelRatio() const noexcept
The VCAModule struct.
Definition VCA.hpp:148
virtual void onNumChannelsChanged(const NumChannelsChangedEvent &e)
Called after enabling the module.
Definition VCA.hpp:206
virtual ~VCAModule() noexcept
Destroy the VCAModule object.
::rack::engine::Module::ProcessArgs ProcessArgs
Definition VCA.hpp:243
virtual void onGainParamChanged(const GainParamChangedEvent &e)
Called after changing the Gain parameter (knob) on the panel.
Definition VCA.hpp:211
@ ENUMS
Definition VCA.hpp:174
@ GAIN_PARAM
Definition VCA.hpp:157
@ VCA_INPUT
Definition VCA.hpp:162
@ CV_INPUT
Definition VCA.hpp:163
VCAModule()
Construct a new VCAModule object.
::std::size_t getVcaInputNumChannels() noexcept
IdxOutputs
Definition VCA.hpp:167
@ VCA_OUTPUT
Definition VCA.hpp:168
The VCAPanelWidget struct.
Definition VCA.hpp:304
virtual ~VCAPanelWidget() noexcept
Destroys the VCAPanelWidget object.
VCAPanelWidget(::rack::math::Rect newBox)
Construct a new VCAPanelWidget object.
::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget::DrawArgs DrawArgs
Definition VCA.hpp:310