2 summary:: Record or overdub into a Buffer.
3 related:: Classes/PlayBuf
4 categories:: UGens>Buffer
7 Records input into a link::Classes/Buffer::.
9 If recLevel is 1.0 and preLevel is 0.0 then the new input overwrites the
10 old data. If they are both 1.0 then the new data is added to the existing
11 data. (Any other settings are also valid.)
13 note:: The number of channels must be fixed for the SynthDef, it cannot vary depending on which buffer you use. ::
20 An Array of input channels.
23 The index of the buffer to use.
26 An offset into the buffer in samples.
29 Value to multiply by input before mixing with existing data.
32 Value to multiply to existing data in buffer before mixing with input.
35 If zero, then recording stops, otherwise recording proceeds.
38 If zero then don't loop, otherwise do. This is modulatable.
41 a trigger causes a jump to the start of the Buffer. A trigger
42 occurs when a signal changes from negative value to positive
46 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.
51 // Execute the following in order
55 b = Buffer.alloc(s, 44100 * 4.0, 1); // a four second 1 channel Buffer
58 // record for four seconds
60 SynthDef(\help_RecordBuf, { arg out = 0, bufnum = 0;
62 formant = Formant.ar(XLine.kr(400,1000, 4), 2000, 800, 0.125);
63 RecordBuf.ar(formant, bufnum, doneAction: 2, loop: 0);
64 }).play(s,[\out, 0, \bufnum, b]);
69 SynthDef(\help_RecordBuf_overdub, { arg out = 0, bufnum = 0;
71 playbuf = PlayBuf.ar(1,bufnum);
72 FreeSelfWhenDone.kr(playbuf); // frees the synth when the PlayBuf is finished
74 }).play(s, [\out, 0, \bufnum, b]);
79 SynthDef(\help_RecordBuf_overdub, { arg out=0, bufnum=0;
81 formant = Formant.ar(XLine.kr(200, 1000, 4), 2000, 800, 0.125);
82 // mixes equally with existing data
83 RecordBuf.ar(formant, bufnum, 0, 0.5, 0.5, doneAction: 2, loop: 0);
84 }).play(s, [\out, 0, \bufnum, b]);
87 // play back the overdubbed version
88 Synth.new(\help_RecordBuf_overdub, [\out, 0, \bufnum, b], s);
90 // write the contents of the buffer to a file (see Buffer for more options)
92 b.write(sampleFormat: 'int16');
93 thisProcess.platform.recordingsDir +/+ "SC_" ++ Date.localtime.stamp ++ ".aiff"; // generated path
96 b.close; b.free; // cleanup