rsc3/doc-schelp/HelpSource/Classes/PatternConductor.scrbl

74 lines
2 KiB
Text
Raw Permalink Normal View History

2022-08-24 13:53:18 +00:00
#lang scribble/manual
@(require (for-label racket))
@title{PatternConductor}
Simple interactive control for playing patterns@section{related}
Classes/Pattern
@section{categories}
Streams-Patterns-Events>Patterns
@section{description}
PatternConductor provides a simple interactive control (supporting play, pause, resume, stop) for playing pattern, much like link::Classes/Pattern#-play::. However, PatternConductor creates its own clock and directly controls the release of sounding notes as well as their initiation by the pattern.
@section{InstanceMethods}
@section{private}
prPlay
@section{method}
tempo
Sets the tempo of the PatternConductor
@section{method}
play
Play the pattern. A link::Classes/TempoClock:: is created, its tempo is set to the PatternConductor tempo, and the pattern is played using that clock. If quant is non-zero, this is synchronized with TempoClock.default at the specified quantization.
@section{method}
pause
Pause the pattern, sustaining notes indefinitely. A subsequent link::#-resume:: will return to the original tempo (so the notes will end as scheduled). A subsequent link::#-play:: will cut-off any sounding notes and resume play at the original tempo.
@section{method}
stop
can cut-off or shorten sounding notes, depending on the value of tempo. If stopTempo is nil, all notes are cut-off immediately. Otherwise, notes end at the specified tempo.
@section{Examples}
@racketblock[
(
// a pattern with long notes
p = Pbind(
\freq, Pwhite(0,log(32)).exp.round(1) * 36.midicps,
\detune, Pfunc({ | ev | ev[\freq] * rand(0.01) }),
\sustain, Pwhite(log(0.1), log(20)).exp,
\dur, Prand([0.1,0.1,0.1,0.1,0.2,1,2],inf),
\db, Pstep(Pseq([-20,-30,-25,-30], inf),0.2)
);
// unrelated cluster pattern running on TempoClock.default
Pbind(\dur,2, \midinote, Pseq([(48..60)],20), \db, -30).play;
// make a conductor
a = PatternConductor(p, quant: 2);
a.play;
)
// now try some interactive control options line by line:
a.quant = 0;
a.pause;
a.resume;
a.stop;
a.play;
a.pause;
a.play;
a.stop(1000);
::
]