Pspawn:
Filter:
Classes | Streams-Patterns-Events > Patterns > Parallel

Pspawn : FilterPattern : Pattern : AbstractFunction : Object

Spawns sub-patterns based on parameters in an event pattern
Source: Pspawner.sc

Description

Pspawn is a pattern-based version of Pspawner. Where Pspawner uses a Routine-style function to determine when and how to spawn child patterns into the result stream, Pspawn uses an event pattern to determine the actions to take.

Recommended to read the Pspawner help file to become familiar with pattern spawning capabilities.

NOTE: Important: There are two kinds of events involved in Pspawn:
parent events
which specify the pattern to embed, how to embed it (in parallel or sequence), and how long to wait until the next action;
child events
which produce the resulting notes (or take other actions on the server).

Of these, only the child events are returned to the event stream player during play. The parent events are used strictly internally to control spawning behavior. The parent and child event streams do not mix together. Thus pattern composition ( Pchain ) and parallelization ( Ppar ) may be used without special handling. It is up to the user to be aware of whether the parent or child stream should be subject to further manipulation, and put that manipulation in the right place. If it is to affect the child stream, it should enclose the entire Pspawn; for the parent stream, it should be inside Pspawn. (See the examples below.)

Pspawn uses the following items in the parent pattern:

method
The action to call on the spawner object. Currently supported: wait, seq, par, suspendAll.
delta
How long to wait until the next action.
dict
If 'pattern' is given as a symbol (see below), this is the dictionary in which the pattern will be looked up. If not specified, the Pdef collection will be used.
pattern
If 'method' is seq or par, this is a pattern or function to be embedded, according to the following rules.
'pattern' in the eventResulting behavior
A Function : { ... }The function should return a pattern; this pattern is spawned.
A Ref to a pattern: `Pbind(...)The referenced pattern is spawned.
A Symbol : \scaleUpThe pattern is looked up in the event's 'dict'.

Using references to protect patterns from embedding

Normally, when a pattern appears inside another pattern, the subpattern is embedded in the main output stream. It is not visible to the outside world as a pattern in itself; only its values appear.

When using Pspawn, a sub pattern must be returned directly into the event. To accomplish this, every such pattern should be wrapped in a Ref :

Hint: Pfunc is another good way to wrap patterns, because it simply returns its result values without further embedding. See the first example.

Class Methods

Pspawn.new(pattern, spawnProtoEvent)

Arguments:

pattern

An event pattern (typically Pbind) encapsulating the desired spawning behavior. Parameters in this event are described below.

spawnProtoEvent

The event prototype against which the pattern is evaluated. Good for giving default values that should apply to all spawning (parent) events.

Inherited class methods

Instance Methods

Inherited instance methods

Undocumented instance methods

.embedInStream(inevent)

.spawnProtoEvent

.spawnProtoEvent = value

Examples