aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2019-03-03 22:09:51 +0100
committerDavid Runge <dave@sleepmap.de>2019-03-03 22:09:51 +0100
commitc1e5d08d58034c8b53d4789dd32983016f4a5456 (patch)
tree14655f907c2dca71168373a1dc6fc50de526f55e
parent3335ef4b505a2a6e423516ec0aec1865231b987a (diff)
downloaddotfiles-c1e5d08d58034c8b53d4789dd32983016f4a5456.tar.gz
dotfiles-c1e5d08d58034c8b53d4789dd32983016f4a5456.tar.bz2
dotfiles-c1e5d08d58034c8b53d4789dd32983016f4a5456.tar.xz
dotfiles-c1e5d08d58034c8b53d4789dd32983016f4a5456.zip
.config/SuperCollider/functions.scd: Minor style fixes and adding of a convenience function for MIDI, to map to a given Bus.
-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);
+ });
+};