SuperCollider CLASSES

Pevent

Provide an inval for an event stream.
Inherits from: Pattern : AbstractFunction : Object

This pattern is mainly used in two cases:

using an event pattern as a stream directly
a = Pbind(\note, Prand([1, 2, 3], inf)).asStream;
a.next; // returns nil
a = Pevent(Pbind(\note, Prand([1, 2, 3], inf))).asStream;
a.next; // returns an event
setting some default values before they are processed by the pattern
Pevent(Pbind(\harmonic, Pseq([24, 25, 29, 30], inf)), (octave: 3, dur: 0.2)).trace.play;
Pevent is a simpler form of Pchain, so that these are equivalent:
Pevent(pattern, event)
Pchain(pattern, event)
pattern <> event

By contrast to Pchain, Pevent uses an Event: *default if nothing is provided.

Class Methods

*new (pattern, event)

Arguments:

pattern

pattern or stream that returns or modifies events.

event

an event with objects to embed. If none is provided, it uses Event: *default.

Inherited class methods

Instance Methods

Inherited instance methods

Undocumented instance methods

-embedInStream (inval)

-event

-event = value

-pattern

-pattern = value

Examples

(
SynthDef(\help_sinegrain,
        { arg out=0, freq=440, sustain=0.05;
                var env;
                env = EnvGen.kr(Env.perc(0.01, sustain, 0.2), doneAction:2);
                Out.ar(out, SinOsc.ar(freq, 0, env))
    }).add;

a = Pn(
    Plazy({
        Pbind(
            \instrument, \help_sinegrain,
            \freq, Pgeom(rrand(200, 600), rrand(1.001, 1.01), rrand(10, 100)).wrap(100, 15000),
            \dur, Pgeom(rrand(0.2, 0.3), rrand(0.99, 0.92))
        )
    })
);


Tdef(\x, {
    var str = Pevent(a).asStream, event;
    loop {
        event = str.next;
        if(event[\freq] % 50 < 20) { event[\freq] = event[\freq] * [1, 1.2, 1.5] };
        event.play;
        event[\dur].wait;
    }

}).play;
)