Writing FluidBufNMF components to files

Hello all,

would there be any straightforward (non realtime) methods to write the FluidBufNMF components to files in SC?
I was hoping to circumvent having to use Buf objects in NRT, as the multiple buffer allocation will probably be quite a challenge… (or are there learning resources on how to combine NRT and FluCoMa Buf objects?)
Thanks,
Jan

Hi @jan,

You mean saving the output of FluidBufNMF run in normal mode to file so you can open them again and use in NRT mode? Because the components are Buffers, using the write method and saving them as audio files should work. For the bases and activations, they would be weird audio files, but it should work nonetheless. The only caveat is that libsndfile, which SC uses, won’t deal with files of > 1024 channels.

As for NRT mode, I don’t have much wisdom to offer (although I think @tedmoore dabbled at some point). What I can say is that using the FluidBuf objects in non-blocking mode absolutely won’t work, but with processBlocking things might well be ok.

1 Like

Hi @weefuzzy,
yes exactly, that is the idea. With straightforward i meant a way to write each component of the buffer to a single file instead of a multichannel one as it happens with .write …i haven’t found that solution yet!
Thanks for the hint regarding the NRT processing. I have the feeling while it would a great accomplishment to bridge Flucoma Buf objects and NRT its probably also opening a pandoras box (at least to me) regarding these issues!

There doesn’t seem to be a built-in way of writing just one channel, indeed. One possibility would be to use FluidBufSelect to copy out each channel before writing. Another possibility would be to write multichannel and only read one in at a time using Buffer.readChannel

Thank you @weefuzzy, i’ll look into FluidBufSelect that seems like a very helpful tool for this!

Hi @jan,

What @weefuzzy says is true, I did dabble for a bit looking at using FluCoMa on the SuperCollider server in NRT mode. Since then the toolkit has evolved and the thing I was trying to do would be done in a different (better) way.

Regarding writing the output of a BufNMF analysis to separate files, here’s a bit of code I’ve used many times:

(
~audio = Buffer.read(s,FluidFilesPath("Nicol-LoopE-M.wav"));
~resynth = Buffer(s);
~writeBuf = Buffer(s);
~nComps = 3;
FluidBufNMF.processBlocking(s,~audio,resynth:~resynth,components:~nComps);
~nComps.do{
	arg i;
	var path = "/Users/macprocomputer/Desktop/resynth_chan_%.wav".format(i);
	FluidBufSelect.processBlocking(s,~resynth,~writeBuf,channels:[i]);
	~writeBuf.write(path,"wav");
	path.postln;
};
)
1 Like

Thanks @tedmoore,
i came up with a very similar little code with BufSelect, not quite as concise though!:wink: