sclang: ServerShmInterface - try to avoid multiple destructor calls
[supercollider.git] / HelpSource / Classes / Pmulpre.schelp
blobc069da8206a686983a4d2c8d3a075039cc903da3
1 class:: Pmulpre
2 summary:: multiplies with value of a key in event stream, before it is passed up
3 related:: Classes/Pmul, Classes/Pmulp
4 categories:: Streams-Patterns-Events>Patterns>Math
6 description::
8 Multiplies with a value in an event, strong::before it is passed up:: the stream. To multiply with the value after it has been passed down, use link::Classes/Pmul::.
10 code::
12 var a, b;
13 a = Pmulpre(\note, 2, Pbind(\note, Pseq([1, 2, 3])));
14 x = a.asStream;
15 9.do({ x.next(Event.default).postln; });
19 Pmulpre does not override incoming values:
20 code::
22 var a, b;
23 a = Pmulpre(\freq, 801, Pset(\freq, 500, Pbind(\dur, 0.2)));
24 x = a.asStream;
25 9.do({ x.next(Event.default).postln; });
29 ClassMethods::
31 method::new
33 argument::value
34 can be a pattern or a stream. The resulting stream ends when that incoming stream ends.
36 Examples::
38 code::
40 var a, b;
41 a = Pmulpre(\freq, Pseq([401, 801], 2), Pbind(\dur, 0.5));
42 x = a.asStream;
43 9.do({ x.next(Event.new).postln; });
47 code::
48 //sound example
50 SynthDef(\sinegrain,
51         { arg out=0, freq=440, sustain=0.02;
52                 var env;
53                 env = EnvGen.kr(Env.perc(0.001, sustain), 1, doneAction:2);
54                 Out.ar(out, SinOsc.ar(freq, 0, env * 0.1))
55         }).add;
59 a = Pbind(\dur, 0.5, \instrument, \sinegrain);
60 b = Pmulpre(\freq, Pseq([1, 2, 3], inf), a);
61 b.play;