[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-users] Free a collection of buffers for reuse?
I have a function called ~changesamples, below. This reads through one of a
number of subfolders of a folder called 'bfsamples', and then loads the
samples found in the named subfolder into an array called ~bufs. Problem is:
say I evaluate ~changesamples.("hitz01") to load buffers 0-9 with ten
samples. If I now evaluate ~changesamples.("soh"), the new files are loaded
into buffers 10-19, and buffers 0-9 are not freed.
In a previous version of the function, I had Buffer.freeAll in before the
new files were loaded, which seemed to work. However, now have other
collections of buffers elsewhere in my project that I do not want to be
freed when ~changesamples executes.
I'm guessing that this is some sort of race condition betwen the old buffers
being freed and the new ones filled, as it works if I run these lines one at
a time. Any ideas how to do this? Thanks!
(
~changesamples = {
|x="hitz01"|
~bufs = [Buffer.new]; // initialise ~bufs to something
if ( "hitz01 soh hamburg iowaphil emf nl".find(x) != nil, // checking the
subfolder is correct
{ var path = "../bfsamples/".resolveRelative ++ x ++ "/";
var files = (path ++ "*.aiff").pathMatch ++ (path ++ "*.aif").pathMatch;
// first, free all the buffers in ~bufs
~bufs.collect({|i| i.free});
// now, read the new files into ~bufs
~bufs = files.collect({ |i| Buffer.read(s, i)});
},
{"that's not a sample folder".error; nil});
};
)
-----
--
J. Simon van der Walt
jsimonvanderwalt.com
twitter.com/tedthetrumpet
--
View this message in context: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/Free-a-collection-of-buffers-for-reuse-tp7629824.html
Sent from the SuperCollider Users New (Use this!!!!) mailing list archive at Nabble.com.
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/