Cabbage Logo
Back to Cabbage Site

Timing accuracy inside host

Hello :slight_smile:
That’s my first post here, I’m a happy and relatively new csound user which I mainly use in contemporary installations, sometimes related to contemporary dance shows, and few other sound utilities. Now also building vsts with cabbage for groups of friends :cowboy_hat_face: Cabbage is so nice. I’m having a problem right now that I couldn’t read about in forums.
I can’t get perfect timing accuracy inside hosts. Every synth I build gets triggered in a slighly different time than my midi notes. It happens also when no midi notes are involved and when the plugin is tracking host’s beats, like a metronome. This picture is the typical result I get when zooming close to the sample level.


Here’s also my simple testing code used to create the screenshot.

<Cabbage>
form caption("Untitled") size(400, 300), colour(58, 110, 182), pluginid("def1")
keyboard bounds(8, 158, 381, 95)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

;instrument will be triggered by keyboard widget
instr 1
aEnv linseg 1, 0.001, 0
aOut noise aEnv, 0
outs aOut, aOut
endin

</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
</CsScore>
</CsoundSynthesizer>

Using Cabbage 2.3.0 on osx 10.11, exported to vst
Tested in Reaper and Live with same results.
Tried to enable/disable PDC on each host
Tried to set ksmps to different values including 1
Tried to run envelope at audiorate
With different results, always not perfectly aligned with host’s grid.

Do you have the same behavior? :wave: :poodle:

I can’t say I’ve noticed this, but I don’t really use hosts. I’ll will take it for a test run later and see what I can see.

1 Like

It seems to me like the sample is playing before the MIDI note? I added a ksmps delay to the synth and it now seems to be correct? Can you try that? Here is the updated code I tried…

instr 1
    xtratim 1
    aEnv linseg 1, 0.001, 0
    aOut noise aEnv, 0
    aDel delay aOut, 32/sr
    outs aDel, aDel
endin

I did some work a while back to address the PDC issue, looks like I might have gone a bit too far…

Thanks for the very fasy replies! Using delay this way makes things better, however I still experience not perfectly synced rendered audio. Surprisingly the delay is not consistent in time, every note has different delay, in a range of approximately 100 samples. Reminds me of clock problems in the hardware world
:face_with_monocle: :mantelpiece_clock:

I just did some tests here too. Something is not right. Even with the extra delay it still seems to drift. I’ll file an issue for it on github so that someone might be able to offer so advice on why this is happening. It has to be related to the PDC, which Cabbage automatically adds as ksmps samples. This was always required in the past, but perhaps newer DAWs read this information in a different way. I don’t know. I’ll look into it.

Thanks :microscope:

This is a strange one. I can’t seem to identify the root of the problem. I’ll keep looking.

@raphael I think I have this fixed now. Well, it is fixed, but I’m not sure it’s the best solution. You can try the new build when it’s ready. It should be accessible from here in a half hour or so.

[edit] There was an issue with the previous build. The latest build, that is taking place now, should work fine.

Thanks a lot for this very fast fix. I’m still afk in the wild for now but I’ll be able to test it in a few days :boar:

Hi @rorywalsh, I got the chance to install and test the 6fe33e8 build (Cabbage version:2.3.56). I feel it is better but unfortunately it still is not perfectly accurate. More surprisingly I still get a different latency for each triggered event.


I hope we’ll be able to solve this, too bad my dev skills are not sufficient to help. Have a nice day

That’s odd. In my tests things were spot on. Let me double check that we’re using the same version…

I just tested with the latest version, 2.3.56, and here is what I see. What ksmps are you using? I was testing with ksmps = 32

Thank you for your time. I was updating my vsts the wrong way, I guess it’s not a good idea to edit a csd file directly inside the vst bundle? I also switched from 2.3.56 to 2.3.57
I now have way better latency compensated audio bounces. Still the only way I found to get perfect per-sample accuracy was to set ksmps to 1, causing higher cpu needs. This is probably an expected behaviour?

ksmps = 1

ksmps = 32

Yeah, this is expected. Not ideal, but there is no way to work around it. Btw, there is no problem editing csd files contained within plugin bundles, but if you need to update Cabbage, you will have to export again.