2 summary:: Sample playback oscillator.
3 related:: Classes/RecordBuf, Classes/DiskIn, Classes/BufRd
4 categories:: UGens>Buffer
8 Plays back a sample resident in memory.
15 Number of channels that the buffer will be. This must be a fixed
16 integer. The architechture of the SynthDef cannot change after it
20 The index of the buffer to use.
22 If you supply a bufnum of a buffer with a differing number of channels
23 than the one specified in this PlayBuf, it will fail silently.
27 1.0 is the server's sample rate, 2.0 is one octave up, 0.5 is one
28 octave down -1.0 is backwards normal rateā¦ etc. Interpolation
33 A trigger causes a jump to the startPos. A trigger occurs when a
34 signal changes from negative value to positive value.
37 Sample frame to start playback.
40 1 means true, 0 means false. This is modulateable.
43 an integer representing an action to be executed when the buffer is finished playing. This can be used to free the enclosing synth, etc. See link::Reference/UGen-doneActions:: for more detail. code::doneAction:: is only evaluated if loop is 0.
48 s.boot // Boot the server, if you need to
50 // read a whole sound into memory
51 // note: not *that* columbia, the first one
52 b = Buffer.read(s, Help.dir +/+ "sounds/a11wlk01.wav"); // remember to free the buffer later.
54 SynthDef(\help_PlayBuf, {| out = 0, bufnum = 0 |
56 PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), doneAction:2)
58 }).play(s, [\out, 0, \bufnum, b]);
61 In the above example, note how the code::doneAction:2:: causes the synth to free itself when the buffer reaches its end.
63 Note again that the number of channels must be fixed for the SynthDef. It cannot vary depending on which buffer you use.
67 SynthDef(\help_PlayBuf, {| out = 0, bufnum = 0 |
69 PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), loop: 1.0)
71 }).play(s, [\out, 0, \bufnum, b]);
74 // trigger one shot on each pulse
75 SynthDef(\help_PlayBuf, {| out = 0, bufnum = 0 |
77 trig = Impulse.kr(2.0);
79 PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), trig, 0, 0)
81 }).play(s, [\out, 0, \bufnum, b]);
84 // trigger one shot on each pulse
85 SynthDef(\help_PlayBuf, {| out = 0, bufnum = 0 |
87 trig = Impulse.kr(XLine.kr(0.1, 100, 30));
89 PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), trig, 5000, 0)
91 }).play(s, [\out, 0, \bufnum, b]);
94 // mouse control of trigger rate and startpos
95 SynthDef(\help_PlayBuf, { arg out=0, bufnum=0;
97 trig = Impulse.kr(MouseY.kr(0.5, 200, 1));
99 PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), trig, MouseX.kr(0, BufFrames.kr(bufnum)), 1)
101 }).play(s, [\out, 0, \bufnum, b]);
104 // accelerating pitch
105 SynthDef(\help_PlayBuf, {| out = 0, bufnum = 0 |
107 rate = XLine.kr(0.1, 100, 60);
109 PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum)*rate, 1.0, 0.0, 1.0)
111 }).play(s, [\out, 0, \bufnum, b]);
114 // sine wave control of playback rate. negative rate plays backwards
115 SynthDef(\help_PlayBuf, {| out = 0, bufnum = 0 |
117 rate = FSinOsc.kr(XLine.kr(0.2, 8, 30), 0, 3, 0.6);
119 PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum) * rate, 1, 0, 1)
121 }).play(s, [\out, 0, \bufnum, b]);
124 // zig zag around sound
125 SynthDef(\help_PlayBuf, {| out = 0, bufnum = 0 |
127 rate = LFNoise2.kr(XLine.kr(1, 20, 60), 2);
129 PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum) * rate, 1, 0, 1)
131 }).play(s, [\out, 0, \bufnum, b]);