aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.config/SuperCollider/functions.scd51
1 files changed, 47 insertions, 4 deletions
diff --git a/.config/SuperCollider/functions.scd b/.config/SuperCollider/functions.scd
index 731760a..3f27e31 100644
--- a/.config/SuperCollider/functions.scd
+++ b/.config/SuperCollider/functions.scd
@@ -40,7 +40,7 @@ postln('Loading custom functions.');
// makes the tuple available in ~additionalChannels Dictionairy
~addAdditionalChannels = {
arg type, name, channels;
- if( name.isKindOf(Symbol) && channels.isArray, {
+ if( (name.isKindOf(Symbol) && channels.isArray), {
switch (type,
\input, {
~additionalChannels.at(\inputs).add(name -> channels);
@@ -54,10 +54,10 @@ postln('Loading custom functions.');
Server.local.options.numOutputBusChannels = Server.local.options.numOutputBusChannels + channels.size;
postln("Setting numOutputBusChannels to "++Server.local.options.numOutputBusChannels);
},
- { postln("Expecting \input or \output as type, got "++type.asString);
- });
+ { error("Expecting \input or \output as type, got "++type.asString);
+ });
},{
- postln('Expecting type Symbol for name and type Array for channels.');
+ error('Expecting type Symbol for name and type Array for channels.');
});
};
@@ -126,4 +126,47 @@ postln('Loading custom functions.');
});
};
+/*
+ * MIDI specific helper functions
+ * TODO: move to Quark
+ */
+// map inputs of a given MIDI device's control messages to the values on a
+// control Bus
+~midiControlToBus = {
+ arg key, msgNum, chan, uid, bus;
+ if(key.isKindOf(Symbol),{
+ if((msgNum.isArray),{
+ if (chan.isInteger, {
+ if (uid.isInteger, {
+ if (bus.isKindOf(Bus), {
+ MIDIdef.new(
+ key: key,
+ func: {
+ arg ...args;
+ bus.setAt(
+ msgNum.indexOf(args[1].asInteger),
+ args[0].asInteger.lincurve(0, 127, 0.0, 1.0, 4, nil)
+ );
+ },
+ msgNum: msgNum,
+ chan: chan,
+ msgType: \control,
+ srcID: uid
+ );
+ },{
+ error('Argument bus must be of type Bus: '++bus.class);
+ });
+ },{
+ error('Argument uid must be of type Integer: '++uid.class);
+ });
+ },{
+ error('Argument chan must be of type Integer: '++chan.class);
+ });
+ },{
+ error('Argument msgNum must be of type Array: '++msgNum.class);
+ });
+ },{
+ error('Argument key must be of type Symbol: '++key.class);
+ });
+};