Tempo sync'd LFO?

How would one go about doing a Tempo sync’d LFO with juce? more specifically, if I want a sample accurate tempo sync’d oscillator (e.g LFO), whats the best way so it maintains its sync with the host without drift. Cheers!

Take a look at AudioPlayHead class. With it you can get information about the current tempo and ppq position in the host app. You can obtain these values in your processBlock() method and with some simple calculations you will get the moments when the LFOs should be synced.


Could someone give me the mathh for this. I’m using the EJuce LFO class, it has three methods
setRate() [in Hz] setSampleRate() and tick(). I understand when to call setSampleRate but what rate in Hz should i set and how often (based on what?) should i call tick() to calculate the next LFO value.

there is a lot of JUCE code out there, i’m sure someone has written something like that already. an example will be enough really :slight_smile: i just can’t picture this, all those numerators and denominators and ppqs. i was always bad at dsp.