aboutsummaryrefslogtreecommitdiffstats
path: root/.config/SuperCollider/functions.scd
blob: fecd1a099535d1f1e7e42892dd2db57af25e2b7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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.');
  });
};