Skip to content
jshanley edited this page Nov 1, 2014 · 12 revisions

Blip provides an elegant syntax for creating new AudioNodes, and provides additional helper methods for identifying individual nodes, and keeping track of collections of nodes.

# blip.node(name)

Creates a new blip node of type name. A blip node is simply a function that wraps an AudioNode. Here is a list of the valid blip node names along with the associated AudioNode name:

blip node name AudioNode name
'gain' GainNode
'delay' DelayNode
'panner' PannerNode
'convolver' ConvolverNode
'analyser' AnalyserNode
'channelSplitter' ChannelSplitterNode
'channelMerger' ChannelMergerNode
'dynamicsCompressor' DynamicsCompressorNode
'biquadFilter' BiquadFilterNode
'waveShaper' WaveShaperNode
'oscillator' OscillatorNode
'periodicWave' PeriodicWave
'bufferSource' AudioBufferSourceNode
'audioBufferSource' AudioBufferSourceNode

For example:

var gain = blip.node('gain'); 

A blip node is assigned a unique id when it is created, and this id is returned from the .valueOf() method of the node's prototype. This means you can use JavaScript's equality operators on nodes. Blip uses this internally to determine if a given node is contained in a collection.

# node.node()

Returns a reference to the underlying AudioNode.

Collections and Connections

Blip keeps track of the inputs and outputs of each node you create, making it simple to inspect the current audio graph. Blip uses an array-like structure called a node-collection to keep track of groups of nodes.

# node.inputs()

Returns a BlipNodeCollection containing all nodes that are connected to the current node's input(s).

# node.outputs()

Returns a BlipNodeCollection containing all nodes connected from the current node's output(s).

Methods

Once created, the following methods are available to a node. Unless otherwise specified, all methods return the node itself, allowing method calls to be chained.

# node.connect(node)

Connects the current node's output to the input of the specified node. Adds the specified node to the current node's outputs collection.

# node.disconnect([node])

If node is specified, disconnects the current node's output from the specified node's input. If the current node is connected to other nodes, these connections are left intact.

If node is not specified, disconnects all existing connections from the current node's output.

# node.prop(name[, value])

If value is specified, sets the named property name on the underlying AudioNode to the specified value.

If value is not specified, returns the current value of the property.

For example:

var pan = blip.node('panner');
pan.prop('rolloffFactor', 1); // sets the rolloff factor
pan.prop('distanceModel') // returns the distance model

# node.param(name[, value])

Set or get values for an AudioParam associated with the node.

If value is specified, sets the value of the AudioParam. If value is a function, it is invoked with the this context being the AudioParam. For example:

var gain = blip.node('gain');
gain.param('gain', function() {
  this.exponentialRampToValueAtTime(0.8, blip.time.now() + 5);
});

If value is not specified, returns the current value of the AudioParam.

Clone this wiki locally