AudioPlayHead sample

Hi,

I need to implement my own play head and was wondering if anyone has done that before, since its behaviour would be quite standard.

If not, I’m planning to update my play head within a Timer callback. Would that be a good choice? I was not sure because I have read somewhere this timer can fluctuate, and also its granularity is of milleseconds, which may not be sufficient if we have high BPMs and say a PPQ of 960.

Thanks for your feedback.

Mariano

What are you actually trying to do…?

If you’re just implementing the AudioPlayHead interface, then your class doesn’t need to have any kind of timer - it could just calculate the values it needs when the getCurrentPosition() method is called, based on the system clock or whatever you’re using in your app.

Oops, you’re right. I was thinking to populate the play head in a thread and then the getCurrentPosition() could retrieve its current value, but in fact I only need its value when getCurrentPosition() is called. I guess it could be different if I wanted to have a smooth progress bar on the screen, but this is not the case anyway.

So I’ll probably need to keep accurate timing of start and/or BPM changes. What clock function would you recomment (ideally cross platform)?

Thanks.

Mariano

Time::getMillisecondCounterHiRes() will give you plenty of accuracy, or just getMillisecondCounter() if you only need it to within 1 or 2ms.

Great, thanks. You saved me again lot of trouble going into a wrong direction :slight_smile: