1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-07 04:10:08 +00:00

Added an overload to allow AudioBuffer reference data to contain an offset

This commit is contained in:
tpoole 2017-02-15 16:13:22 +00:00
parent 61ae28b060
commit 73ca34d7b6

View file

@ -405,11 +405,13 @@ public:
it when the buffer is deleted or resized.
@param newNumChannels the number of channels to use - this must correspond to the
number of elements in the array passed in
@param newStartSample the offset within the arrays at which the data begins
@param newNumSamples the number of samples to use - this must correspond to the
size of the arrays passed in
*/
void setDataToReferTo (Type** dataToReferTo,
const int newNumChannels,
const int newStartSample,
const int newNumSamples) noexcept
{
jassert (dataToReferTo != nullptr);
@ -424,10 +426,35 @@ public:
numChannels = newNumChannels;
size = newNumSamples;
allocateChannels (dataToReferTo, 0);
allocateChannels (dataToReferTo, newStartSample);
jassert (! isClear);
}
/** Makes this buffer point to a pre-allocated set of channel data arrays.
There's also a constructor that lets you specify arrays like this, but this
lets you change the channels dynamically.
Note that if the buffer is resized or its number of channels is changed, it
will re-allocate memory internally and copy the existing data to this new area,
so it will then stop directly addressing this memory.
@param dataToReferTo a pre-allocated array containing pointers to the data
for each channel that should be used by this buffer. The
buffer will only refer to this memory, it won't try to delete
it when the buffer is deleted or resized.
@param newNumChannels the number of channels to use - this must correspond to the
number of elements in the array passed in
@param newNumSamples the number of samples to use - this must correspond to the
size of the arrays passed in
*/
void setDataToReferTo (Type** dataToReferTo,
const int newNumChannels,
const int newNumSamples) noexcept
{
setDataToReferTo (dataToReferTo, newNumChannels, 0, newNumSamples);
}
/** Resizes this buffer to match the given one, and copies all of its content across.
The source buffer can contain a different floating point type, so this can be used to
convert between 32 and 64 bit float buffer types.