Cabbage Logo
Back to Cabbage Site

Host info update frequency

Writing a plugin that uses host info to place events in a bar I noticed that the precision was less than the expected ksmps/sr. I could track this down to HOST_PPQ_POS not being updated every k-cycle. I attach a reduced version of the plugin which prints the values in a csoundoutput window each k-cycle as long as IS_PLAYING. The same happens with TIME_IN_SECONDS.

Is there anything I am doing wrong or does it really only update every 11.61ms (which is 16x 32/44100Hz, so every 16th k-cycle)? Could the host (REAPER) be the reason? Can that
frequency be increased? (preferentially without decreasing ksmps) (3.8 MB)

It should update on every k-cycle? I’ll check this later and get back to you…

Thanks for looking after this! I just made a test with Waveform 12 to make sure that it is not a problem only with REAPER. The same thing just that HOST_PPQ_POS and TIME_IN_SECONDS are updated every 8th instead of every 16th k-cycle.

I’ll run some tests and let you know, but it won’t be before Monday :+1:

I took a quick look at this and I am also seeing some inconsistent results. I didn’t have time today to go into it in any depth, but will take another look tomorrow.

So the underlying function to pass host data to the plugin is only called once per process block. If your ksmps is smaller than the host buffer size, then it will create some issues. If it happens to be the case that ksmps is 32, while the host buffer is 64, it will look like the info is only updating on every second k-cycle.

I think the update rate will match whichever has the largest buffer size. It’s not great, but I’m not sure how to resolve it.

Dear Rory, thanks for looking for this. I guess you are right. Among the zillion settings REAPER allows, I found one: Buffers 4 x 512 samples. 512 samples is just 11.61 ms. So it seems that REAPER only updates the timing values when one buffer is finished. I checked 4x256, and indeed I get updates every 8 k-cycles instead of 16. Probably all DAWs work that way, just that Waveform has another buffer size. I don’t think that this justifies reducing the DAW buffer to get the HOST_PPQ_POS updated more often. Rather, I will look for a way to interpolate the time in between from the csound clock. I will post the plugin when I’m finished with it.

1 Like

I did some programming and the result is mixed:

The good news: With a code like the one attached you can ‘interpolate’ between the HOST_PPQ_POS values received from the host so that Cabbage/csound is always aware of the real position in the host’s score with a precision of ksmps/sr.

ppqpostest.csd (1.1 KB)

The bad news is that with REAPER it still does not work because REAPER seems to transmit MIDI note-on signals only with the above mentioned resolution of 11.61 ms. So it does help that Cabbage sends out the MIDI with perfect timing if that is spoiled in the effect chain.

Interestingly, this seems to work better for REAPERS ‘JS’ plugins which are based on a programming language EEL2 Cockos devised for that purpose. I checked this with the JS MIDI Transpose plugin which comes with REAPER and that reproduces to <0.1ms the timing of the incoming MIDI. That would not be possible if it had the same limitations a Cabbage (and presumably VST3 in general) plugin obviously has.

But I don’t want to rewrite my project in EEL2. Firstly, I’m too lazy to learn another language (although it does not seem to be very different from C). Secondly, I would prefer to publish plugins as VST3 and not some stuff which only works in REAPER.

PS: It seems that they (Cockos) are aware of the problem since years. Here is one of the recent posts:

To me it is unacceptable that the audio buffer still influences the midi timing even when attempting a mere midi thru with a midi controller.


I need to use higher buffer settings because Reaper starts to pop and crackle on anything lower than 128 samples (while 128 and higher cause already an unacceptable midi delay for me).

But in the next post someone explains how complicated it is to fix this. So it my take a couple of years more.

Nice detective work. It’s a pity Reaper falls short here, because in so many other ways it’s a great DAW :frowning: