A Rest may be used in event patterns to indicate that the resulting event should be a rest (i.e., silent). It should be used in one of the child patterns belonging to a Pbind, for instance.
// do nothing for 2 seconds
(note:Rest(), dur:2).play;
// intersperse pauses in pattern
Pbind(\note, Pseq([0, 4, 7, 11], inf), \dur, Pseq([2, 1, Rest(1)], inf) / 5).play;
The Rest class allows rests to be indicated in any stream, not only frequency or event type. Also, using the duration argument (see the *new method below), rests may be embedded into a duration stream. That is, rests may be treated as part of the rhythmic specification, rather than the pitch specification.
Rest
's behavior has changed to be more intuitive. Note that you have to now use Rest()
- the shortcut of Rest
as class directly is not supported anymore.Rest
instance, the Rest
class, or either of the symbols \
or \r
. If any item meets the condition, the event will be considered a rest and it will not take action when played.Rest(1) * 2 == Rest(2)
.All methods of Rest except *new are private, and should not be used directly.
Create an instance of Rest, with a value to be used in the resulting rest event.
value |
The Rest instance's numeric value, to be used in math operations. Note that a Rest's value is ignored for most Event keys (assuming the Event does nothing in response to |
xxxxxxxxxx
a = Rest(6);
b = a * 2; // returns Rest(12)
b = 2 * a; // the same
b.value; // returns 12
The rest of a rest is always a rest. This idempotence is implemented by Rest's superclass Operand.
xxxxxxxxxx
Rest(Rest(1)) // returns Rest(1)
returns true
returns the value.
This method implements the following behavior.
xxxxxxxxxx
Rest(6) + 1 // Rest(7)
Rest(true) // true
This makes comparisons work:
xxxxxxxxxx
Rest(6) < 7 // true, and not Rest(true)
a = Pseq([1, 2, 1, 3, Rest(1), 2, Rest(3)], inf); // e.g. as a duration pattern
b = a.collect { |x| if(x > 2) { x / 2 } { x } };
b.asStream.nextN(8)
Using Rest instances in a pitch stream
xxxxxxxxxx
(
Pbind(
\degree, Pif(
0.1.loop.coin,
Pseq([Rest(), 7], inf), // every second is a Rest
Pseries(0, 1, inf).fold(-7, 7)
),
\dur, 0.125
).play
)
Using a Rest instance in a duration stream
xxxxxxxxxx
(
Pbind(
\degree, Pseries(0, 1, inf).fold(-7, 7),
\dur, Pseq([Pn(0.125, { rrand(3, 6) }), Rest(0.25)], inf)
).play
)
In addition to Rest, in events, rests can be specified in two other ways (legacy usages).
xxxxxxxxxx
(
p = Pbind(
\degree, Pseq([
0, 1, 2, 0, 0, 1, 2, 0,
2, 3, 4, \rest, 2, 3, 4, \rest
]),
\dur, 0.25
).play;
)
xxxxxxxxxx
(
p = Pbind(
\degree, Pseries(0, 1, inf).fold(-7, 7),
\dur, 0.125,
\type, Pwrand([\note, \rest], [0.9, 0.1], inf)
).play;
)
p.stop;