Krotos Modules 3
Loading...
Searching...
No Matches
Kwidget_AudioOut.cpp
Go to the documentation of this file.
1namespace krotos
2{
3 const String Kwidget_AudioOut::Parameters::Volume = "Volume";
4 const String Kwidget_AudioOut::Parameters::Mute = "Mute";
5 const String Kwidget_AudioOut::Parameters::Autoplay = "Autoplay";
6 const String Kwidget_AudioOut::Parameters::AutoplayVisibility = "AutoplayVisibility";
7 const String Kwidget_AudioOut::Parameters::FXActivation = "FXActivation";
8
9 Kwidget_AudioOut::Kwidget_AudioOut(const String& kwidgetID) : Kwidget("AudioOut", kwidgetID)
10 {
11 init();
12 // Only in the special case of an audio out with ID "Master" do we add the AutoplayVisibility parameter &
13 // FXActivation
14 if (getKwidgetID() == "Master")
15 {
16 createAndAddCustomParameter(Parameters::AutoplayVisibility, true); // Create with an initial value of true
17
18 addParameterCallback(Parameters::FXActivation, [this](float newValue) { fxActivationChange(newValue); });
19 }
20 }
21
22 std::vector<Kwidget::ParameterInfo> Kwidget_AudioOut::createParameters()
23 {
24 using P = Parameters;
25
26 // Only in the special case of an audio out with ID "Master" do we add the autoplay parameter
27 if (getKwidgetID() == "Master")
28 {
29 std::vector<Kwidget::ParameterInfo> parameters = {
30 {P::Volume, P::Volume, {-96.0f, 12.0f, 1e-2f, DSPConstants::defaultSliderSkew}, 0.0f},
31 {P::Mute, P::Mute, {0.0f, 1.0f, 1.0f}, 0.0f},
32 {P::Autoplay, P::Autoplay, {0.0f, 1.0f}, 0.0f},
33 {P::FXActivation, P::FXActivation, {0.0f, 1.0f}, 0.0f}
34 // DO NOT ADD OR REMOVE ANY PARAMETERS HERE
35 // KST-1903 This is due to a backwards compatibility issue with static kwidget parameter allocation
36 // where new parameters in a static kwidget cause the order of existing parameters to change
37 // See
38 // https://bitbucket.org/krotos/krotos_modules_3/commits/210fc7d7462c69287d5ac50f32bc06e9996fc178
39 // Todo: Update once new solution for static kwidgets is found.
40 };
41 jassert(parameters.size() == 4); // See above comment
42 return parameters;
43 }
44 else
45 {
46 std::vector<Kwidget::ParameterInfo> parameters = {
47 {P::Volume, P::Volume, {-96.0f, 12.0f, 1e-2f, DSPConstants::defaultSliderSkew}, 0.0f},
48 {P::Mute, P::Mute, {0.0f, 1.0f, 1.0f}, 0.0f}
49 // DO NOT ADD OR REMOVE ANY PARAMETERS HERE
50 // See above comment
51 // Todo: Update once new solution for static kwidgets is found.
52 };
53 jassert(parameters.size() == 2); // See above comment
54 return parameters;
55 }
56 }
57
58 std::unique_ptr<KwidgetProcessor> Kwidget_AudioOut::createProcessor()
59 {
60 return std::make_unique<KwidgetProcessor_AudioOut>(*this);
61 }
62
63 std::unique_ptr<KwidgetGUI> Kwidget_AudioOut::createGUI() { return std::make_unique<KwidgetGUI_AudioOut>(*this); }
64
65 void Kwidget_AudioOut::addListener(Listener* listenerToAdd) { m_listeners.add(listenerToAdd); }
66
68 {
69 jassert(m_listeners.contains(listenerToRemove));
70 m_listeners.remove(listenerToRemove);
71 }
72
74 {
75 m_listeners.call([newValue](Listener& l) { l.fxActivationChanged(newValue); });
76 }
77
78} // namespace krotos
static const float defaultSliderSkew
Definition constants.h:26
Definition Kwidget_AudioOut.h:7
virtual void fxActivationChanged(float newVal)=0
std::vector< ParameterInfo > createParameters() override
Definition Kwidget_AudioOut.cpp:22
std::unique_ptr< KwidgetProcessor > createProcessor() override
Definition Kwidget_AudioOut.cpp:58
void removeListener(Listener *listenerToRemove)
Definition Kwidget_AudioOut.cpp:67
void addListener(Listener *listenerToAdd)
Definition Kwidget_AudioOut.cpp:65
void fxActivationChange(float newValue)
Definition Kwidget_AudioOut.cpp:73
Kwidget_AudioOut(const String &kwidgetID)
Definition Kwidget_AudioOut.cpp:9
ListenerList< Listener > m_listeners
Definition Kwidget_AudioOut.h:33
std::unique_ptr< KwidgetGUI > createGUI() override
Definition Kwidget_AudioOut.cpp:63
Definition Kwidget.h:8
void init()
Definition Kwidget.cpp:27
CustomParameter * createAndAddCustomParameter(const String &paramID, const var &value)
Definition Kwidget.cpp:419
const String & getKwidgetID() const
Definition Kwidget.cpp:367
void addParameterCallback(const String &paramID, std::function< void(float)> callback)
Definition Kwidget.cpp:458
Definition AirAbsorptionFilter.cpp:2
Kwidget_CoreEngine::Parameters Parameters
Definition KwidgetGUI_CoreEngine.cpp:42
static const String Mute
Definition Kwidget_CoreEngine.h:69
static const String Autoplay
Definition Kwidget_CoreEngine.h:50