Cabbage Logo
Back to Cabbage Site

Host_ppq_pos

HOST_PPQ_POS Return the position of the start of the last bar, in pulses-per-quarter-note.”

How many pulses is this? Does it reset to 1 at each beat? Bar? Song start? Do different DAWs do it differently?

In Logic this just looks like a counter of quarter notes that starts at 0 and keeps climbing. I’m obviously missing something …

Your observation is correct, it’s the docs that are wrong. This returns the current play position in quarter notes.

Oh … hmmm. I’m hoping to synchronize actions from mouse clicks to the nearest quarter/eighth/sixteenth or similar. I had thought this would be a pathway to doing that. Is there a midi clock signal I should use instead?

What’s tricky about this is the fact that the host will process a block of sample at a time. And within that block it will schedule any MIDI event that need to take place at some point within that block, for example it might schedule a midi note one to take place 18 samples in. Any of the playhead info you retrieve will only be available once per block. TIME_IN_SAMPLES will give you the best resolution clock, but it will also jump by ksmps on each k-cycle. You could also use IS_PLAYING to determine when an instrument starts, and construct your own timer within Csound, but keep in mind, this info will also be restricted to a block boundary. If the user somehow presses play in the middle of the a processing block, you won’t get that info until the next k cycle. In practical terms the maximum delay is about 4ms. It’s all about finding the best balance I guess.

If you really need sample accurate timing* within Cabbage, you’ll need to set ksmps to 1.

  • MIDI events are sample accurate - the playhead info is not…