Okay, it just takes a lot of time when i have a few more subfolders with soundfiles.
Done a test with 1 soundfile in 1 subfolder then all the Synth Nodes are gone right away.
The Problem now is, accessing the analysed soundfiles via the Pattern Library causes heavy Server Overload, up to 140%. Same SynthDef with hardcoded path for sndBuf/recBuf ca. 7%. I already have read this thread Performance of SC on OSX about better using Arrays.
The question now is: how can I use an Array instead of a Dictionary in this case or are there any other solutions?
For PV_BinBufRd I would need an Array including one SubArray for the sndBuf and one SubArray for the corresponding recBufs with their different rates. thanks alot.
(
s.waitForBoot({
s.sync;
~path = PathName(thisProcess.nowExecutingPath).parentPath ++ "samples/";
// the frame size for the analysis - experiment with other sizes (powers of 2)
~windowSize = 1024;
// the hop size
~hopSize = 0.25;
// Hann window
~winType = 1;
//different playback rates
~rates = (1..12) * 0.1 + 0.4;
~buffers = Dictionary.new;
PathName(~path).entries.do {
arg subfolder;
var soundfile, data;
~buffers.add(
subfolder.folderName.asSymbol ->
Array.fill(
subfolder.entries.size,
{
arg i;
// read size of Soundfiles
soundfile = SoundFile.openRead(subfolder.entries[i].fullPath);
protect {
(
pvRecBuf: ~rates.collect { |rate, i|
Buffer.alloc(s, (soundfile.duration / rate).calcPVRecSize(~windowSize, ~hopSize))
},
sndBuf: Buffer.read(s, subfolder.entries[i].fullPath)
)
} { |err|
if(err.notNil) {
"Error opening '%'".format(subfolder.entries[i].fullPath.basename).warn;
};
soundfile.close
};
}
);
);
};
// this does the analysis and saves it to ~recBufs... frees itself when done (in addition uses rate)
SynthDef(\pvrec, {
arg recBuf, soundBufnum, rate = 1;
var in, chain;
Line.kr(1, 1, BufDur.kr(soundBufnum) / rate, doneAction: 2);
in = PlayBuf.ar(1, soundBufnum, rate * BufRateScale.kr(soundBufnum), loop: 0);
chain = FFT(LocalBuf(~windowSize), in, ~hopSize, ~winType);
chain = PV_RecordBuf(chain, recBuf, 0, 1, 0, ~hopSize, ~winType);
}).add;
s.sync;
~buffers.do { |subdirArray|
subdirArray.do { |buf|
~rates.do { |rate, i|
Synth(\pvrec, [
\recBuf, buf.pvRecBuf[i],
\soundBufnum, buf.sndBuf,
\rate, rate
]);
};
};
};
s.sync;
"fft analysis done".postln;
});
)