I made a script for a machine (Digitakt) which is both the source and destination for MIDI cc (control change) messages. The script works for the rounting task, but I want to filter a specific CC message within the routing, and it didn’t work well.
(
~midiOut = MIDIOut.newByName("Elektron Digitakt", "Elektron Digitakt").latency_(Server.default.latency);
MIDIdef.cc(\cc, {
arg ccNum, chan, srcID, argTemplate, dispatcher;
["MIDI CHAN:" + (srcID + 1), "CC MSB:" + chan, "CC VAL:" + ccNum].postln;
~midiOut.control(chan: srcID, ctlNum: chan, val: ccNum);
})
)
Above script is working for routing task, (by the way I found an inconsistent naming convention on MIDIdef.cc
and MIDIOut.control
)
I want to do something like this, but didn't success:
MIDIdef.cc(\cc, {
arg ccNum, chan, srcID, argTemplate, dispatcher;
["MIDI CHAN:" + (srcID + 1), "CC MSB:" + chan, "CC VAL:" + ccNum].postln;
if (chan != 120,
~midiOut.control(chan: srcID, ctlNum: chan, val: ccNum),
chan = nil
);
})
I also tried to apply a function on argTemplate
but did not work either:
I want to do something like this, but didn't success:
MIDIdef.cc(\cc, {
arg ccNum, chan, srcID, argTemplate, dispatcher;
["MIDI CHAN:" + (srcID + 1), "CC MSB:" + chan, "CC VAL:" + ccNum].postln;
~midiOut.control(chan: srcID, ctlNum: chan, val: ccNum);
}, argTemplate: {arg chan; chan != 120 })
I want to know:
- How to apply a if statement function inside MIDIdef
- Any practical application on
argTemplate
?
Thank you!