diff options
author | David Runge <dave@sleepmap.de> | 2019-03-03 17:04:01 +0100 |
---|---|---|
committer | David Runge <dave@sleepmap.de> | 2019-03-03 17:04:01 +0100 |
commit | 73fca249f23bd236a00f1e9282709f456c23b9b8 (patch) | |
tree | faf068228b154e6286cda0cf7c9609da14c001d3 | |
parent | f3ee15d598cbdabd9fc0b55b9f4fc99dd7af30e9 (diff) | |
download | dotfiles-73fca249f23bd236a00f1e9282709f456c23b9b8.tar.gz dotfiles-73fca249f23bd236a00f1e9282709f456c23b9b8.tar.bz2 dotfiles-73fca249f23bd236a00f1e9282709f456c23b9b8.tar.xz dotfiles-73fca249f23bd236a00f1e9282709f456c23b9b8.zip |
.config/SuperCollider/functions.scd: Adding simple helper functions to connect/disconnect JACK clients by name:port_name. Adding function to add additional channels (above hardware in and outputs), which automatically increments Server.local.options.num{In,Out}putBuschannels.
-rw-r--r-- | .config/SuperCollider/functions.scd | 58 |
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.'); + }); +}; |