A FluidBufCompose object provides a flexible utility for combining the contents of buffers on the server. It can be used for thing like mixing down multichannel buffers, or converting from left-right stereo to mid-side. We use it extensively in our example code.
A FluidBufCompose object provides a flexible utility for combining the contents of buffers on the server. It can be used for thing like mixing down multichannel buffers, or converting from left-right stereo to mid-side. We use it extensively in our example code.
At its most simple, the object copies the content of two source buffers into a destination buffer. The flexibility comes from the various flags controlling which portions and channels of the sources to use, and by applying gains (which can be positive or negative) to the source data.
At its most simple, the object copies the content of a source buffer into a destination buffer. The flexibility comes from the various flags controlling which portions and channels of the sources to use, and by applying gains (which can be positive or negative) to the source data and the portion of the destination that would be overwritten.
It is part of the Fluid Decomposition Toolkit of the FluCoMa project. footnote::
It is part of the Fluid Decomposition Toolkit of the FluCoMa project. footnote::
This was made possible thanks to the FluCoMa project ( http://www.flucoma.org/ ) funded by the European Research Council ( https://erc.europa.eu/ ) under the European Union’s Horizon 2020 research and innovation programme (grant agreement No 725899).::
This was made possible thanks to the FluCoMa project ( http://www.flucoma.org/ ) funded by the European Research Council ( https://erc.europa.eu/ ) under the European Union’s Horizon 2020 research and innovation programme (grant agreement No 725899).::
The algorithm takes two buffers in, and writes the composited information at the provided dstBuf. These buffer arguments can all point to the same buffer, which gives great flexibility in transforming and reshaping.
The algorithm takes a srcBuf, and writes the information at the provided dstBuf. These buffer arguments can all point to the same buffer, which gives great flexibility in transforming and reshaping.
CLASSMETHODS::
CLASSMETHODS::
@ -23,62 +23,41 @@ METHOD:: process
ARGUMENT:: server
ARGUMENT:: server
The server on which the buffers to be processed are allocated.
The server on which the buffers to be processed are allocated.
ARGUMENT:: srcBufNumA
ARGUMENT:: srcBufNum
The bufNum of the first source buffer.
The bufNum of the source buffer.
ARGUMENT:: startAtA
ARGUMENT:: startAt
The starting point (in samples) from which to copy in the first source buffer.
The starting point (in samples) from which to copy in the source buffer.
ARGUMENT:: nFramesA
ARGUMENT:: nFrames
The duration (in samples) to copy from the first source buffer.
The duration (in samples) to copy from the source buffer.
ARGUMENT:: startChanA
ARGUMENT:: startChan
The first channel from which to copy in the first source buffer.
The first channel from which to copy in the source buffer.
ARGUMENT:: nChansA
ARGUMENT:: nChans
The number of channels from which to copy in the first source buffer. This parameter will wrap around the number of channels in the source buffer.
The number of channels from which to copy in the source buffer. This parameter will wrap around the number of channels in the source buffer.
ARGUMENT:: srcGainA
ARGUMENT:: srcGain
The gain applied to the samples to be copied from the first source buffer.
The gain applied to the samples to be copied from the source buffer.
ARGUMENT:: dstStartAtA
ARGUMENT:: dstBufNum
The time offset (in samples) in the destination buffer to start writing the first source at. The destination buffer will be resized if the portion to copy is overflowing.
The bufNum of the destination buffer.
ARGUMENT:: dstStartChanA
The channel offest in the destination buffer to start writing the first source at. The destination buffer will be resized if the number of channels to copy is overflowing.
ARGUMENT:: srcBufNumB
The bufNum of the second source buffer.
ARGUMENT:: startAtB
The starting point (in samples) from which to copy in the second source buffer.
ARGUMENT:: nFramesB
The duration (in samples) to copy from the second source buffer.
ARGUMENT:: startChanB
The first channel from which to copy in the second source buffer.
ARGUMENT:: nChansB
The number of channels from which to copy in the second source buffer. This parameter will wrap around the number of channels in the source buffer.
ARGUMENT:: srcGainB
The gain applied to the samples to be copied from the second source buffer.
ARGUMENT:: dstStartAtB
ARGUMENT:: dstStartAt
The time offset (in samples) in the destination buffer to start writing the second source at. The destination buffer will be resized if the portion to copy is overflowing.
The time offset (in samples) in the destination buffer to start writing the source at. The destination buffer will be resized if the portion to copy is overflowing.
ARGUMENT:: dstStartChanB
ARGUMENT:: dstStartChan
The channel offest in the destination buffer to start writing the second source at. The destination buffer will be resized if the number of channels to copy is overflowing.
The channel offest in the destination buffer to start writing the source at. The destination buffer will be resized if the number of channels to copy is overflowing.
ARGUMENT:: dstBufNum
ARGUMENT:: dstGain
The bufNum of the destination buffer.
The gain applied to the samples in the region of the destination buffer over which the source is to be copied. The default value of 0. would overwrite completely, and a value of 1.0 would sum the source to the material that was present.
RETURNS::
RETURNS::
Nothing, as the various destination buffers are declared in the function call.
Nothing, as the various destination buffers are declared in the function call.
DISCUSSION::
DISCUSSION::
It is important to understand the rules used for determining the final desintinaiton buffer dimensions to get the most out of this object. The destination buffer will be resized to the maxima of the requsted source numFrames and numChannels, independently of whether the source buffers are that big or not. Frames will be written up to the limit of actually available samples (meaning you can create zero padding);channels will be written modulo the available channels, taking into account the channel offsets, meaning you can have channels repeat or loop into the desintation buffer's channels. See the examples below.
It is important to understand the rules used for determining the final desintinaiton buffer dimensions to get the most out of this object. If needs be, the destination buffer will be resized to the maxima of the requsted source numFrames and numChannels. Frames will be written up to the limit of actually available samples (meaning you can create zero padding); channels will be written modulo the available channels, taking into account the channel offsets, meaning you can have channels repeat or loop into the source buffer's channels. See the examples below.
EXAMPLES::
EXAMPLES::
@ -91,31 +70,31 @@ d = Buffer.new(s);
)
)
// with basic params (basic summing of each full buffer in all dimensions)
// with basic params (basic summing of each full buffer in all dimensions)
STRONG::A more complex example: using composition as an Mid-Side filtering process::
STRONG::A more complex example: using composition as an Mid-Side filtering process::
@ -126,14 +105,16 @@ e.play;
b = Buffer.read(s,File.realpath(FluidBufCompose.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Tremblay-SA-UprightPianoPedalWide.wav");
b = Buffer.read(s,File.realpath(FluidBufCompose.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Tremblay-SA-UprightPianoPedalWide.wav");
FluidBufCompose.process(s,d.bufnum,srcGainA: x, dstStartAtA: y, srcBufNumB: e.bufnum, dstBufNum: e.bufnum);
FluidBufCompose.process(s, d.bufnum, srcGain: x, dstStartAt: y, dstBufNum: e.bufnum, dstGain: 1.0);
});
});
)
)
// play the high-passed side buffer
// play the high-passed side buffer
e.query;
e.play;
e.play;
// if you want to try the other filters, do not forget to clear the destination buffer since it will add programmatically onto itself and would not create the expected frequency response
// if you want to try the other filters, do not forget to clear the destination buffer since it will add programmatically onto itself and would not create the expected frequency response