hey,
im currently trying to find a good solution for preparing wavetables for beeing used with OscOS using FluidBufCompose. This is Not so much a technical question but more one about different practices.
I would normally use something like this in my startup file to store waveforms from different subfolders into a dictionary.
~path = PathName(thisProcess.nowExecutingPath).parentPath ++ "samples";
~makeBuffers = {
~samples = Dictionary.new;
PathName(~path).entries.do{ |subfolder|
var soundfiles = Array.fill(subfolder.entries.size,{ |i|
Buffer.read(s, subfolder.entries[i].fullPath);
});
~samples.add(subfolder.folderName.asSymbol -> soundfiles);
};
};
I was wondering how i should set up the function for FluidBufCompose. If the waveforms are loaded already into a dictionary i can just access them without having to do that again here. But probably i would not need to store them one by one in a dictionary any more then.
There is also the option to save them to disc and then just load the final tables into a dictionary in the startup file. Ideally i would like to boot the server and then have the tables available.
How are you going about that? Are you composing them beforehand and storing them to disc? How many waveforms are you using per table? Are you just using single-cycle waveforms or also multiple cycles per waveform?
(
~processAndLoadWaveforms = { |sourceFolderName|
var baseFolder = ~path ++ "/" ++ sourceFolderName;
var sourceBuffers, composedBuffer, totalFrames;
/*
// Load files into buffers
sourceBuffers = PathName(baseFolder).entries.collect{ |file|
Buffer.read(s, file.fullPath);
};
*/
sourceBuffers = [0, 4, 20].collect{ |bufnum|
~samples[\single_cycles][bufnum]
};
s.sync;
// Compose the buffers
totalFrames = sourceBuffers.collect{ |buffer|
buffer.numFrames
}.sum;
composedBuffer = Buffer.alloc(s, totalFrames);
sourceBuffers.do{ |srcBuf, i|
var startPos = i * srcBuf.numFrames;
FluidBufCompose.processBlocking(
server: s,
source: srcBuf,
destination: composedBuffer,
startFrame: 0,
numFrames: -1,
destStartFrame: startPos
);
};
/*
// Save the composed buffer
composedBuffer.write(
~path ++ "/" ++ sourceFolderName ++ "_composed.wav",
headerFormat: "WAV",
sampleFormat: "float"
);
*/
// [sourceBuffers, composedBuffer];
composedBuffer;
};
)
(
Routine({
~waveTable = ~processAndLoadWaveforms.();
}).play;
)