83 lines
2.8 KiB
Text
83 lines
2.8 KiB
Text
|
#lang scribble/manual
|
||
|
@(require (for-label racket))
|
||
|
|
||
|
@title{Pbindef}
|
||
|
incremental event pattern reference definition@section{categories}
|
||
|
Libraries>JITLib>Patterns, Live Coding, Streams-Patterns-Events>Patterns
|
||
|
@section{related}
|
||
|
Classes/Pdef, Classes/Pbind
|
||
|
|
||
|
@section{description}
|
||
|
|
||
|
Pbindef keeps a reference to a Pbind in which single keys can be replaced, combining link::Classes/PbindProxy:: and link::Classes/Pdef::. It plays on when the old stream ended and a new stream is set and schedules the changes to the beat.
|
||
|
|
||
|
the difference to Pdef is that it allows to incrementally change the elementary patterns (patternpairs) of a Pbind - also of an already existing Pbind inside a Pdef.
|
||
|
|
||
|
Pbindef and Pdef use the same global collection, while Pdef and Pdefn use separate ones.
|
||
|
|
||
|
Pbindef inherits most methods from link::Classes/Pdef::. Overview: link::Overviews/JITLib::
|
||
|
|
||
|
@section{ClassMethods}
|
||
|
|
||
|
|
||
|
@section{method}
|
||
|
new
|
||
|
store the pattern in the global dictionary of link::Classes/Pdef:: under key. (if there is already a Pdef there, replace its pattern with the new one. If there is already a strong::Pbindef:: there, set the parameters only, or add a new one (the whole pattern is replaced).
|
||
|
|
||
|
Using strong::*new(key):: you can access the pattern at that key (if none is there, a default pattern is created). see link::Classes/Pdef::.
|
||
|
|
||
|
@section{Examples}
|
||
|
|
||
|
|
||
|
|
||
|
@racketblock[
|
||
|
(
|
||
|
SynthDef("Pdefhelp", { arg out, freq, sustain=1, amp=1, pan;
|
||
|
var env, u=1;
|
||
|
env = EnvGen.kr(Env.perc(0.01, sustain), 1, doneAction: Done.freeSelf);
|
||
|
5.do { var d; d = exprand(0.01, 1); u = SinOsc.ar(d * 300, u, rrand(0.1,1.2) * d, 1) };
|
||
|
Out.ar(out, Pan2.ar(SinOsc.ar(u + 1 * freq, 0, amp * env), pan));
|
||
|
}).add;
|
||
|
)
|
||
|
s.boot;
|
||
|
|
||
|
|
||
|
Pbindef(\a, \instrument, \Pdefhelp).play;
|
||
|
Pbindef(\a, \degree, Pseq([0, 2, 5b, 1b], inf));
|
||
|
Pbindef(\a, \dur, 0.1);
|
||
|
Pbindef(\a, \degree, Pseq([1b, 5, 3, 1b, 6, 2, 5, 0, 3, 0, 2], inf));
|
||
|
Pbindef(\a, \legato, Prand([1.0, 2.4, 0.2], inf), \mtranspose, -3);
|
||
|
Pbindef(\a, \mtranspose, nil); // remove key
|
||
|
|
||
|
Pbindef(\a, \degree, Pseq([1, 2, 3, 4, 5, 6], 1));
|
||
|
Pbindef(\a, \degree, Pseq([1, 2, 3, 4, 5, 6], 3), \dur, 0.02);
|
||
|
Pbindef(\a, \degree, Pseq([1, 2, 3, 4, 5, 6], 3), \dur, 0.1);
|
||
|
|
||
|
// apart from this Pbindef behaves like Pdef:
|
||
|
|
||
|
Pbindef(\a).quant = 0.0;
|
||
|
Pbindef(\a, \degree, Pseq([1, 2, 3, 4, 5, 6], 1));
|
||
|
|
||
|
Pbindef(\a).stop;
|
||
|
Pbindef(\a, \degree, Pseq([1, 2, 3, 4, 5, 6], 1)); // does not resume now
|
||
|
|
||
|
Pbindef(\a).playOnce; // play single instance
|
||
|
Pseq([Pbindef(\a), Pdef(\a)]).play; // same here (Pdef(\a) is the same pattern as Pbindef))
|
||
|
|
||
|
Pbindef(\a) === Pdef(\a) // identical.
|
||
|
|
||
|
|
||
|
|
||
|
// an already existing Pdef can be incrementally changed
|
||
|
|
||
|
Pdef(\x, Pbind(\instrument, \Pdefhelp, \dur, 0.3));
|
||
|
Pdef(\x).play;
|
||
|
|
||
|
Pbindef(\x, \degree, 7.rand);
|
||
|
Pbindef(\x, \degree, Pseq([0, 7, 3, 7, 4], inf), \dur, Pn(Pseries(0.2, -0.02, 10)));
|
||
|
Pbindef(\x, \stretch, 2);
|
||
|
::
|
||
|
]
|
||
|
|
||
|
|