This file is indexed.

/usr/share/SuperCollider/HelpSource/Classes/Pspawn.schelp is in supercollider-common 1:3.8.0~repack-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
class:: Pspawn
summary:: Spawns sub-patterns based on parameters in an event pattern
related:: Classes/Pspawner
categories:: Streams-Patterns-Events>Patterns>Parallel

description::

Pspawn is a pattern-based version of link::Classes/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 link::Classes/Pspawner:: help file to become familiar with pattern spawning capabilities.

note::
Important: There are two kinds of events involved in Pspawn:

definitionList::
## strong::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;
## strong::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 ( link::Classes/Pchain:: ) and parallelization ( link::Classes/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 link::#Examples:: below.)

Pspawn uses the following items in the parent pattern:
definitionList::
## 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 link::Classes/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.
::

table::
## strong::'pattern' in the event:: || strong::Resulting behavior::
## A link::Classes/Function:: : code:: { ... } :: || The function should return a pattern; this pattern is spawned.
## A link::Classes/Ref:: to a pattern: code::`Pbind(...):: || The referenced pattern is spawned.
## A link::Classes/Symbol:: : code::\scaleUp:: || The pattern is looked up in the event's 'dict'.
::

subsection::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.

code::
Pseq([Pwhite(0, 9, 5), Pwhite(10, 19, 5)], 1).asStream.all;
::

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

code::
Pseq([`Pwhite(0, 9, 5), `Pwhite(10, 19, 5)], 1).asStream.all;
::

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

ClassMethods::

method::new

argument::pattern
An event pattern (typically link::Classes/Pbind::) encapsulating the desired spawning behavior. Parameters in this event are described below.

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

Examples::

code::
// Play overlapping major scales, up and down
(
p = Pspawn(Pbind(
		// Pbind returned by Pfunc is not embedded, just placed in the event
		// So, it can be spawned
	\pattern, Pfunc { Pbind(\degree, Pseries(rrand(0, 10), #[-1, 1].choose, rrand(4, 10)), \dur, 0.125) },
	\delta, Pwhite(1, 5, inf) * 0.125,
	\method, \par
)).play;
)

p.stop;


// Same, using a dictionary of patterns, changing dur rhythm also
(
var	patternChoices = (
	up: { Pbind(\degree, Pseries(rrand(-4, 5), 1, rrand(4, 10)), \dur, 0.125) },
	down: { Pbind(\degree, Pseries(rrand(4, 11), -1, rrand(4, 10)), \dur, 0.125 * 4/3) }
);

p = Pspawn(Pbind(
	\pattern, Prand([\up, \down], inf),
	\delta, Pwhite(1, 5, inf) * 0.125,
	\method, \par
), (dict: patternChoices)).play;
)

p.stop;


// Using pattern composition (perhaps gratuitously) to build the parent events
(
var	patternChoices = (
	up: { Pbind(\degree, Pseries(rrand(-4, 5), 1, rrand(4, 10)), \dur, 0.125) },
	down: { Pbind(\degree, Pseries(rrand(4, 11), -1, rrand(4, 10)), \dur, 0.125 * 4/3) }
);

p = Pspawn(Pchain(
	Pbind(
		\pattern, Prand([\up, \down], inf),
		\method, \par
	),
	Pbind(
		\delta, Pwhite(1, 5, inf) * 0.125
	)
), (dict: patternChoices)).play;
)

p.stop;


// Play parallel scales in the left channel and sequentially-arranged scales in the right
// This means parallelizing (Ppar) the child streams; thus Ppar surrounds a pair of Pspawns

// Handling of \pan is interesting: \pan needs to be a property of the patternChoices items
// It is NOT a property of the spawning events
// To reuse patternChoices, the Pspawns wrap the base patterns in a Pbindf, which adds new values
(
var	patternChoices = (
	up: { Pbind(\degree, Pseries(rrand(-4, 5), 1, rrand(4, 10)), \dur, 0.125) },
	down: { Pbind(\degree, Pseries(rrand(4, 11), -1, rrand(4, 10)), \dur, 0.125 * 4/3) }
);

p = Ppar([
	Pspawn(Pbind(
			// intermediate value
		\patternKey, Prand([\up, \down], inf),
			// pattern is selected and pan applied here
		\pattern, Pfunc { |ev| Pbindf(ev.dict[ev.patternKey].value, \pan, -1) },
		\delta, Pwhite(1, 5, inf) * 0.125,
		\method, \par
	), (dict: patternChoices)),
	Pspawn(Pbind(
		\patternKey, Prand([\up, \down], inf),
		\pattern, Pfunc { |ev| Pbindf(ev.dict[ev.patternKey].value, \pan, 1) },
		\delta, Pwhite(1, 5, inf) * 0.125,
		\method, \seq
	), (dict: patternChoices)),
]).play;
)

p.stop;
::