// 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;