Get values from midi keyboard

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 ="", 6010);



on = MIDIFunc.noteOn({ |val, num, chan, src|
	~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 = {;;

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...