1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Evaluate the block below to start the mapping MIDI -> OSC.
(
var on, off, cc;
var osc;
osc = NetAddr.new("127.0.0.1", 6010);
MIDIClient.init;
MIDIIn.connectAll;
// Initial: sends velocity on note's channel
// on = MIDIFunc.noteOn({ |val, num, chan, src|
// osc.sendMsg("/ctrl", num.asString, val/127);
// });
on = MIDIFunc.noteOn({ |val, num, chan, src|
// it will be passed the arguments val, num, chan, and src, corresponding to the message value (e.g. velocity, control value, etc.)
osc.sendMsg("/ctrl", "note", (num - 60));
});
off = MIDIFunc.noteOff({ |val, num, chan, src|
osc.sendMsg("/ctrl", "note", 0);
});
cc = MIDIFunc.cc({ |val, num, chan, src|
osc.sendMsg("/ctrl", num.asString, val/127);
});
if (~stopMidiToOsc != nil, {
~stopMidiToOsc.value;
});
~stopMidiToOsc = {
on.free;
off.free;
cc.free;
};
)
// Evaluate the line below to stop it.
// ~stopMidiToOsc.value;