hey, i have implemented ~path and ~makeBuffers in order to analyse multiple soundfiles. how has ~soundfile, ~recBufs and ~rates.do from the PV_BufRd helpfile to be changed to do the analysis for multiple soundfiles when booting the server? thanks.
(
// path to a sound files here
~path = PathName(thisProcess.nowExecutingPath).parentPath++"buffers/";
// 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;
// get some info about the files
~soundfile = SoundFile.new(~path);
~soundfile.openRead;
~soundfile.close;
~rates = (1..12) * 0.1 + 0.4;
// FFT buffers from different lengths
~recBufs = ~rates.collect {
arg rate, i;
Buffer.alloc(s, (~soundfile.duration / rate).calcPVRecSize(~windowSize, ~hopSize));
};
// allocate the soundfiles you want to analyze
~makeBuffers = {
~samples = Dictionary.new;
PathName(~path).entries.do{
arg subfolder;
~samples.add(
subfolder.folderName.asSymbol ->
Array.fill(
subfolder.entries.size,
{
arg i;
Buffer.read(s, subfolder.entries[i].fullPath);
}
)
);
};
};
ServerBoot.add(~makeBuffers);
)
// this does the analysis and saves it to buffer 1... frees itself when done
// analysis SynthDef (in addition uses rate)
(
SynthDef(\pvrec_2, {
arg recBuf, soundBufnum, rate = 1;
var in, chain, bufnum;
bufnum = LocalBuf.new(~windowSize);
Line.kr(1, 1, BufDur.kr(soundBufnum) / rate, doneAction: 2);
in = PlayBuf.ar(1, soundBufnum, rate * BufRateScale.kr(soundBufnum), loop: 0);
chain = FFT(bufnum, in, ~hopSize, ~winType);
chain = PV_RecordBuf(chain, recBuf, 0, 1, 0, ~hopSize, ~winType);
}).add;
)
// make analysis of same buffers played back at different speeds
(
~rates.do {
arg rate, i;
Synth(\pvrec_2, [\recBuf, ~recBufs[i], \soundBufnum, ~samples, \rate, rate])
};
)