Cabbage Logo
Back to Cabbage Site

MIDI transformation possibilities in cabbage and csound

Hello everybody!

I’m working currently on a new performance system where i write algorithmically midi files in common lisp, load them into ableton live and then trigger my beautiful cabbage-csound instruments. so far so good.

but now i’m wondering how i can transform my midi files / tracks / output in a performance situation in real time. like gradually delaying the midi output to the instrument, or transposing the midi output by some defined parameters.
i’m wondering what possibilities there are, with what you experimented so far? to get some ideas and inspiration from you.

also i tried to export and use the midi examples out of cabbage. but none of them worked in my environment. i exported them als vst3 synth. how do i have to handle / export plugins for this usecase? is there something else i have to think about when developing my ideas for this?


Hi @ph_ne, I think the first step is to figure out why you can’t get any MIDI output. I don’t use Live but I just tested the MIDI Arp example in Reaper and it works as expected. Also, have you tried with the a VST2 export?

With regards to your first question, the possibilities are somewhat endless. If you can output your own MIDI stream you can do what you like with it.

I dusted off my copy of Live and tried that simple arp example I mentioned. At first I couldn’t get it to work because I’m a Live idiot. But I dug up this old thread and was able to get it to work fine. Seems Rory of the past posted this for future Rory because he knew it wouldn’t be the only time he’d get stuck trying to route MIDI in Live :slight_smile:

Hey Rory, thanks for your reply!
I started to get my head around this (i still can’t use the MIDI examples, but my own stuff is working - i forgot the -Q flag).

Right now i’m wondering if this is possible:

  • creating a VST which has a button to load a midi-file (the problem could be, that midi files has to be loaded in the flag area - or can i do it in another way?)
  • playing back the midi file while modifying the output - especially i want to change the playback speed of the midi file during the playback

I don’t have much experience with playing back midi files and i’m wondering if this is possible.

Not out of the box in Csound, but Cabbage has you covered. These opcodes are relatively untested, so let me know if you have any issues with them. You’ll need a recent beta build to test them.

Great! I will try it out and share my results! If this will work my musical dreams will come true!

sadly i have the feeling that this (cabbageMidiFileReader) is not running stable as vst export. i tried this midi-file-player-001.csd (2.2 KB) .csd as vst3 in reaper and ableton and both are crushing, when i start the playback. Do you already have experience with this as vst export?

I don’t think I’ve yet tested it in a vst, but I will when I get a chance. Probably won’t be until next week though as I’m away at the moment. I’ll let you know what I find. I’m sure we can find a solution. :+1:

I have some more information for debugging:
it’s also crashing when i use it in a modified version inside cabbage. it’s running till i want to start the playback of the midi file. init of the instrument is working.
I’m on the latest cabbage version.

Can you send me the modified version, and does it crash with all midi files? If not can you send me the files it does crash with? As I mentioned earlier, these opcodes are relatively untested, so I appreciate your help, and patience in testing them :pray:

I tested it now with MIDI files, that are not generated by me and there it works. At least with the cabbage version: midi-file-player-002.csd (2.0 KB)

And this is one of the MIDI files which will create a crash: (2.0 KB)

Hi @ph_ne, I don’t get any crash here, but I do get some errors printed to the console. What OS are you on?

The problem here is that the MIDI file contains only one track, and you were passing track index 1 to the opcode. Maybe passing a track index is not so intuitive? Maybe track number is better? Either way, if you change the track index to 0 it runs. I’ve also adding an perf error if users try this in the future.

But, the output from the instrument is pretty awful, but that’s something on my end. It seems that far too many events are being sent. I’m looking into it now. :+1:

Using track index 0 solves the crashes. Also in Reaper is this Version running midi-file-player-001.csd (2.9 KB) and gives midi ouput. But the output is really terrible.

In Ableton i don’t get output with the same vst. But the cpu is spiking up to 50% just running this one vst.

EDIT: I’m on MacOSX 13.4

You should disable printing numEvents. That’s not doing the performance any favours. I see the problem now, I’m looking for a fix. It also explains the CPU spike…

[edit] FWIW - there are way too many events being fired off, hence the terrible audio and CPU spike…

Will do it. Was just for debugging reasons.

But there must be a solution for this, or not? DAW intern playing midi files like this or in other applications are normally no problem.

Of course there is a solution. I just want to find the best one :+1:

I just triggered a new build. Things look and sound a lot better now, and the CPU is also way down on the previous iteration. The new build will take an hour or so to complete. Let me know if it works better for you. :+1:

Rory, amazing!

No crushes anymore, the playback is very good and my cpu stays down! I’m testing it with synchronous playback of the same midi file in the DAW and i notice just a minimal delay, even at all!

Very great! I was scared that i have to use Max for this…

BTW: what would be also great for this opcode would be, that the playback can be reset to start by a trigger.