Greetings! I have found MPE to work fairly well with Csound/Cabbage–I am using a roliu seaboard (1st gen) on a Mac. Here is a relatively simple MPE flute instrument that uses the roli XY pad for modulation effects and incorporates polyphonic aftertouch:
form caption("MPE flute") size(400, 300), guiMode("queue"), pluginId("MPE2")
button bounds(345,5,47,25) channel(“record”) text(“Record”,“Stop”) colour(“red”) fontColour(“white”)
combobox bounds(345,35,47,15) channel(“recch”) value(2) text(“mono”,“stereo”)
combobox bounds(345,55,47,15) channel(“bit”) value(1) text(“16-bit”,“24-bit”,“32-bit”)
button bounds(345,75,47,25), channel(“play”) text(“Play”) colour(“green”) fontColour(“white”)
combobox bounds(5,35,100,20) channel(“xysel”) items(“sine”,“triangle”,“bipolar square”,“unipolar square”,“saw up”,“saw down”) value(1)
label bounds(110,35,100,15) channel(“t2”) text(“Mod Select”) fontColour(“white”)
nslider bounds(5,65,50,23) channel(“xmax”) range(0,60,48,1,.1)
label bounds(60,67,150,15) channel(“t3”) text(“Mod Width Max (X)”) fontColour(“white”)
nslider bounds(5,95,50,23) channel(“ymax”) range(0,250,100,1,.1)
label bounds(60,97,150,15) channel(“t4”) text(“Mod cps Max (Y)”) fontColour(“white”)
nslider bounds(5,125,50,23) channel(“xyport”) range(0.001,.1,.01,1,.001)
label bounds(60,127,150,15) channel(“t5”) text(“Mod cps Max (Y)”) fontColour(“white”)
keyboard bounds(8, 198, 381, 95)
-n -d -+rtmidi=NULL -M0 --midi-key=4 --midi-velocity-amp=5 ;-+raw_controller_mode=1 ;was supposedto make ctrl 113 and 114 work butit didn’t
; Initialize the global variables.
ksmps = 32
nchnls = 2
0dbfs = 1
alwayson 1
alwayson 20
alwayson 750
massign 0,10 ;assigns all incoming MIDI channels to instr 1
gkx,gky init 0
gaout init 0
gichnls init 0 ;globals for soundfile table loading
giReady init 0
gkTabLen init 2
giTable init 501
gkRecordingActiveFlag,gkFileRecorded init 0
instr 1 ;live audio input and record/play control
gkrecord chnget “record”
gkplay chnget “play”
kRecStart trigger gkrecord,0.5,0
if kRecStart==1 && gkRecordingActiveFlag==0 then
event “i”,600,0,-1
gkRecordingActiveFlag = 1
endif
kPlayStart trigger gkplay,0.5,0
if kPlayStart==1 && gkFileRecorded==1 then
event “i”,601,ksmps/sr,3600
endif
endin
instr 10
kxmax chnget “xmax”
kymax chnget “ymax”
kxysel chnget “xysel”
kenv madsr .05, .2, .8, .2
kY midictrl 74,0,1 ;grabs incoming Y values and maps to .5-1 floating point values
kY port kY,.01 ;maybe map these to a filter instead? or make choices for mappings of the controller
kbend pchbend 0,48 ;this provides pitch bend in semitones mapped in direct correlation with roli keys
;24 would be half the deviation, 96 twice the deviation
kaft aftouch 0,1
klfo1 lfo gkxkxmax,gkykymax,0 ;amp (MIDI), cps, [wave] 0=sine, 1=triangle, 2=bipolar square, 3=unipolar square, 4=saw up, 5=saw down
klfo2 lfo gkxkxmax,gkykymax,1
klfo3 lfo gkxkxmax,gkykymax,2
klfo4 lfo gkxkxmax,gkykymax,3
klfo5 lfo gkxkxmax,gkykymax,4
klfo6 lfo gkxkxmax,gkykymax,5
if kxysel=1 then
klfo=klfo1
elseif kxysel=2 then
klfo=klfo2
elseif kxysel=3 then
klfo=klfo3
elseif kxysel=4 then
klfo=klfo4
elseif kxysel=5 then
klfo=klfo5
elseif kxysel=6 then
klfo=klfo6
endif
aout wgflute kaftkaft,cpsmidinn(p4+kbend+klfo),(kY.4)+.1,.1,.1,kY*.1,0,0 ;gky100,gkx24
aout dcblock2 aout
aout=aout*kenv
outs aout,aout
gaout=aout+gaout
endin
instr 20 ;instrument always on to sense non-note-specific MIDI controller values coming in on channel 1
kxyport chnget “xyport”
kstatus,kchan,kdata1,kdata2 midiin
if kstatus==176 then
if kdata1==113 then
kx=kdata2/127 ;mapsx-y pad x value to 0-1
gkx portk kx,kxyport
elseif kdata1=114 then
ky=kdata2/127 ;mapsx-y pad y value to 0-1
gky portk ky,kxyport
endif
endif
endin
instr 600 ; record file
irecch chnget “recch”
ibit chnget “bit”
print p1
if gkplay==1 then
chnset k(0),“record”
turnoff
endif
gkFileRecorded init 1
itim date
Stim dates itim
itim date
Stim dates itim
Syear strsub Stim, 20, 24
Smonth strsub Stim, 4, 7
Sday strsub Stim, 8, 10
iday strtod Sday
Shor strsub Stim, 11, 13
Smin strsub Stim, 14, 16
Ssec strsub Stim, 17, 19
Sfilnam sprintf “%s_%s_%02d_%s_%s_%s.wav”, Syear, Smonth, iday, Shor,Smin, Ssec
gSname sprintf “MPEflute_%s”, Sfilnam
if gkrecord==1 then ; record
if ibit=1 then
imode=4
elseif ibit=2 then
imode=8
elseif ibit=3 then
imode=5
endif
if irecch=1 then
fout gSname,imode,gaout
elseif irecch=2 then
fout gSname,imode,gaout,gaout
endif
endif
gkRecordingActiveFlag = 1 - release()
endin
instr 601 ; play file
if gkplay==0 then
turnoff
endif
ichn filenchnls gSname
if ichn=1 then
aL diskin2 gSname,1
outs aL,aL
else
aL,aR diskin2 gSname,1
outs aL,aR
endif
iFileLen filelen gSname
p3 = iFileLen
xtratim 0.1
krelease release
chnset 1-krelease,“play”
endin
instr 750 ;clear global audio paths that include feedback (don’t need to clear the global LFO outputs)
clear gaout
endin
;causes Csound to run for about 7000 years...
f0 z
Widgets
100
100
320
240
true
240
240
240