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>
43#include <StoneyVCV/plugin.hpp>
44
45//==============================================================================
46
47#include <rack.hpp>
48#include <StoneyDSP/Core.hpp>
49#include <StoneyDSP/DSP.hpp>
50#include <StoneyDSP/SIMD.hpp>
51
52//==============================================================================
53
54#include <array>
55
56//==============================================================================
57
58namespace StoneyDSP
59{
64//==============================================================================
65
66namespace StoneyVCV
67{
72//==============================================================================
73
81namespace VCA
82{
87//==============================================================================
88
93template<typename T>
95{
96 //==========================================================================
97
98public:
99
100 //==========================================================================
101
103
105
107
108 //==========================================================================
109
111
113
115
117
119
120 //==========================================================================
121
122private:
123
124 //==========================================================================
125
131
137
140};
141
142//==============================================================================
143
148struct VCAModule final : virtual ::rack::engine::Module
149{
150
151 //==========================================================================
152
153public:
154
155 //==========================================================================
156
159 NUM_PARAMS
160 };
161
165 NUM_INPUTS
166 };
167
170 NUM_OUTPUTS
171 };
172
174 BLINK_LIGHT, // ENUMS(BLINK_LIGHT, 2),
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
203private:
204
205 //==========================================================================
206
207 using ProcessArgs = ::rack::engine::Module::ProcessArgs;
208
209 //==========================================================================
210
211 ::rack::engine::Input &getVcaInput() noexcept;
212
213 ::rack::engine::Input &getCvInput() noexcept;
214
215 ::rack::engine::Param &getGainParam() noexcept;
216
217 ::rack::engine::Output &getVcaOutput() noexcept;
218
219 ::rack::engine::Light &getBlinkLight() noexcept;
220
221 //==========================================================================
222
227 ::rack::dsp::ClockDivider lightDivider;
228
233 ::std::array<::StoneyDSP::StoneyVCV::VCA::VCAEngine<::StoneyDSP::float_t>, 16> engine;
234
239 ::std::array<::StoneyDSP::float_t, 16> lightGains;
240
241 //==========================================================================
242
247 const ::StoneyDSP::float_t &vNominal = ::StoneyDSP::StoneyVCV::Tools::vNominal;
248
253 const ::StoneyDSP::float_t &vFloor = ::StoneyDSP::StoneyVCV::Tools::vFloor;
254
255 //==========================================================================
256
257 ::rack::engine::Input* vcaInputPtr;
258
259 ::rack::engine::Input* cvInputPtr;
260
261 ::rack::engine::Param* gainParamPtr;
262
263 ::rack::engine::Output* vcaOutputPtr;
264
265 ::rack::engine::Light* blinkLightPtr;
266
269};
270
271//==============================================================================
272
277struct VCAWidget final : virtual ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget
278{
279
280 //==========================================================================
281
282public:
283
284 using DrawArgs = ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget::DrawArgs;
285
286 //==========================================================================
287
293
298 virtual ~VCAWidget();
299
300 //==========================================================================
301
306 virtual void step() override;
307
314 virtual void draw(const ::StoneyDSP::StoneyVCV::VCA::VCAWidget::DrawArgs &args) override;
315
316 //==========================================================================
317
318private:
319
320 //==========================================================================
321
326 const ::std::array<::rack::math::Vec, 4> screwsPositions;
327
332 const ::std::array<::rack::componentlibrary::ThemedScrew *, 4> screws;
333
334 //==========================================================================
335
338};
339
340//==============================================================================
341
346struct VCAModuleWidget final : virtual ::rack::app::ModuleWidget
347{
348
349 //==========================================================================
350
351public:
352
353 using DrawArgs = ::rack::app::ModuleWidget::DrawArgs;
354
355 //==========================================================================
356
364
370
371 //==========================================================================
372
377 virtual void step() override;
378
379 virtual void draw(const ::StoneyDSP::StoneyVCV::VCA::VCAModuleWidget::DrawArgs &args) override;
380
381 //==========================================================================
382
383private:
384
385 //==========================================================================
386
391 const ::rack::math::Vec size;
392
397 ::rack::app::ThemedSvgPanel *panel;
398
404
409 ::rack::FramebufferWidget *vcaModuleWidgetFrameBuffer;
410
411 //==========================================================================
412
417 ::rack::componentlibrary::RoundLargeBlackKnob *gainKnob;
418
419 // ::rack::componentlibrary::VCVLightSlider<::rack::componentlibrary::YellowLight>* gainSlider;
420
425 ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortWidget *portCvInput;
426
431 ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortWidget *portVcaInput;
432
437 ::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortWidget *portVcaOutput;
438
442 ::rack::componentlibrary::MediumLight<::rack::componentlibrary::RedLight> *lightVca;
443
444 // ::rack::componentlibrary::MediumLight<::rack::componentlibrary::GreenRedLight> *lightVca;
445
446 //==========================================================================
447
453
454 //==========================================================================
455
458};
459
460//==============================================================================
461
473 ::std::string name = "",
474 ::std::string description = "",
475 ::std::string manualUrl = "",
476 bool hidden = true
477) noexcept(false); // STONEYDSP_NOEXCEPT(false);
478
479//==============================================================================
480
482} // namespace VCA
483
484//==============================================================================
485
487} // namespace VCVRack
488
489//==============================================================================
490
492} // namespace StoneyDSP
493
494//==============================================================================
495
496#endif // defined (STONEYVCV_BUILD_VCA)
497
498//==============================================================================
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:58
StoneyDSP Modules for VCV Rack 2.
Definition StoneyVCV.hpp:105
Engine()
Definition StoneyVCV.hpp:113
The VCAEngine struct.
Definition VCA.hpp:95
T lastGain
Definition VCA.hpp:136
void setGain(const T &newGain)
void processSampleSimd(::StoneyDSP::SIMD::float_4 *v)
void processSample(T *sample) override
T gain
Definition VCA.hpp:130
The VCAModuleWidget struct.
Definition VCA.hpp:347
virtual void step() override
Advances the module by one frame.
::rack::componentlibrary::RoundLargeBlackKnob * gainKnob
Definition VCA.hpp:417
::StoneyDSP::StoneyVCV::VCA::VCAWidget * vcaWidget
Definition VCA.hpp:403
::rack::app::ThemedSvgPanel * panel
Definition VCA.hpp:397
virtual void draw(const ::StoneyDSP::StoneyVCV::VCA::VCAModuleWidget::DrawArgs &args) override
::rack::app::ModuleWidget::DrawArgs DrawArgs
Definition VCA.hpp:353
::rack::componentlibrary::MediumLight<::rack::componentlibrary::RedLight > * lightVca
3mm LED showing a smoothed CV value.
Definition VCA.hpp:442
::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortWidget * portCvInput
Definition VCA.hpp:425
::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortWidget * portVcaOutput
Definition VCA.hpp:437
::rack::FramebufferWidget * vcaModuleWidgetFrameBuffer
Definition VCA.hpp:409
VCAModuleWidget(::StoneyDSP::StoneyVCV::VCA::VCAModule *module)
Construct a new VCAModuleWidget object.
virtual ~VCAModuleWidget()
Destroys the VCAModuleWidget object.
::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPortWidget * portVcaInput
Definition VCA.hpp:431
bool lastPrefersDarkPanels
Definition VCA.hpp:452
const ::rack::math::Vec size
Definition VCA.hpp:391
The VCAModule struct.
Definition VCA.hpp:149
virtual ~VCAModule() noexcept
Destroy the VCAModule object.
::rack::engine::Module::ProcessArgs ProcessArgs
Definition VCA.hpp:207
@ BLINK_LIGHT
Definition VCA.hpp:174
@ GAIN_PARAM
Definition VCA.hpp:158
@ VCA_INPUT
Definition VCA.hpp:163
@ CV_INPUT
Definition VCA.hpp:164
VCAModule()
Construct a new VCAModule object.
IdxOutputs
Definition VCA.hpp:168
@ VCA_OUTPUT
Definition VCA.hpp:169
The VCAWidget struct.
Definition VCA.hpp:278
::StoneyDSP::StoneyVCV::ComponentLibrary::ThemedPanelWidget::DrawArgs DrawArgs
Definition VCA.hpp:284
const ::std::array<::rack::componentlibrary::ThemedScrew *, 4 > screws
Definition VCA.hpp:332
const ::std::array<::rack::math::Vec, 4 > screwsPositions
Definition VCA.hpp:326
virtual void step() override
Advances the module by one frame.
virtual void draw(const ::StoneyDSP::StoneyVCV::VCA::VCAWidget::DrawArgs &args) override
Draws the widget to the NanoVG context.
virtual ~VCAWidget()
Destroys the VCAWidget object.
VCAWidget()
Construct a new VCAWidget object.