Cabbage Logo
Back to Cabbage Site

Transient Tracking Effect for generating MIDI Notes

Hello Everybody!

I’m very curious in exploring cabbage and developing some VSTs based on my Csound Codes from the last year.

I’m struggling a bit with a transient tracking vst which should generate midi events when a trigger is generated by the transient tracking algorithm. Outside of cabbage it works perfectly fine. But i think i’m missing some things about the generation of midi events. Can someone help out and check my .csd?

Normaly i’m playing soundfiles with this transient tracking instrument. But now, when i want to generate midi events, the events are delayed and not every transient is delivering a midi event. Somewhere between kTrig and the midi event generation is a problem. I already have implemented an pre-gain for the audio source to control whats inside the vst.

I’m using it in Ableton, where i have this vst on a audio tracking. A midi track with a vsti is receiving the midi data from the audio track.

Thanks in Advance,
Philipp
transient-tracking.csd (3.2 KB)

Hi Philip.

Do you mean outside of Cabbage when you run this in Csound from the command line? Of that the general approach works Ok in another environment?

With regards to the code, I wonder why you are using an rms amplitude value to delay the signal? I’m not au fait with transient detection so perhaps this is some kind of well known trick. But I would have though an rms opcode combined with a trigger opcode would also do the trick? Anyhow, for now I’m most interested in whether this works fine from the command line version of Csound, and if so, why it doesn’t work that well in Cabbage. Btw, what version of Cabbage are you using?

Also, here is a related thread you might find useful.

Hey Rory,

the transient_tracking UDO works perfectly fine. I used it a lot in last past months for generating soundfiles via the command line.

The delaying of the rms value happens to see if the actual value is really a peak or if the last rms values are all high.

Maybe i have to start with debugging by printing the kTrig events when i use it in Ableton. But i didn’t find out yet how to do this. I hope i can do it this evening. But i’m pretty sure it has something to do with generating the MIDI signals or the signal flow in Ableton. Maybe someone else can try this as a vst in their DAW?

Greetings,
Philipp

You can add a csoundoutput widget to see your print statements. That should help determine what’s going on. Let me know if you find anything👍

Ok, i found it. Strangely it started working better when i was rising the ksmps in the UDO. Now it works perfect with ksmps on 32. Don’t know why. I have to check the transient_tracking UDO again…hmmm

Sounds like i was an issue of latency. If you want to use ksmps=1 you need to use latency(-1) in your form identifier. See here. But I think it’s best to use ksmps=32. Cabbage to notify the host about this in order to make sure things stay in sync. But wait, you global ksmps was 32? So I’m not sure why setksmps=1 in the UDO would have this affect? Anyway, I’m glad it working now, and I’m sure it’s related to this somehow, although I can say for sure why it is :laughing:

Ah, okay! i see. I’m used to work with csound from the command line, where i often create feedback loops that work sample precise via UDOs with ksmps on 1.
But i see now that this is not working with a Host like a DAW, because of their internal buffer size. Am i right?

Normally you can use different ksmps globally and inside a UDO. So you can create UDOs that are working sample precise (thats one reasons i love csound) but the rest of the .csd is not that expansive on your CPU because it’s using a bigger ksmps, the global ksmps.

You can do this with Cabbage too, no problem. You’ll see this throughout the examples. This issue seems to be how MIDI events are fired off within the plugin processing block. If you need sample accurate midi events, then you need to use latency(-1) and ksmps=1. But as you know, that comes at a cost. With ksmps = 32 you have a maximum delay of half a sample block for MIDI notes, so 16 samples. At 44.1kHz that’s about 3 milliseconds. I am not sure anyone would even notice this.