aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.config/SuperCollider/functions.scd58
1 files changed, 58 insertions, 0 deletions
diff --git a/.config/SuperCollider/functions.scd b/.config/SuperCollider/functions.scd
new file mode 100644
index 0000000..fecd1a0
--- /dev/null
+++ b/.config/SuperCollider/functions.scd
@@ -0,0 +1,58 @@
+postln('Loading custom functions.');
+
+/*
+ * JACK specific helper functions
+ *
+ */
+// disconnect a port
+~jackDisconnectPort = {
+ arg source, sourceChannel, destination, destinationChannel;
+ ("jack_disconnect "++source++":"++sourceChannel++" "++destination++":"++destinationChannel).unixCmd({
+ arg exitCode;
+ if(exitCode != 0, {
+ postln("Disconnecting "++source++":"++sourceChannel++" from "++destination++":"++destinationChannel++" was unsuccessful!");
+ });
+ });
+};
+
+// connect a port
+~jackConnectPort = {
+ arg source, sourceChannel, destination, destinationChannel;
+ ("jack_connect "++source++":"++sourceChannel++" "++destination++":"++destinationChannel).unixCmd({
+ arg exitCode;
+ if(exitCode != 0, {
+ postln("Connecting "++source++":"++sourceChannel++" from "++destination++":"++destinationChannel++" was unsuccessful!");
+ });
+ });
+};
+
+// returns the amount of ports of a given client
+~jackClientPorts = {
+ arg clientName;
+ ("jack_lsp "++clientName++"| wc -l").unixCmdGetStdOut.asInt;
+};
+
+// adds one or more channels to Server.local.options.num{In,Out}putBusChannels
+// makes the tuple available in ~additionalChannels Dictionairy
+~addAdditionalChannels = {
+ arg type, name, channels;
+ if( name.class == Symbol && channels.isArray, {
+ switch (type,
+ \input, {
+ ~additionalChannels.at(\inputs).add(name -> channels);
+ postln("Added additional input channels for '"++name++"': "++channels.asString);
+ Server.local.options.numInputBusChannels = Server.local.options.numInputBusChannels + channels.size;
+ postln("Setting numInputBusChannels to "++Server.local.options.numInputBusChannels);
+ },
+ \output, {
+ ~additionalChannels.at(\outputs).add(name -> channels);
+ postln("Added additional output channels for '"++name++"': "++channels.asString);
+ 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);
+ });
+ },{
+ postln('Expecting type Symbol for name and type Array for channels.');
+ });
+};