Is there a way to create a mono buffer from a stereo file where both channels are combined?
There might be a simpler way, but this works for me:
// load a stereo sound file
b = Buffer.read(s, Platform.resourceDir +/+ "sounds/SinedPink.aiff");
b.numChannels; // 2
(
b.loadToFloatArray(action: { |array|
d = Buffer.loadCollection(s, array.unlace(2).sum * 0.5
});
)
d.numChannels; // 1
Replace the 0.5
constant with -3.dbamp
(≈ 1/sqrt(2) ≈ 0.707) for uncorrelated signals.
If you want to keep it all on the server, the FluCoMa extension has a tool that can do this:
(
b = Buffer.read(s, Platform.resourceDir +/+ "sounds/SinedPink.aiff");
c = Buffer(s);
FluidBufCompose.processBlocking(s,b,numChans:1,destination:c,gain:-6.dbamp);
FluidBufCompose.processBlocking(s,b,startChan:1,numChans:1,destination:c,gain:-6.dbamp,destGain:1);
)
b.numChannels; // 2
c.numChannels; // 1
b.play;
c.play;
b.plot
c.plot
2 Likes