Pbind:
Filter:
Classes | Streams-Patterns-Events > Patterns > Event

Pbind : Pattern : AbstractFunction : Object

combine several value patterns to one event stream by binding keys to values
Source: Patterns.sc

Description

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.)

Class Methods

Pbind.new( ... pairs)

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.

Inherited class methods

Instance Methods

Inherited instance methods

Undocumented instance methods

.embedInStream(inevent)

.patternpairs

.patternpairs = value

Examples

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:

SynthDef and Event

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:

instrument (\default)
The synthdef to be played
variant (nil, optional)
The set of variant control defaults to use (see SynthDef)
server (Server.default)
The server that plays the synth
group (1)
The new synth's or the synth the new synth is placed before or after
addAction (0)
How the synth is placed relative to the target specified by group
0
head of group
1
tail of group
2
before group (could be a Synth)
3
after group (could be a Synth)

delta (function)
The time until the next event in a sequence of events, generally specified indirectly through dur

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.

out
output bus index
in
input bus index (for filters, modulators, etc)
gate
envelope gate (not level!) - should default to 1.0, deletes synth when released
trig
envelope gate (not level!) - should default to 1.0, does not delete synth when released
pan
panning position
bufnum
buffer number (used in synths that utilize PlayBuf, DiskIn, etc)
sustain
duration of the synth
amp
amplitude of the synth
freq
base pitch of the 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.

delta
The time until the next event. Generally determined by:
dur
The time until next event in a sequence of events
stretch
Scales event timings (i.e. stretch == 2 => durations are twice as long)

sustain
Duration of the synth, typically determined (in stretched time units) by:
legato
The ratio of the synth's duration to the event's duration

amp
synth amplitude (typically ranging from 0 to 1), often determined by
db
Amplitude in decibels

detunedFreq
actual "pitch" of a synth, determined by:
freq + detune;
freq is determined by:
(midinote + ctranspose).midicps * harmonic;
midinote is determined by:
(note + gtranspose + root)/stepsPerOctave * octave * 12;
note is determined by:
(degree + mtranspose).degreeToKey(scale, stepsPerOctave)

Rests

See Rest for a discussion of marking events as rests in Pbind.

The Play Method

While the play method is actually defined in the class Pattern, it is useful to review it here:

play (clock, protoEvent, quant)
returns an EventStreamPlayer.
clock
The clock that schedules the EventStreamPlayer, defaults to TempoClock.default. Patterns that change graphics must use AppClock.
protoEvent
The initial event modified by Pbind, defaults to Event.default.
quant
A quantization value used by clock. When a number, the pattern will start at the next even multiple of that number. May also be a Quant, which specifies quantization, time position within that quantization, and a timingOffset. See Quant for details.

Realtime Control with EventStreamPlayer

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).

Additional arguments

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:

Multichannel Expansion

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.

NOTE: In Pbind, you can’t have arrays of patterns, but only patterns that return arrays.

Experimenting with Patterns

Using Pdef (provided by JITLib) makes it easy to replace patterns on the fly:

Sending to effects

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.

Additional examples