VDiskIn stream in audio from a file (with variable rate)



DiskIn.ar(numChannels, bufnum, rate, loop )


Continuously play a longer soundfile from disk.  This requires a buffer to be preloaded with one buffer size of sound. If loop is set to 1, the soundfile will loop.


rate controls the rate of playback. Values below 4 are probably fine, but the higher the value, the more disk activity there is, and the more likelihood there will be a problem.


WARNING: the rate does have a practical limit. The following must be true: 

(rate * s.options.blockSize) / Buffer's size < 0.5

If the rate is too high, the UGen will not execute, and you will see this warning


pitch ratio is greater then max allowed (see VDiskIn help)


See also: PlayBuf, BufRd 




Using Buffer (Object Style)


b = Buffer.cueSoundFile(s, "sounds/a11wlk01-44_1.aiff", 0, 1);


x = { VDiskIn.ar(1, b, LFNoise2.kr(0.2).range(0.5, 2), 1) }.play;


b.close;


// again

// note the like named instance method, but different arguments

b.cueSoundFile("sounds/a11wlk01-44_1.aiff", 0);

x.free; b.close; b.free;



// cue and play right away

(

SynthDef("help-VDiskin", { arg bufnum = 0;

Out.ar(0, VDiskIn.ar(1, bufnum, MouseX.kr(0.5, 2.0)));

}).send(s);

)

(

x = Synth.basicNew("help-VDiskin");

m = { arg buf; x.addToHeadMsg(nil, [\bufnum, buf])};


b = Buffer.cueSoundFile(s,"sounds/a11wlk01-44_1.aiff",0,1, completionMessage: m);

)


x.free; b.close; b.free; //clean up




OSC Messaging Style


// allocate a disk i/o buffer

s.sendMsg("/b_alloc", 0, 65536, 1);


// open an input file for this buffer, leave it open

s.sendMsg("/b_read", 0, "sounds/a11wlk01-44_1.aiff", 0, 65536, 0, 1);


// create a diskin node

s.sendMsg("/s_new", "help-VDiskin", x = s.nextNodeID, 1, 1);


s.sendMsg("/b_close", 0); // close the file (very important!)



// again 

// don't need to reallocate and Synth is still reading

s.sendMsg("/b_read", 0, "sounds/a11wlk01-44_1.aiff", 0, 0, 0, 1);


s.sendMsg("/n_free", x); // stop reading


s.sendMsg("/b_close", 0); // close the file.


s.sendMsg("/b_free", 0); // frees the buffer