2 summary:: Record to a soundfile to disk.
3 related:: Classes/RecordBuf, Classes/DiskIn
4 categories:: UGens>InOut, UGens>Buffer
7 Record to a soundfile to disk. Uses a link::Classes/Buffer::.
9 See link::Classes/RecordBuf:: for recording into a buffer in memory.
17 The number of the buffer to write to (prepared with /b-write or
19 Note:: The Buffer's numFrames must be a power of two and is recommended to be at least 65536 -- preferably 131072 or 262144. Smaller buffer sizes mean more frequent disk access, which can cause glitches. ::
21 argument::channelsArray
22 The Array of channels to write to the file.
23 Note:: The number of channels in the buffer and the channelsArray must be the same, otherwise DiskOut will fail silently (and not write anything to your file). ::
25 returns:: The number of frames written to disk.
32 s.boot; // start the server
34 // something to record
37 f = LFSaw.kr(0.4, 0, 24, LFSaw.kr([8,7.23], 0, 3, 80)).midicps; // glissando function
38 zout = CombN.ar(SinOsc.ar(f, 0, 0.04), 0.2, 0.2, 4); // echoing sine wave
42 // this will record to the disk
43 SynthDef("help-Diskout", {arg bufnum;
44 DiskOut.ar(bufnum, In.ar(0,2));
47 // this will play it back
48 SynthDef("help-Diskin-2chan", { arg bufnum = 0;
49 Out.ar(0, DiskIn.ar(2, bufnum));
54 subsection:: Object Style
56 // start something to record
57 x = Synth.new("bubbles");
59 // allocate a disk i/o buffer
60 b= Buffer.alloc(s, 65536, 2);
62 // create an output file for this buffer, leave it open
63 b.write("~/diskouttest.aiff".standardizePath, "aiff", "int16", 0, 0, true);
64 // create the diskout node; making sure it comes after the source
65 d = Synth.tail(nil, "help-Diskout", ["bufnum", b]);
70 // close the buffer and the soundfile
77 x = Synth.basicNew("help-Diskin-2chan");
78 m = { arg buf; x.addToHeadMsg(nil, [\bufnum,buf])};
80 b = Buffer.cueSoundFile(s,"~/diskouttest.aiff".standardizePath, 0, 2, completionMessage: m);
82 x.free; b.close; b.free; // cleanup
85 subsection:: Messaging Style
87 // The same thing done in Messaging Style (less overhead but without the convienence of objects)
88 // start something to record
89 s.sendMsg("/s_new", "bubbles", 2003, 1, 1);
91 // allocate a disk i/o buffer
92 s.sendMsg("/b_alloc", 0, 65536, 2); // Buffer number is 0
94 // create an output file for this buffer, leave it open
95 s.sendMsg("/b_write", 0, "~/diskouttest.aiff".standardizePath, "aiff", "int16", 0, 0, 1);
97 // create the diskout node
98 s.sendMsg("/s_new", "help-Diskout", 2004, 3, 2003, "bufnum", 0);
100 s.sendMsg("/n_free", 2004); // stop recording
101 s.sendMsg("/n_free", 2003); // stop the bubbles
103 s.sendMsg("/b_close", 0); // close the file.
104 s.sendMsg("/b_free", 0);