Pproto:
Filter:

Pproto : Pattern : AbstractFunction : Object

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

Description

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:

\allocRead
load a file from ~path, starting at ~firstFileFrame, reading ~numFrames sample frames
\cue
cue a file for DiskIn, with ~bufferSize frames
\table
load ~amps directly into a buffer
\sine1
generate a buffer from ~amps
\sine2
generate a buffer from ~freqs, ~amps
\sine3
generate a buffer from ~freqs, ~amps, ~phases
\cheby
generate a waveshape buffer from ~amps
\audioBus
allocate ~channels consecutive audio buses
\controlBus
allocate ~channels consecutive control buses
\on
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 4 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

.cleanupFunc = value

.embedInStream(event)

.makeFunction

.makeFunction = value

.pattern

.pattern = value

Examples

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.