Вы находитесь на странице: 1из 8

More on Event Patterns

First:
SynthDescLib.global.read;
Test:
(
Pbind( \freq, Pseq([440,880]) ).play
)

Parallel Patterns
Ppar
The Ppar pattern allows you to merge multiple event
streams to play in parallel. Ppar is a ListPattern and so
like most ListPatterns it takes two arguments, a list of
event patterns to play in parallel and a repeats count.
Ppar's child patterns must be event patterns. Using
value patterns in a Ppar is an error because value
patterns contain no duration data. A Ppar is done
when all of its subpatterns are done.
(
Ppar([
Pbind(\dur, 0.2, \midinote, Pseq([62, 65, 69, 72],
inf)),
Pbind(\dur, 0.4, \midinote, Pseq([50, 45], inf))
]).play

)
(
// Ppars can be nested
Ppar([
Pbind(
\dur, Prand([0.2, 0.4, 0.6], inf),
\midinote, Prand([72, 74, 76, 77, 79, 81], inf),
\db, -26,
\legato, 1.1
),
Pseq([
Pbind(\dur, 3.2, \freq, Pseq([\rest]) ),
Prand([
Ppar([
Pbind(\dur, 0.2, \pan, 0.5, \midinote,
Pseq([60, 64, 67, 64])),
Pbind(\dur, 0.4, \pan, -0.5, \midinote,
Pseq([48, 43]))
]),
Ppar([
Pbind(\dur, 0.2, \pan, 0.5, \midinote,
Pseq([62, 65, 69, 65])),
Pbind(\dur, 0.4, \pan, -0.5, \midinote,
Pseq([50, 45]))
]),
Ppar([
Pbind(\dur, 0.2, \pan, 0.5, \midinote,
Pseq([64, 67, 71, 67])),
Pbind(\dur, 0.4, \pan, -0.5, \midinote,
Pseq([52, 47]))

])
], 12)
], inf)
], inf).play;
)

Ptpar
The Ppar pattern starts all of its subpatterns at the
same time. Ptpar pattern includes a start time
parameter before each subpattern which allow the
subpatterns to be started at some time delay within the
pattern. The start time is given in beats.
(
var makePattern, durpat;
durpat = Pseq([ Pgeom(0.05, 1.1, 24), Pgeom(0.5,
0.909, 24) ], 2);
makePattern = { arg note, db, pan;
Pbind( \dur, durpat, \db, db, \pan, pan, \midinote,
Pseq([note, note-4], inf) );
};
Ptpar([
0.0, makePattern.value(53, -20, -0.9),
2.0, makePattern.value(60, -23, -0.3),
4.0, makePattern.value(67, -26, 0.3),
6.0, makePattern.value(74, -29, 0.9)
], inf).play;

)
The time arguments are sent the 'value' message when
the Ptpar pattern
is started, so you may use functions to specify the
times.
(
var makePattern, durpat;
durpat = Pseq([ Pgeom(0.05, 1.1, 24), Pgeom(0.5,
0.909, 24) ], 2);
makePattern = { arg note, db, pan;
Pbind( \dur, durpat, \db, db, \pan, pan, \midinote,
Pseq([note, note-4], inf) );
};
Ptpar([
{ 0.0 }, makePattern.value(53, -20, -0.9),
{ 8.0.rand }, makePattern.value(60, -23, -0.3),
{ 8.0.rand }, makePattern.value(67, -26, 0.3),
{ 8.0.rand }, makePattern.value(74, -29, 0.9)
], inf).play;
)

Practical Considerations
Using your own ~instrument
(

SynthDef("Help-SPE7-BerlinB", { arg i_out=0, freq =


80, amp = 0.2, pan=0;
var out, a, b;
amp = Decay2.kr(Impulse.kr(0), 0.05, 8, amp);
out = RLPF.ar(
LFPulse.ar(freq, 0, SinOsc.kr(0.12,
[0,0.5pi],0.48,0.5), amp),
freq * SinOsc.kr(0.21,0,4,8),
0.07
);
#a, b = out;
DetectSilence.ar(a, 0.0001, doneAction: 2);
Out.ar(i_out, Mix.ar(PanAz.ar(4, [a, b], [pan,
pan+1])));
}).store;
SynthDef("Help-SPE7-CFString1", { arg i_out, freq =
360, gate = 1, pan, amp=0.1;
var out, eg, fc, osc, a, b, w;
fc = LinExp.kr(LFNoise1.kr(Rand(0.25,0.4)),
-1,1,500,2000);
osc = Mix.fill(8, { LFSaw.ar(freq *
[Rand(0.99,1.01),Rand(0.99,1.01)], 0, amp) }).distort
* 0.2;
eg = EnvGen.kr(Env.asr(1,1,1), gate,
doneAction:2);
out = eg * RLPF.ar(osc, fc, 0.1);
#a, b = out;
Out.ar(i_out, Mix.ar(PanAz.ar(4, [a, b], [pan,
pan+0.3])));

}).store;
)
(
Pbind(
\instrument, Prand(['Help-SPE7-BerlinB','HelpSPE7-CFString1'],inf),
\degree, Pseq([0,1,2,4,6,3,4,8],inf),
\dur, 0.8,
\octave, 3,
\amp, 0.03
).play;
)

Manipulating an EventStreamPlayer in
Realtime
(
p = Pbind(
\degree, Pwhite(0,12),
\dur, 0.2,
\instrument, "Help-SPE7-CFString1"
);
// e is an EventStreamPlayer
e = p.play;
)
(
// you can change the stream at any point in time

e.stream = Pbind(
\degree, Pseq([0,1,2,4,6,3,4,8],inf),
\dur, Prand([0.2,0.4,0.8],inf),
\amp, 0.05,
\octave, 5,
\instrument, 'Help-SPE7-BerlinB', // you can
also use a symbol
\ctranspose, 0
).asStream;
)
(
e.stream = Pbind(
[\degree, \dur], Pseq(
[
Pseq([[0,0.1],[2,0.1],[3,0.1],[4,0.1],
[5,0.8]],2),
Ptuple([Pxrand([6,7,8,9],4), 0.4]),
Ptuple([Pseq([9,8,7,6,5,4,3,2]), 0.2])
], inf
),
\amp, 0.05,
\octave, 5,
\instrument, "Help-SPE7-CFString1"
).asStream;
)
The following methods are possible because an
EventStreamPlayer is a PauseStream:

e.mute; // keeps playing, but replaces notes with rests


e.unmute;
e.reset; // reset the stream.
e.pause; // will resume where paused.
e.resume;
e.stop; // will reset before resume.
e.resume;