Cabbage Logo
Back to Cabbage Site

MidiOut vs OSC

My Cabbage midi2osc plugin works. I can trigger notes in a stand-alone Python Pyo synth via OSC. But it is a bit slow. I wonder if using midiOut would be faster?
Here is the code of my plugin, BTW:

form caption(“Midi2OSC”) size(400, 300), colour(58, 110, 182), pluginid(“def1”)



-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5


; Initialize the global variables.
ksmps = 32
nchnls = 2
0dbfs = 1

massign 0,12

instr 12
mididefault 60, p3
midinoteonkey p4, p5
ikey init p4
iVel init p5

kDur        timeinsts          ; running total of duration of this note
kRelease    release            ; sense when note is ending
;print ikey,iVel
OSCsend     1, "localhost",8000, "/midi/note", "ii", p4, iVel
if kRelease=1 then            ; if note is about to end
    ;printk2 kDur
    OSCsend     1, "localhost",8000, "/midi/note", "ii", p4, 0
endif

endin

;causes Csound to run for about 7000 years... f0 z

And here is the Pyo program:

from pyo import *
s = Server().boot().start()

def receiveMidiMessages(address, *args):
# 144 is a noteon, args are pitch and velocity
# print(address, args)
s.addMidiEvent(144, args[0], args[1])

rec = OscDataReceive(port=8000, address="/midi/note", function=receiveMidiMessages)

notes = Notein(poly=10, scale=1, first=0, last=127, channel=0, mul=1)
amps = Port(notes[“velocity”], risetime=0.005, falltime=0.5, mul=0.1)

sigL = RCOsc(freq=notes[“pitch”], sharp=0.5, mul=amps)
sigR = RCOsc(freq=notes[“pitch”]*1.003, sharp=0.5, mul=amps)

outL = sigL.mix(1).out()
outR = sigR.mix(1).out(1)

s.gui(locals())
Richard

If you’re sending MIDI to another plugin in a DAW then I assume MIDI will be quicker.

Apparently I have to use the OS X IAC driver to somehow connect the midi out from my Cabbage plugin to the midi synth on the other end. How do I force Csound/cabbage to use the IAC bus?

It can’t. The Cabbage ide does not support midi out. In this case OSC is the best bet. Or else try hosting a Cabbage plugin in a DAW that supports midi out?

I am trying Reaper now. I read from you that plugins do support midi out?
It works great with Reaper now. I could make the Cabbage UI to select midi and/or OSC…

1 Like