I know the following code doesn’t work, but I feel like it will explain what I am trying to do better than my description.
Essentially, I’d like to have a 6-channel bus and I’d like to send an output to specific channels of the bus.
What would the proper way of doing this be?
Thank you for the advice in advance.
N.B. A ServerOptions’ instance variables are translated into commandline arguments when a server app is booted. Thus a running Server must be rebooted before changes will take effect. There are also a few commandline options which are not currently encapsulated in ServerOptions. See Server Architecture for more details.
I also assumed this could be done while the Server is running when I was first getting into SC so you’re not alone in this
Note that the Server itself has no notion of a “multichannel Bus”, it only has one large fixed-size array of Busses. Bus allocation is done entirely on the Client. Bus.audio(s, 6) simply reserves 6 consecutive bus numbers.
All that being said, I’m not entirely sure what you are trying to do in that example. To me it seems like you want to play the SineOsc on a particular output channel. Since the output and input busses are automatically reserved by the Server (based on the Server options), you don’t allocate them explicitly. Instead you just pass the output channel number:
(
// boot Server with 6 output channels
s.options.numOutputBusChannels = 6;
s.boot;
)
// write to Bus 3 (counting from 0)
{ Out.ar(3, SinOsc.ar(300)) }.play;
s.meter;
(The first N busses are always reserved for the device outputs and inputs; all subsequent busses can be used freely by the Client. Since output busses come first, you can simply use the channel index. Input busses must be offset by the number of output busses; the pseudo-UGen SoundIn does that for you.)
Bus.audio(s, 6) gives you a Bus object with an index (first bus number) and a numChannels (6 in this case). The index is assigned by the server’s audioBusAllocator such that all of the buses between and including index and index+5 were not reserved by another Bus at the time of allocating the new bus.
In the server, then, to write into the 4th channel (as your initial example suggests): the bus object knows the first channel index, so it would be Out.ar(~bus.index + 3, signal).
To sum them, you’d access all the channels with In.ar(~bus, 6) and then .sum that. (This is a slight improvement over the suggestion to allocate buses individually – the “array of single channel buses” would require 6 In units, where this approach needs only one In.)
When you allocate a bus, it will come from a range that is not connected to the audio hardware. So it’s your responsibility to run a synth to transfer the signal to the hardware outputs. IMO this is a good habit to get into, except for very quick-and-dirty testing; I use my ddwMixerChannel quark for this purpose (always, in production code; seldom when I’m { ... }.play-ing something).