Cabbage Logo
Back to Cabbage Site

Midi out timing

I’ve run into an odd problem with the timing of midi out from Cabbage.
When I use Csound/Cabbage to generate fast midi notes, it seems the note offs have some odd quantiziation. The note ons have correct timing as far as I can see, but the note offs are misplaced in a manner that looks like time quantization.

If I set the tempo low (say 5 notes per second), it sounds ok, but with tempos above 10, it sounds as if I’m missing some of the notes. When I record the midi output, I see that I do indeed have all the notes, but some of the note durations have become very short.
Here’s a pianoroll view of the recorded midi from Csound/Cabbage, and also the csd I’ve used.

midi_speednote.csd (5.3 KB)
The csd has 4 voices of this mechanism, but I did also simplify it to make sure it was not a coding kludge from me that made the issue pop up. Also tried other methods of midi out (using the midiout opcode, triggered in various ways etc).

I’ve tested running Csound offline and creating a midi file with --midioutfile=“filename.mid”
This creates a midi file with correct note offs.
Also, if I take this as a midi item in Reaper, and just scale the time, so it plays at a faster speed, the note offs are also good.
So it is somehow related to the realtime communication between the DAW and the plugin. Not sure if the problem is with Cabbage or if it is the DAW quantizing to audio buffer boundaries. Just so strange that the note ons are not affected, just the note offs.

Any clues appreciated.
All best
Øyvind

Hi Oeyvind, I had a look through the source code, and I can see that incoming and outgoing buffers are not treated in the same way. I’ve have a look and see if I can’t find a quick fix.

[edit] New build underway. I won’t have time to test it here, but it should be cooked in an hour or so and available from Azure DevOps in the usual place. Let me know if this works. I must add your test to the Cabbage3 tests too, to make sure it also works there.

Thanks for the update. Yes, it seems better. Still some note-offs that are offset in time, but it now seems to tolerate higher tempi or shorter notes before starting to crack. But now, when it fails it prolongs the midi notes until the next note on (where before it would shorten the note to have zero duration).

Setting a lower ksmps seems not to make a difference (?)

Sorry for my latency, I did not get an email notice that you had replied (but the forum says I will be notified of updates to this thread… also checked my email filters but did not find anything).

Hi @Oeyvind I’ve just pushed another attempt fix. It will be ready in a bit. As for missing emails, I wonder if you only get notified when I ping you in the message? If you get a notification about this one we’ll know that’s key :+1:

Hi @rorywalsh
Excellent. What is changed in the new fix?
The email thing is odd. I did not get any email this time either. The last time I got something from Cabbage (mail@cabbageaudio.com) was 18th July…

Hopefully this issue:

But I didn’t have time to test, so if you wouldn’t mind doing the honors :slight_smile:

Halleluja @rorywalsh, yes! Now I can do 50 notes per second with proper note-offs :smiley:

Nice one. So let me guess, you’re planning on loading 200+ instances of a Cabbage plugins into Reaper with each producing 50 notes per second :rofl:

haha, no did not think of that one … until now :slight_smile:
But I’m trying to control the air flow to a midi controllable acoustic pipe organ that only have on/off on the air valves. So I imagined I could do some sort of PWM, opening and closing them fast. Initial experiments shows that it does not result in what I had expected, but other interesting things happens :wink:

You never fail to surprise with your inventiveness :rofl: