Last active
July 26, 2019 04:45
-
-
Save dyfer/425bb6a085588be35e329e7a409024f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CtkBuffer sync method | |
// get a folder of files | |
FileDialog({|path| ~path = path}, {}, 2, 0, true); | |
~path; | |
// or set manually | |
// ~path = /path/to/files | |
~path.openOS | |
s.reboot | |
s.dumpOSC(0) | |
//----------- | |
// using {}.play | |
//----------- | |
//CtkBuffer and {}.play | |
( | |
CtkObj.latency_(nil); | |
fork{ | |
var arr; | |
~bufs !? {~bufs.flat.do(_.free); ~bufs = nil}; | |
s.sync; | |
1.wait; // just in case to account for system memory management time | |
arr = [true, false].collect({|bool| | |
var list = List(); | |
var sync = bool; | |
var start = thisThread.seconds; | |
PathName(~path).filesDo{arg pathname; | |
list.add(CtkBuffer(pathname.fullPath).load(sync: sync)) | |
}; | |
"------------".postln; | |
postf("using CtkBuffer and {}.play\nsync: %\n% files loaded in % seconds\n", sync, list.size, (thisThread.seconds - start).round(0.001)); | |
{PlayBuf.ar(2, list.last, doneAction: 2)}.play; | |
s.sync; | |
postf("synth started after % seconds\n", (thisThread.seconds - start).round(0.001)); | |
list; //return buffers | |
}); | |
if(~bufs.isNil, {~bufs = arr}, {~bufs = ~bufs.add(arr)}); | |
} | |
) | |
//Buffer and {}.play | |
( | |
fork{ | |
var arr; | |
~bufs !? {~bufs.flat.do(_.free); ~bufs = nil}; | |
s.sync; | |
1.wait; // just in case to account for system memory management time | |
arr = [true, false].collect({|bool| | |
var list = List(); | |
var sync = bool; | |
var start = thisThread.seconds; | |
PathName(~path).filesDo{arg pathname; | |
list.add(Buffer.read(s, pathname.fullPath)); | |
if(sync, {s.sync}); | |
}; | |
"------------".postln; | |
postf("using Buffer and {}.play\nsync: %\n% files loaded in % seconds\n", sync, list.size, (thisThread.seconds - start).round(0.001)); | |
{PlayBuf.ar(2, list.last, doneAction: 2)}.play; | |
s.sync; | |
postf("synth started after % seconds\n", (thisThread.seconds - start).round(0.001)); | |
list; //return buffers | |
}); | |
if(~bufs.isNil, {~bufs = arr}, {~bufs = ~bufs.add(arr)}); | |
} | |
) | |
//------------------ | |
// using a synthdef | |
//------------------ | |
SynthDef(\pb2, {|buffer = 0, out = 0| Out.ar(out, PlayBuf.ar(2, buffer, doneAction: 2))}).add; | |
//CtkBuffer and {}.play | |
( | |
CtkObj.latency_(nil); | |
fork{ | |
var arr; | |
~bufs !? {~bufs.flat.do(_.free); ~bufs = nil}; | |
s.sync; | |
1.wait; // just in case to account for system memory management time | |
arr = [true, false].collect({|bool| | |
var list = List(); | |
var sync = bool; | |
var start = thisThread.seconds; | |
PathName(~path).filesDo{arg pathname; | |
list.add(CtkBuffer(pathname.fullPath).load(sync: sync)) | |
}; | |
"------------".postln; | |
postf("using CtkBuffer and Synth\nsync: %\n% files loaded in % seconds\n", sync, list.size, (thisThread.seconds - start).round(0.001)); | |
Synth(\pb2, [\buffer, list.last.bufnum]); | |
s.sync; | |
postf("synth started after % seconds\n", (thisThread.seconds - start).round(0.001)); | |
list; //return buffers | |
}); | |
if(~bufs.isNil, {~bufs = arr}, {~bufs = ~bufs.add(arr)}); | |
} | |
) | |
//Buffer and {}.play | |
( | |
fork{ | |
var arr; | |
~bufs !? {~bufs.flat.do(_.free); ~bufs = nil}; | |
s.sync; | |
1.wait; // just in case to account for system memory management time | |
arr = [true, false].collect({|bool| | |
var list = List(); | |
var sync = bool; | |
var start = thisThread.seconds; | |
PathName(~path).filesDo{arg pathname; | |
list.add(Buffer.read(s, pathname.fullPath)); | |
if(sync, {s.sync}); | |
}; | |
"------------".postln; | |
postf("using Buffer and Synth\nsync: %\n% files loaded in % seconds\n", sync, list.size, (thisThread.seconds - start).round(0.001)); | |
Synth(\pb2, [\buffer, list.last.bufnum]); | |
s.sync; | |
postf("synth started after % seconds\n", (thisThread.seconds - start).round(0.001)); | |
list; //return buffers | |
}); | |
if(~bufs.isNil, {~bufs = arr}, {~bufs = ~bufs.add(arr)}); | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment