Hello, I’m trying to implement a tremolo plugin.
I use the LFO class from IPlug2 but I don’t understand how to assign a tempo.
The effect works when the rate is in Hz.
If the mode is switch to BPM, it seems to be fixed at 120 BPM.
The speed changes with the « kParamLFORateTempo ».
At the beginning of « ProcessBlock » of the LFO Class, I set the tempo variable at 190. or 40, but it doesn’t seem to change anything.
Lfo function :
/* Block process function */
void ProcessBlock(T* pOutput, int nFrames, double qnPos = 0., bool transportIsRunning = false, double tempo = 120.)
{
tempo = 200;
T oneOverQNScalar = 1./mQNScalar;
T phase = IOscillator<T>::mPhase;
if (mRateMode == ERateMode::kBPM && !transportIsRunning) {
IOscillator<T>::SetFreqCPS(tempo / 60.);
}
double samplesPerBeat = IOscillator<T>::mSampleRate * (60.0 / (tempo == 0.0 ? 1.0 : tempo)); // samples per beat
T phaseIncr = IOscillator<T>::mPhaseIncr;
for (int s=0; s<nFrames; s++)
{
double sampleAccurateQnPos = qnPos + ((double) s / samplesPerBeat);
if(mRateMode == ERateMode::kBPM)
{
if(transportIsRunning)
phase = std::fmod(sampleAccurateQnPos, oneOverQNScalar) / oneOverQNScalar;
else
phase = WrapPhase(phase + (phaseIncr * mQNScalar));
}
else
phase = WrapPhase(phase + phaseIncr);
pOutput[s] = DoProcess(phase);
}
IOscillator<T>::mPhase = phase;
}