Oscillator we wrote earlier and set it to a low frequency.private : Oscillator mLFO; double lfoFilterModAmount; lfoFilterModAmount indicates how much the LFO will affect the filter. This parameter must be initialized in the constructor in Synthesis.cpp : lfoFilterModAmount(0.1) 0.1 ? Here we just want to show the basic ease of creating an LFO. We will add individual control knobs to this oscillator later, at the redesign stage. Add to the end of the constructor: mLFO.setMode(OSCILLATOR_MODE_TRIANGLE); mLFO.setFrequency(6.0); mLFO.setMuted(false); isMuted flag is isMuted . If you add controls for the LFO to the interface, the first two functions must be called from OnParamChange . And the isMuted flag depends on whether the value of the lfoFilterModAmount parameter is equal to zero.Synthesis::Reset : mLFO.setSampleRate(GetSampleRate()); ProcessDoubleReplacing . Replace the for loop with the following: for (int i = 0; i < nFrames; ++i) { mMIDIReceiver.advance(); int velocity = mMIDIReceiver.getLastVelocity(); double lfoFilterModulation = mLFO.nextSample() * lfoFilterModAmount; mOscillator.setFrequency(mMIDIReceiver.getLastFrequency()); mFilter.setCutoffMod((mFilterEnvelopeGenerator.nextSample() * filterEnvelopeAmount) + lfoFilterModulation); leftOutput[i] = rightOutput[i] = mFilter.process(mOscillator.nextSample() * mEnvelopeGenerator.nextSample() * velocity / 127.0); } lfoFilterModulation varies from -1 to +1 . For the argument to the setCutoffMod function setCutoffMod we add the cut-off frequency controlled by the envelope and the value of lfoFilterModulation , that is, the cut is now changed by two parameters.Source: https://habr.com/ru/post/227827/
All Articles