SuperCollider CLASSES

Rest

Represents a rest in event patterns
Inherits from: Object

Description

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.

Expressing rests in event patterns

In addition to the Rest class, rests can be specified in two other ways (legacy usages).

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.

Usage

Class Methods

All methods of Rest except *new are private, and should not be used directly.

*new (dur: 1)

Create an instance of Rest, with a value to be used in the resulting rest event.

Arguments:

dur

Typically, Rest instances will be used in duration streams, so the argument should be the rest's rhythmic value, or duration. Rest instances may also be used in any other stream, but the value will be ignored (since the event will do nothing except take time).

Inherited class methods

Undocumented class methods

*isRest

Instance Methods

Inherited instance methods

Undocumented instance methods

-isRest

-value

Examples

Using the Rest class in a pitch stream

p = Pbind(
    \degree, Pif(
        0.1.loop.coin,
        Rest,
        Pseries(0, 1, inf).fold(-7, 7)
    ),
    \dur, 0.125
).play;

p.stop;

Using a Rest instance in a duration stream

p = Pbind(
    \degree, Pseries(0, 1, inf).fold(-7, 7),
    \dur, Pseq([Pn(0.125, { rrand(3, 6) }), Rest(0.25)], inf)
).play;

p.stop;

How it works

When a Pbind child pattern returns a Rest, the Rest object sets a flag 'isRest' in the resulting event to be true. The child pattern's value in the event is a number. This is to prevent math errors if Rest is used in a pitch or duration stream (degree, note, midiNote, freq, dur, delta, stretch).

When a Rest is returned from a child stream, the rest object itself will not appear in the event. You can tell that the event is a rest by the presence of 'isRest': true.

p = Pbind(\degree, Pseq([4, Rest], 1)).asStream;

p.next(());
// prints: ( 'degree': 4 )

p.next(());
// prints: ( 'isRest': true, 'degree': 1 )

That is, the importance of the Rest object is not that it appears in the event. The importance is the side effect that this object has on the resulting event.