SuperCollider CLASSES

BusPlug

a listener on a bus
Inherits from: AbstractFunction : Object
Subclasses: NodeProxy

Description

A BusPlug is represents a listener on a private Bus that makes it easy to play back to multiple channels. It is mainly in use as a superclass of NodeProxy, but it can be used for general channel routings as well. Most methods are documented in the NodeProxy helpfile.

s.boot;
z = Bus.control(s, 16);
z.setn({ |i| (i * 5).nthPrime } ! 16 * 5 + 100);
a = BusPlug.for(z);
{ Splay.ar(SinOsc.ar(a.kr(3, MouseX.kr(0, 25)))) * 0.1 }.play; // selectively play 3 channel of the 16, modulate offset

Class Methods

*new (server)

Create a new (neutral) instance on the given server

*for (bus)

Create an instance with a given Bus.

*audio (server, numChannels)

Create a new audio rate instance on the given server

*control (server, numChannels)

Create a new audio rate instance on the given server

*defaultNumAudio

*defaultNumAudio = value

Default number of channels when initializing in audio rate and no specific number is given (default: 2).

*defaultNumControl

*defaultNumControl = value

Default number of channels when initializing in control rate and no specific number is given (default: 1).

*defaultReshaping

*defaultReshaping = value

default reshaping behaviour for BusPlug and its sublass NodeProxy. See: reshaping

Inherited class methods

Instance Methods

-server

Return the server that the BusPlug runs on.

-clear

Free the bus, end the monitor

Making copies

-copy

copies the hidden internal state to make the new BusPlug independent of the old, running on a new Bus. By design, the Monitor is copied, but is not running (use play to start it in the same configuration). If needed, you can also copy the Monitor only (see: NodeProxy: copy).

-copyState (proxy)

Copy the internal settings of one proxy into another. Old state is cleared, the bus is freed.

Arguments:

proxy

The object whose internal state is being copied.

-reshaping

-reshaping = value

Determines how to behave when initBus is called. Current options:

In UGen graphs and Patterns

-ar (numChannels, offset: 0, clip: 'wrap')

-kr (numChannels, offset: 0, clip: 'wrap')

Return a link to numChannels of my output. If uninitialized, creates a matching bus. Normally, ar defaults to stereo, kr to mono. This can be set in the classvars: *defaultNumAudio, *defaultNumControl

For consistency, it always returns an array of signals when no numChannels are given. To make it a single ugen output, use cumChannels = 1 . See also: InBus.

Arguments:

numChannels

Number of channels returned. If the receiver is neutral or reshaping is elastic, initialize it to this number. If this is more than the available channels, use the clip behaviour (below). If set to 1, it will return an instance of InBus, otherwise an Array of one or more instances of InBus.

offset

Channel offset when reading a bus that has more channels than numChannels, cross fading between adjacent channels. "/Users/wanninger/Library/Application Support/SuperCollider/Help/Overviews/Methods.html"

clip

If set to 'wrap', exceeding channels will wrap around, if set to 'clip', repeat the last one.

-asUGenInput

Returns the appropriate output to read from the BusPlug bus (an InBus UGen)

b = BusPlug.new;
{ Blip.ar(b + 5) }.play;
b.bus.set(12);

-embedInStream (inval)

Returns the map argument for the bus, if the bus has multiple channels, it will return an array of map args.

b = BusPlug.new;
x = Pbind(\z, b).asStream;
x.next(()); // returns the map argument for the bus
b.defineBus(\audio, 3);
x.next(()); // returns map arguments for the audio rate bus

-asControlInput

Returns the map argument for the bus, just like -embedInStream

Monitoring and Routing

-isPlaying

Returns true if server is running and bus not nil. NodeProxy this returns true if the group is playing.

-isMonitoring

Returns true if monitor is playing

-play (out, numChannels, group, multi: false, vol, fadeTime, addAction)

Play from a bus index with a number of channels to another index with a number of channels, within a Group (i.e. a target group or server).

Arguments:

out

bus index

numChannels

number of channels to output. If BusPlug is neutral or reshaping is elastic, initialize it to this number. If this is more than the available channels, wrap around. If this is not given, and reshaping is elastic, it will automatically expand.

group

target Group or Server in which to play the monitor synths.

multi

keep old playback links and add new one

vol

overall volume at which to monitor

fadeTime

fade in / fade out time

addAction

Where in the node tree to play the monitor synths

-playN (outs, amps, ins, vol, fadeTime, group, addAction)

Play back on non-contiguous channels. See: Monitor and playN

Arguments:

outs

array of destination channels (or single value)

amps

array of amplitudes for each channel (or single value)

ins

array of source channel offsets within the bus (or single value)

vol

Overall volume (multiplied by amps)

fadeTime

array of fadeTimes (or single value) for fade in / fade out

group

target Group or Server in which to play the monitor synths.

addAction

Where in the node tree to play the monitor synths

-stop (fadeTime, reset: false)

stop to play out public channels.

Arguments:

fadeTime

decay time for this action

reset

if set to true, reset all monitor state. Otherwise, the previous play arguments are kept.

-monitor

-monitor = value

returns the current monitor (see Monitor)

Bus changes

These methods are a little numerous, because they are important for implementing NodeProxy behavior. Mostly the methods -bus and -initBus will be sufficient in normal use.

NOTE: The old bus is freed when a new bus is made.

-isNeutral

Returns true if no bus has been initialized so far.

-bus

-bus = inBus

Set or get the bus. If BusPlug monitor is playing, restart the monitor to adequately play back the new bus.

-setBus (inBus)

set the bus object by passing a Bus.

NOTE: you have to stop and play explicitly

-defineBus (rate: 'audio', numChannels)

make a new bus for the BusPlug with a given rate and number of channels.

-initBus (rate, numChannels)

Make a new bus only if necessary. This depends on the current bus and the -reshaping mode.

Returns:

Boolean (true if successful).

Inherited instance methods

Undocumented instance methods

-asBus

-asMap

-asNodeArg

-asOSCArgEmbeddedArray (array)

From extension in /usr/local/share/SuperCollider/SCClassLibrary/JITLib/ProxySpace/NodeMap.sc

-asStream

-busArg

-composeBinaryOp (aSelector, something)

-composeNAryOp (aSelector, anArgList)

-composeUnaryOp (aSelector)

-fadeTime

-fixedBus

-freeBus

-homeServer

-index

-initMonitor (vol)

-monitorGroup

-monitorIndex

-numChannels

-parentGroup

-parentGroup = value

-plot (duration: 0.01, bounds, minval, maxval, separately: false)

-prepareOutput

-quant

-rate

-reverseComposeBinaryOp (aSelector, something)

-scope (bufsize: 4096, zoom)

-serverQuit

-shared

-value (something)

-vol

-vol = val

-wakeUp

Examples

// using as a control bus listener

s.boot;
z = Bus.control(s, 16);
a = BusPlug.for(z);

m = { Mix(SinOsc.ar(a.kr(16), 0, 0.1)) }.play;

z.setn(Array.rand(16, 300, 320).put(16.rand, rrand(500, 1000)));
z.setn(Array.rand(16, 300, 320).put(16.rand, rrand(500, 1000)));
z.setn(Array.rand(16, 300, 320).put(16.rand, rrand(500, 1000)));

m.free;


m = { SinOsc.ar(a.kr(2, MouseX.kr(0, 19)), 0, 0.1) }.play; // modulate channel offset

z.setn(Array.rand(16, 300, 1320).put(16.rand, rrand(500, 1000)));


m.free; z.free;

// using as a audio monitor

p = BusPlug.audio(s,2);
d = { Out.ar(p.index, PinkNoise.ar([0.1, 0.1])) }.play;


p.play; // monitor whatever plays in p (the execution order does not matter)



d.free;
d = { Out.ar(p.index, PinkNoise.ar([0.1, 0.1])) }.play;

p.stop;
p.play;

// also p can play to another bus:

p.stop;
p.play(12);

// listen to that bus for a test:
x = { InFeedback.ar(12,2) }.play;
x.free;