Audio play head and ppqn


#1

Im trying to implement a timer that continuously updates the data of an audio play head, but I have some problems for example in a 60bpm song you get that every quarter note lasts 1000 milliseconds  and if you want to use a high resolution ppqn value like 960; you get 1.041666 milliseconds for every pulse. So my problem is if I double that tempo to 120 bpm I get half of 1.041666 milliseconds and juce timer class can´t handle values lower than 1 milliseconds. So my question is what's the way to implement this, or what I'm doing wrong?


#2

Hi BK8, 

JUCE's Timer class is not for high-precision timing. In fact, the Timer class will make absolutely no guarentee if the time interval is met at all. This is because the Timer's callback is always called on the main message thread and a previously delivered message may have taken an unusal long time to process.

I'm not sure how your program is structured, but generally, you should be using an audio callback (for example processBlock) for low-latency audio. Within this callback you can use getPlayHead to get accurate timing information and then trigger your audio when needed.


#3

Thanks, yes I finally understand how to update an audio playhead. The way you described is the same the guys from justice used in jost. Really thanks, and sorry for the late reply.