2 summary:: A resettable linear ramp between two levels.
3 categories:: UGens>Triggers, UGens>Buffer
8 Phasor is a linear ramp between start and end values. When its trigger
9 input crosses from non-positive to positive, Phasor's output will jump to
10 its reset position. Upon reaching the end of its ramp Phasor will wrap
15 N.B. Since end is defined as the wrap point, its value is never
19 Phasor is commonly used as an index control with link::Classes/BufRd::
20 and link::Classes/BufWr:: .
29 When triggered, jump to resetPos (default: 0, equivalent to
35 The amount of change per sample, i.e at a rate of 1 the value of
36 each sample will be 1 greater than the preceding sample.
41 Start point of the ramp.
46 End point of the ramp.
51 The value to jump to upon receiving a trigger.
58 // phasor controls sine frequency: end frequency matches a second sine wave.
61 { var trig, rate, x, sr;
62 rate = MouseX.kr(0.2, 2, 1);
63 trig = Impulse.ar(rate);
65 x = Phasor.ar(trig, rate / sr);
68 LinLin.kr(x, 0, 1, 600, 1000), // convert range from 0..1 to 600..1000
69 1000 // constant second frequency
76 // two phasors control two sine frequencies: mouse y controls resetPos of the second
78 { var trig, rate, x, sr;
79 rate = MouseX.kr(1, 200, 1);
80 trig = Impulse.ar(rate);
82 x = Phasor.ar(trig, rate / sr, 0, 1, [0, MouseY.kr(0, 1)]);
83 SinOsc.ar(x * 500 + 500, 0, 0.2)
88 // use phasor to index into a sound file
90 // allocate a buffer with a sound file
91 b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav");
93 // simple playback (more examples: see BufRd)
94 // Start and end here are defined as 0 and the number of frames in the buffer.
95 // This means that the Phasor will output values from 0 to numFrames - 1 before looping,
96 // which is perfect for driving BufRd. (See note above)
97 { BufRd.ar(1, b.bufnum, Phasor.ar(0, BufRateScale.kr(b.bufnum), 0, BufFrames.kr(b.bufnum))) }.play;
100 // two phasors control two sound file positions: mouse y controls resetPos of the second
102 { var trig, rate, framesInBuffer;
103 rate = MouseX.kr(0.1, 100, 1);
104 trig = Impulse.ar(rate);
105 framesInBuffer = BufFrames.kr(b.bufnum);
106 x = Phasor.ar(trig, BufRateScale.kr(b.bufnum), 0, framesInBuffer,
107 [0, MouseY.kr(0, framesInBuffer)]);
108 BufRd.ar(1, b.bufnum, x);