This commit is contained in:
nik gaffney 2018-05-14 12:15:50 +02:00
parent 6547ef0a08
commit f91f193fab

View file

@ -52,8 +52,8 @@ if ( ~now.year == 1970,
~file = ~sources.choose; ~file = ~sources.choose;
~file.postln; ~file.postln;
// read file then play buffer // cue file form disk then play
Buffer.read (server: s, path: ~prefix++~file, action: ~play1); Buffer.cueSoundFile (server: s, path: ~prefix++~file, action: ~play1);
}; };
~foreground = { ~foreground = {
@ -86,7 +86,7 @@ if ( ~now.year == 1970,
Routine { Routine {
"~play [bg - ".post; b1.path.post; "]".postln; "~play [bg - ".post; b1.path.post; "]".postln;
{(PlayBuf.ar(1, b1, rate: 1, loop: 0, doneAction: 2) * 0.1).dup }.play.waitForFree; {(Diskin.ar(1, b1, loop: 0) * 0.1).dup }.play.waitForFree;
// free buffer once done? // free buffer once done?
"freed [bg - ".post; b1.path.post; "]".postln; "freed [bg - ".post; b1.path.post; "]".postln;
@ -124,27 +124,3 @@ s.waitForBoot {
// 167/31 -> 175/31 -> 168/31 // 167/31 -> 175/31 -> 168/31
// via http://danielnouri.org/docs/SuperColliderHelp/Tutorials/Getting-Started/Buffers.html
// Streaming a File in From Disk
// In some cases, for instance when working with very large files, you might not want to load a sound completely into memory. Instead, you can stream it in from disk a bit at a time, using the UGen DiskIn, and Buffer's 'cueSoundFile' method:
// (
// SynthDef("tutorial-Buffer-cue",{ arg out=0,bufnum;
// Out.ar(out,
// DiskIn.ar( 1, bufnum )
// )
// }).send(s);
// )
// b = Buffer.cueSoundFile(s,"sounds/a11wlk01-44_1.aiff", 0, 1);
// y = Synth.new("tutorial-Buffer-cue", [\bufnum,b.bufnum], s);
// b.free; y.free;
// This is not as flexible as PlayBuf (no rate control), but can save memory.