Since I helped someone out with this topic today, I would like to append something to this topic for the sake of completeness. It is also possible to send a list of notes to TidalCycles (e.g. to send whole chords). My SuperCollider code looks like this:
(
var on, off;
var osc;
osc = NetAddr.new("127.0.0.1", 6010);
~notes=[];
MIDIClient.init;
MIDIIn.connectAll;
on = MIDIFunc.noteOn({ |val, num, chan, src|
~notes=~notes.add(num);
~notes=~notes.sort({|a,b| a>b}).reverse;
osc.sendMsg("/ctrl", "notes", format("%", ~notes-60));
});
off = MIDIFunc.noteOff({ |val, num, chan, src|
~notes=~notes.takeThese({|x| x ==num});
osc.sendMsg("/ctrl", "notes", format("%", ~notes-60));
});
if (~stopMidiToOsc != nil, {
~stopMidiToOsc.value;
});
~stopMidiToOsc = {
on.free;
off.free;
};
)
In TidalCycles there is a (undocumented?) function cP
, which accepts whole lists. So with the code above you could do something like this:
d1 $ s "superpiano" <| n (arp "converge" $ cP "notes")
So maybe this is useful for someone...