Signal Class Input/Output

Signal classes come in two general categories: Generator and Filter. Generator classes do not have inputs and can only give output signals. Filter classes, however, have both input and output signals.

There can be any number of inputs and outputs to signal classes. As inputs (Filter classes only), signal streams are connected to an objects input by the connect command.

Input connections can be thought of as an array that starts at index 0. The connect command has four forms:
connect(aSignal) Connects aSignal to the first empty input slot.
connect(aSignal, int slot) Connects aSignal to the slot location. If there was any signal previously in that slot, it is now disconnected.
connect(aSignal, slot, int outputChannel) Connects aSignal to slot input, and reads the outputChannel of the connects signal object. By default, outputChannel 0 of the input object is read.
connect(sampleType number, slot) Sets the input channel slot to a constant value, number.

Output connections are handled by downstream objects. The current object returns it current sample with the output(int outputChannel) command. To get the value of the 0th output channel, a downstream object would call the object with the function output(0). There may be only one output channel to an object; if so, then the output channel specified in the output command is usually ignored.


Reading the Input/Output Diagrams

Here is the input/output diagram for the Allpass1 filter:

Input index Description Summary
0 input signal Incoming signal to be allpassed.
1 gain A number between -1 and 1 that represents the gain used in the allpass filter.
Output index Description Summary
* output signal the allpassed output signal.

Input signals are shown as arrows pointing towards the class object. Output signals are shown leaving the class object. In this particular case there are two input signals and one output signal.

Notice that the input arrows are numbered. This represents the input slot to the Filter class that is being used to connect the signal stream. The input audio signal is entering at slot 0, and the gain parameter for the Allpass1 filter is exptected to come in at slot 1. There are function names in small print underneath the name of each input. The functions describe the default values which will be used if no signal stream is connected at that particular slot. For example in this case, slot 0 will be read as 0.0 if there is no signal connected at slot 0, and likewise, slot 1 will be read as 0.5. Any connections to slots 2 and higher will be ignored by the Allpass1 filter.

The output in this case is only one signal stream; however, there could be more than one output. If that is the case, then the output channels would be number as was the case for the inputs. Here is an example input/output diagram from the Pan class which contains two outputs:

Input index Description Summary
0 input signal Incoming signal to be panned.
1 pan location A number between 0 and 1 that represents the pan location in the stereo field; 0=all left channel, 1=all right channel.
Output index Description Summary
0 left channel Input signal scaled by the pan location amplitude value for the left channel.
1 right channel Input signal scaled by the pan location amplitude value for the right channel.










craig@ccrma.stanford.edu