Interactive Swarm Space

Multichannel Output and Routing

In this section, we will explain how to create multichannel units as well as how to connect multichannel units with each other.

First of all, you need to know, that all units are basically multichannel-capable in that they support multiple channels. But some units can have separate controlport values for each channel and some can't. In the example bellow, the InputFile Unit's "transpose" values of each channel can be set individually by using a Frame.

Frame(4, 0.5, 0.6, 0.8, 0,7));

The first parameter of frame specifies the number of channels to be set - which is four in our example. All following numbers hold individual values. Please make absolutely sure you use doubles for these values! Integer values will be misinterpreted.

The BWFilter could could have 4 channels, but the control ports "frequency" and "bandwidth" cannot be set individually but would affect all channels likewise. That's why the example bellow makes use of 4 separate BWFilters, each with their own frequency/bandwidth setting.

However this gives us the opportunity to demonstrate what happens when two units with an unequal amount of ports are connected to each other. You need a ChannelMap. Let's for example connect a 3-channel unit to a 5-channel unit. In the short example syntax, channel 1 of the sending unit will be routed to input port 1 and 4 of the receiving unit, and channel 3 will be routed to channel 2:

sender->connect(receiver, new ChannelMap(5, 1, 3, 0, 1, 0); //s1->r1, s3->r2, s1->r4

Similar to the Frame, the ChannelMap's parameters starts with the number of channels of the receiving unit, followed by a corresponding amount of integers containing the sender channel index - 0 means this receiving channel is not used in this connection. Notice, that in contrast to Frame, you need to write the keyword "new"! Frames and ChannelMaps are two very different concepts. Don't get mixed up, simply because they are mentioned here side by side.

Lets now assume, you would like to create an simple quadraphonic installation (4 outputs): A source sound is played at 4 different speed, run through 4 separate bandpass filters and then passed to the four speakers.

First let's look at the code and the discuss some further details:

OutputUnit* jackOutput = new JackOutputUnit(4, "Aggregate Device");
  // Please make sure Jack is configured to 4 output channels (JackPilot.app)

InputFile* sourceSnd = new InputFile(4,"<directory>/src.aif");
BWFilter* bandFilter1 = new BWFilter(BW_BANDPASS);
BWFilter* bandFilter2 = new BWFilter(BW_BANDPASS);
BWFilter* bandFilter3 = new BWFilter(BW_BANDPASS);
BWFilter* bandFilter4 = new BWFilter(BW_BANDPASS);

sourceSnd->set("transpose", Frame(4, 0.5, 0.6, 0.8, 0,7));
  // set 4 transpose values at once with the help of a Frame object

bandFilter1->set("frequency", 3000.0);
bandFilter2->set("frequency", 5000.0);
bandFilter3->set("frequency", 7000.0);
bandFilter4->set("frequency", 9000.0);
bandFilter1->set("bandwidth, 1000.0);
bandFilter2->set("bandwidth, 1000.0);
bandFilter3->set("bandwidth, 1000.0);
bandFilter4->set("bandwidth, 1000.0);
 
sourceSnd->connect(bandFilter1, new ChannelMap(1, 1));
sourceSnd->connect(bandFilter2, new ChannelMap(1, 2));
sourceSnd->connect(bandFilter3, new ChannelMap(1, 3)); 
sourceSnd->connect(bandFilter4, new ChannelMap(1, 4));

bandFilter1->connect(jackOutput, new ChannelMap(4, 1, 0, 0, 0));
bandFilter2->connect(jackOutput, new ChannelMap(4, 0, 1, 0, 0));
bandFilter3->connect(jackOutput, new ChannelMap(4, 0, 0, 1, 0));
bandFilter4->connect(jackOutput, new ChannelMap(4, 0, 0, 0, 1));

Last updated: May 15, 2024