22class LFOProcessor ::TypeParameter final : public AudioParameterChoice
33{
44public:
5- TypeParameter ( ) :
5+ TypeParameter (LFOProcessor& p ) :
66 AudioParameterChoice (ParameterID (" type" , 1 ), TRANS (" Type" ), getChoices(),
7- static_cast <int > (LFOProcessor::LFOType::sine))
7+ static_cast <int > (LFOProcessor::LFOType::sine)),
8+ parentProc (p)
89 {
910 }
1011
12+ void valueChanged (int ) override
13+ {
14+ parentProc.setLFOType (parentProc.getLFOType (), true );
15+ }
16+
1117private:
18+ LFOProcessor& parentProc;
19+
1220 static StringArray getChoices ()
1321 {
1422 StringArray choices;
@@ -18,6 +26,7 @@ class LFOProcessor::TypeParameter final : public AudioParameterChoice
1826 choices.add (NEEDS_TRANS (" Triangle" ));
1927 choices.add (NEEDS_TRANS (" Ramp" ));
2028 choices.add (NEEDS_TRANS (" Sawtooth" ));
29+ choices.add (NEEDS_TRANS (" Square" ));
2130 choices.add (NEEDS_TRANS (" White Noise" ));
2231 choices.add (NEEDS_TRANS (" Pink Noise" ));
2332 choices.add (NEEDS_TRANS (" Blue Noise" ));
@@ -39,7 +48,7 @@ LFOProcessor::LFOProcessor (double minFreqHz, double maxFreqHz,
3948
4049 auto layout = createDefaultParameterLayout ();
4150
42- auto tp = std::make_unique<TypeParameter>( );
51+ auto tp = std::make_unique<TypeParameter> (* this );
4352 type = tp.get ();
4453 layout.add (std::move (tp));
4554
@@ -121,7 +130,7 @@ void LFOProcessor::prepareToPlay (const double newSampleRate, const int samplesP
121130
122131 if (isFirstRun)
123132 {
124- setLFOType (static_cast <LFOType> (type-> getIndex () ), true );
133+ setLFOType (getLFOType ( ), true );
125134 isFirstRun = false ;
126135 }
127136}
@@ -138,6 +147,9 @@ void LFOProcessor::process (dsp::Oscillator<FloatType>& osc,
138147 doubleOsc.setFrequency (v);
139148 }
140149
150+ if (isBypassed ())
151+ return ;
152+
141153 if (isMultiplying)
142154 {
143155 multer.setSize (buffer.getNumChannels (), buffer.getNumSamples (), false , true , true );
@@ -147,7 +159,6 @@ void LFOProcessor::process (dsp::Oscillator<FloatType>& osc,
147159
148160 {
149161 dsp::ProcessContextReplacing<FloatType> context (abMulter);
150- context.isBypassed = isBypassed ();
151162 osc.process (context);
152163 }
153164
@@ -158,7 +169,6 @@ void LFOProcessor::process (dsp::Oscillator<FloatType>& osc,
158169 {
159170 dsp::AudioBlock<FloatType> audioBlock (buffer);
160171 dsp::ProcessContextReplacing<FloatType> context (audioBlock);
161- context.isBypassed = isBypassed ();
162172 osc.process (context);
163173 }
164174}
0 commit comments