Cabbage Logo
Back to Cabbage Site

Csound options for midiout

I am using a KORG nanoKONTROL2 controller and wanted to control the LEDs from an instrument by midiout. I did not get this to work, so I wrote a small test file:

form caption("Untitled") size(400, 300), guiMode("queue"), pluginId("def1")
keyboard bounds(8, 158, 381, 95)


; These options allow controlling the LEDs but do not trigger instrument 1 from MIDI:
; -n -d -M0 -m0d -Q2
; Standard Cabbage options: trigger the instrument, but don't control the LEDs:
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5


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

;instrument will be triggered by keyboard widget
instr 1
kEnv madsr .1, .2, .6, .4
aOut vco2 p5, p4
outs aOut*kEnv, aOut*kEnv

instr 99

kstatus, kchan, kdata1, kdata2 midiin
if kstatus!=0 then
  printks "Status: %i, Channel: %i, Data1: %i, Data2: %i\n", 0, kstatus, kchan, kdata1, kdata2

midiout 176, 7, 32, p4



i99 0 1 127
i99 1 100 0


There is one MIDI-playable instrument (1) and another one (99) which is played from the score and should switch an LED on/off by midiout. The latter also monitors all incoming MIDI messages by midiin and prints them to the console.

What I noticed is that if I use the standard Cabbage options for Csound instrument 1 plays but the LED is not activated. (I checked that in the Cabbage settings MIDI Output is set to “nanoKONTROL2 1 CTRL”.) But the midiin works.

After some fiddling I found that removing -+rtmidi=NULL from the options and adding -Q2 for assigning the MIDI output lets me control the LED. But then instrument 1 cannot be played from MIDI anymore.

I tried to find a combination of options which work for both with no avail.

[I am not sure whether this is really a bug. I don’t fully understand the MIDI assigment mechanisms of Csound and Cabbage. So it may simply be that I am not using the right options.]

The Cabbage IDE does not output MIDI. If you remove the -+rtmidi=NULL, then you are asking Csound to output MIDI directly, which means that it will no longer behave correctly in Cabbage. Best might be to do this through a host that can output MIDI.