- gathering data from buses on the server
SWBusNodes provide a way to analyze or process data on an audio or control bus, and put the result of the analysis on the network. It has several subclasses for common analysis methods, such as smoothing, statistical properties, and audio feature extraction.
As the SWDataNode in the network is created, the bus of that node will be the internal bus of the SWBusNode. This means that the scale factor of the SWDataNode is not represented on the bus itself.
- Example -
x = SWDataNetwork.new;
q = XBeeSMS.new( "/dev/ttyUSB0", 115200 );
q.action_({ |msg| x.setData( msg[0], msg.copyToEnd(1) ); });
x.addExpected( 2, \floor );
x.addExpected( 102, \floorVar );
q.start;
x[\floor].scale = 1/255;
x[\floor].createBus( s );
~floorVar = StdDevNode.new( 102, x, x.at( \floor ).bus, s );
~floorVar.start;
- Methods -
- Initialization -
- *new( id, network, input, serv )
- This creates an SWBusNode which will create a DataNode with id in the network. input is the inputbus from which the BusNode will read. This has to be an instance of Bus, and can be audiorate or controlrate, depending on the kind of analysis done on it. serv is the Server on which the bus is and on which the analysis synth will run (if none given the default server will be used).
- initSynthDefAndBus ( s, nc )
- private This method is called when creating a new SWBusNode. This method initializes the SynthDef and the output bus for the BusNode. Subclasses override this method with the specific analysis or processing SynthDef. In the base class this produces a simple SynthDef which reads from one bus, multiplies it with a factor mul, and outputs the a lagged result to another bus.
- Settings -
- settings ( )
- This is an IdentityDictionary which holds the settings for the synth. Basic settings for all SWBusNode's are: out, the output bus, in, the input bus, lag, the lagtime for the output, mul, multiplication factor, and gate, gate to keep the synth open. out, in and gate should not be set directly.
Subclasses have more settings, which are listed below. The settings can be set even when the synth is not running. As the synth is created it looks in this dictionary for its start settings.
- set ( key, val, ... )
- Set one or more key and value pairs of the synth. If the synth is not running, the settings are still recorded in the settings dictionary, so they will be used on startup of the synth.
- dt ( )
- dt_ ( )
- The time interval at which the watcher is updating the data. The default is 0.05s.
- Starting and stopping -
- start ( )
- Start the synth and start the watcher for the output results.
- stop ( )
- Stop the synth and stop the watcher.
- release ( releasetime )
- Release the synth with releasetime, and stop the watcher after that time.
- Bus access and control -
- bus ( )
- The output bus.
- get ( func )
- Get the current value of the bus. This is asynchronous, just like Bus.get
- getn ( func )
- Get the current value of the multichannel bus. This is asynchronous, just like Bus.getn
- inbus ( )
- inbus_ ( ibus )
- Change the input bus to another bus. This updates the in setting in the settings as well.
- node ( )
- The SWDataNode in the network.
- setLabel ( )
- Method used to set a default label for the node, if no label exists yet. The default label corresponds to the name of the bus node, the number of input channels and the input channel id.
- Other (more private methods) -
- synthDef ( )
- synthDef_ ( )
- The SynthDef name to be used. This name is generated by the node. Only supply it when you have created a node that corresponds to the basic setup of an SWBusNode.
- id ( )
- The node ID in the network
- network ( )
- The network to which the data is posted.
- synth ( )
- The synth which is doing the processing.
- server ( )
- The server on which the node is running.
- watcher ( )
- The SkipJack which is regularly requesting the value from the bus and setting it in the data network.
- myInit ( )
- private - override in subclass to perform additional initialization
- Subclasses -
- Audio/signal analysis -
- AmpTrackNode
- Amplitude tracker. The input bus can either be control rate or audio rate.
It has the parameters atime (attack time) and rtime (release time). Based on the UGen Amplitude.
- PitchTrackNode
- Pitch tracker. The input bus can either be control rate or audio rate. Before estimating the pitch, the input signal is passed through lowpass and highpass filters to limit the signal within a certain frequency range.
It has the parameters lpfreq (low pass filter frequency), hpfreq (high pass filter frequency), initFreq (initial pitch estimate), minFreq (minimum pitch frequency), maxFreq (maximum pitch frequency) and ampThreshold (amplitude threshold). Based on the UGen Pitch.
- Mixing -
- SumBusesNode
- Mixes down a multichannel bus to a one channel bus, thus effectively summing them.
- Smoothing -
- LeakyNode
- Leaky integrator. The minimum output value is configurable (and defaults to 0).
It has the parameters posSlope1, posSlope2, negSlope and minValue, and implements the formula
out(i) = (posSlope1 * in(i)) + (posSlope2 * in(i-1)) - (negSlope * out(i-1))
.
Based on the UGen FOS.
- LagUDNode
- Smooths the signal by putting a lagtime on it. You can set a different lagtime for going up (parameter lagup), than for going down (parameter lagdown). Based on the UGen LagUD.
- ASRNode
- Trigger an envelope from the signal. This keeps the envelope open, as long as the input signal is above 0. Has the parameters attack, release, curve. See the Env helpfile for more details.
- ASRMulNode
- As above, but the sustain level of the envelope is the running maximum of the input signal.
- SlewNode
- Limits the upSlope and downSlope of the signal. Based on the UGen Slew.
- Derivatives -
- SlopeNode
- Measures the rate of change per second. Based on the UGen Slope.
- Metadata -
- TimerNode
- Measures the time between updates of the bus. Based on the UGen Timer.
- Statistics -
- MeanStdDevNode
- Output the mean and standard deviation of the last number (parameter length; default 50) of samples. The length setting has to be set or changed before the synth is started. The first buses are the mean, the second half of the buses are the standard deviation. The mean will be a smoothed version of the signal. The standard deviation gives an impression of how much change there is in a signal. Based on the UGens RunningSum and StdDevUGen.
- StdDevNode
- Output the standard deviation of the last number (parameter length; default 50) of samples. The length setting has to be set or changed before the synth is started. The standard deviation gives an impression of how much change there is in a signal. Based on the UGen StdDevUGen.
- SumStdDevNode
- As StdDevNode, but mixes down the outputs to one channel.
- MedianNode
- Output the median of the last number (parameter length; default 21) of samples. The length setting must be an odd number from 1 to 31. The output is a smoothed version of the signal, less sensitive to outliers. Based on the UGen Median.
- Physics -
- FrictionNode
- Inputs the input bus into a friction model, with adjustable friction, spring, damp, mass and beltmass. Based on the UGen Friction.
- Gating and triggering -
- SchmidtNode
- Output 1 if input signal is higher than parameter hi, output 0 if parameter lower than parameter lo. Based on the UGen Schmidt.
- SchmidtGateNode
- As above, but multiplies the output by the current input signal.
- InRangeNode
- Outputs 1 if the input is within the given range (between the parameters low and hi), otherwise 0. Based on the UGen InRange.
- InRangeGateNode
- Outputs the input value if the input is within the given range (between the parameters low and hi), otherwise 0. Based on the UGen InRange.
- ToggleFFNode
- Toggles between 0 and 1 upon a trigger on the input (transition from value smaller than or equal to zero to a value above zero). Based on the UGen ToggleFF.
- ToggleFFGateNode
- As above, but multiplies the output by the current input signal.
- Other nodes -
- GridVectorNode
- This calculates the directional vector in x,y, based on 9 input busses, assumed to be directions themselves in the order
[ [ -1, 1 ], [ -1, 0 ], [ -1, -1 ], [ 0, 1 ], [ 0, 0 ], [ 0, -1 ], [ 1, 1 ], [ 1, 0 ], [ 1, -1 ] ]
.
- Trig Bus nodes -
- SWTrigBusNode
- experimental - This is the basic TrigBusNode. Instead of watching the bus at regular intervals, a TrigBusNode uses a SendTrig to set the data. A trigger is sent whenever the signal goes above the parameter threshold, or below. The output of this TrigBusNode are three times as many channels as the input (let's assume it has N channels), with the first N outputs being the strength of the trigger (how far it is above the threshold) above the threshold, the second N the strength of the trigger below the threshold, and the last N the on/off value (1 or 0). For this case, InRange may actually work more reliable. But this class may be useful for subclassing.
- BeatListenNode
- Beat tracker. The input bus should be audio rate. It outputs tempo and triggers for quarter note, eighth note and sixteenth note.
Based on the UGen BeatTrack.
- MouseGridNode
- Simulates a 6 by 4 matrix with a mouse, and gives triggers when it enters a field within the matrix.
- TransitNode
- experimental - Transition within a certain time frame (parameter time) between one input bus and several others.
Marije Baalman
2009-03-16