Pbind combines several value streams into one event stream. Each value stream is assigned to one or more keys in the resulting event stream. It specifies a stream of Events in terms of different patterns that are bound to different keys in the Event. The patterns bound to keys are referred to as value patterns and the Pbind itself is termed an event pattern.
The keys used in a Pbind are usually determined by Event's default mechanism and the controls defined for the SynthDef to be played. (See SynthDef and Event below for a brief discussion of both in relation to Pbind.)
The arguments to Pbind are an alternating sequence of keys and patterns. A pattern can also be bount to an array of keys. In this case, the pattern must specify a sequence whose elements are arrays with at least as many elements as there are keys.
It is possible to specify a Pbind with an Array preceded by *. This takes advantage of a special syntactic shortcut in SC where using * expands an Array into a list of method arguments. You can see more information about this and other syntactic shortcuts in Syntax Shortcuts and Symbolic Notations. Another useful shortcut is that Arrays treat identifiers ending with a colon as Symbols. Both of these shortcuts together help make the syntax of the Pbind specification a bit more concise:
The keys used in a Pbind are determined by the SynthDef used and the structure of the extensive default mechanism provided by Event. This section provides a brief review of both.
A SynthDef assigns a name to an interconnection of unit generators to be run as a synth on a server. It also assigns control names to the synth's control inputs. In the following example the SynthDef \test has control inputs out, freq, amp, nharms, pan, and gate.
The SynthDef needs to be downloaded to the server upon which it is to be run. Use .add instead of .send to ensure that any patterns using this SynthDef have information about the available control inputs (see SynthDesc). Alternately, .store may be used to save the SynthDef to disk and add the SynthDesc to the library.
An Event is a Dictionary that specifies an action to be taken in response to play and a time increment to be returned in response to delta. Events can be written as a series of key value pairs enclosed in parentheses. Empty parentheses create an empty event.
By default, Events play synths on a server. Such note events use the following keys:
When the Event is played, it creates an OSC command to play a synth. It uses the name assigned to instrument to the select the SynthDef to be played. The SynthDef's control names (found in its SynthDesc) are looked up in the event and the corresponding values included in the command.
Playing a synth is the normal action taken by an Event. The default event structure defines several other event types that can perform a wide variety of server actions. See the Event help file for a list of event types.
There are a number of coventional names typically used to identify controls in a synth.
Event implements a layered specification scheme for some of these controls. In the following list, the first and leftmost name is the actual control name, names below and indented are more abstract ways to specify the control.
While the play method is actually defined in the class Pattern, it is useful to review it here:
The EventStreamPlayer provides realtime control through mute, unmute, stop, play and reset.
In addition, the stream the EventStreamPlayer plays can be altered while it is running through the method stream_(aStream).
Here is an example with more bindings. Here we have added a filter with cutoff and resonance arguments. You will need to hit command '.' before executing the next few pbind ex. without having them stack up. also, due to the synthdef's and synthdeclib, if the server is shut down you will have to reload the synthdef and re-read the synthdesclib.
The ListPatterns can be put around Event Streams to create sequences of Event Streams.
'Pseq' in the above ex. can be any pattern object:
If we supply an array for any argument, the synth node will automatically replicate to handle the additional arguments.
The only exception to this is: \instrument
and \dur
. For the general schema, see also: Multichannel Expansion.
Using Pdef (provided by JITLib) makes it easy to replace patterns on the fly:
Assignment to effect processors can be achieved by setting the 'out' argument to the desired efx's input bus. The effect Synth must also be created. Synth.new is one way of doing this.