Pproto : Pattern : AbstractFunction : Object

provide a proto event for an event stream
Source: Pproto.sc


Pproto uses the makeFunction to allocate resources (buffers, buses, groups) and create a protoEvent that makes those resources available to a pattern. It is fully compatible with non-realtime synthesis using render.

The makeFunction "makes" the protoEvent (i.e. protoEvent is currentEnvironment). Typically, it defines and yields a sequence of events that create the needed resources using the following Event types:

load a file from ~path, starting at ~firstFileFrame, reading ~numFrames sample frames
cue a file for DiskIn, with ~bufferSize frames
load ~amps directly into a buffer
generate a buffer from ~amps
generate a buffer from ~freqs, ~amps
generate a buffer from ~freqs, ~amps, ~phases
generate a waveshape buffer from ~amps
allocate ~channels consecutive audio buses
allocate ~channels consecutive control buses
create a synth
NOTE: These eventTypes will allocate their own buffers and buses unless they are specified. To support this, the key \bufNum is used rather than \bufnum which has a default value assigned.

When Pproto ends, these eventTypes will respond to the cleanup call by deallocating any resources they have allocated. Do not assume your buffers, buses etc. will exist after Pproto stops!

The function yields each event. That event is then performed with possible modifications by enclosing patterns and the player (either an EventStreamPlayer or a ScoreStreamPlayer). The resultant event is returned to the function where it can be assigned to a key within the protoEvent.

The patternarray is played using Pfpar, a variant of Ppar that ends when any of its subpatterns end. In this way, you can use Pproto to create effects that can be controlled by a pattern that runs in parallel with the note generating pattern and ends together with that note generating pattern (see example 0 below).

A cleanupFunction that deallocates resources when the pattern ends or is stopped is automatically created. It can be replaced with a user defined cleanup if needed. This function receives two arguments: proto, the prototype event, and flag, which is set false if all nodes have been freed already by CmdPeriod.

Class Methods

Inherited class methods

Undocumented class methods

Pproto.new(makeFunction, pattern, cleanupFunc)

Instance Methods

Inherited instance methods

Undocumented instance methods


.cleanupFunc = value



.makeFunction = value


.pattern = value


NOTE: The syntax used for patterns like Pbind and Pmono is a little bit different for making the code more readable. The difference has nothing to do with Pproto. This is the same: Pbind(\freq, 700, \amp, 0.1) and Pbind(*[freq: 700, amp: 0.1])

Example 1, loading and granulating a sound file.

Example 2, loading a waveform buffer and modifying it in performance.

Example 3, loading a waveshaper buffer and modifying it in performance.

Example 4, using an effect with parallel control.