mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-31 03:00:05 +00:00
Fixed the AudioSampleBuffer copy-constructor's behaviour to match its description.
This commit is contained in:
parent
ca40721527
commit
dd1a3496c2
2 changed files with 22 additions and 16 deletions
|
|
@ -22,25 +22,33 @@
|
|||
==============================================================================
|
||||
*/
|
||||
|
||||
AudioSampleBuffer::AudioSampleBuffer (const int numChannels_,
|
||||
AudioSampleBuffer::AudioSampleBuffer (const int numChans,
|
||||
const int numSamples) noexcept
|
||||
: numChannels (numChannels_),
|
||||
: numChannels (numChans),
|
||||
size (numSamples)
|
||||
{
|
||||
jassert (numSamples >= 0);
|
||||
jassert (numChannels_ > 0);
|
||||
jassert (numChans > 0);
|
||||
|
||||
allocateData();
|
||||
}
|
||||
|
||||
AudioSampleBuffer::AudioSampleBuffer (const AudioSampleBuffer& other) noexcept
|
||||
: numChannels (other.numChannels),
|
||||
size (other.size)
|
||||
size (other.size),
|
||||
allocatedBytes (other.allocatedBytes)
|
||||
{
|
||||
allocateData();
|
||||
if (allocatedBytes == 0)
|
||||
{
|
||||
allocateChannels (other.channels, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
allocateData();
|
||||
|
||||
for (int i = 0; i < numChannels; ++i)
|
||||
FloatVectorOperations::copy (channels[i], other.channels[i], size);
|
||||
for (int i = 0; i < numChannels; ++i)
|
||||
FloatVectorOperations::copy (channels[i], other.channels[i], size);
|
||||
}
|
||||
}
|
||||
|
||||
void AudioSampleBuffer::allocateData()
|
||||
|
|
@ -61,25 +69,25 @@ void AudioSampleBuffer::allocateData()
|
|||
}
|
||||
|
||||
AudioSampleBuffer::AudioSampleBuffer (float* const* dataToReferTo,
|
||||
const int numChannels_,
|
||||
const int numChans,
|
||||
const int numSamples) noexcept
|
||||
: numChannels (numChannels_),
|
||||
: numChannels (numChans),
|
||||
size (numSamples),
|
||||
allocatedBytes (0)
|
||||
{
|
||||
jassert (numChannels_ > 0);
|
||||
jassert (numChans > 0);
|
||||
allocateChannels (dataToReferTo, 0);
|
||||
}
|
||||
|
||||
AudioSampleBuffer::AudioSampleBuffer (float* const* dataToReferTo,
|
||||
const int numChannels_,
|
||||
const int numChans,
|
||||
const int startSample,
|
||||
const int numSamples) noexcept
|
||||
: numChannels (numChannels_),
|
||||
: numChannels (numChans),
|
||||
size (numSamples),
|
||||
allocatedBytes (0)
|
||||
{
|
||||
jassert (numChannels_ > 0);
|
||||
jassert (numChans > 0);
|
||||
allocateChannels (dataToReferTo, startSample);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,16 +96,14 @@ public:
|
|||
AudioSampleBuffer (const AudioSampleBuffer& other) noexcept;
|
||||
|
||||
/** Copies another buffer onto this one.
|
||||
|
||||
This buffer's size will be changed to that of the other buffer.
|
||||
*/
|
||||
AudioSampleBuffer& operator= (const AudioSampleBuffer& other) noexcept;
|
||||
|
||||
/** Destructor.
|
||||
|
||||
This will free any memory allocated by the buffer.
|
||||
*/
|
||||
virtual ~AudioSampleBuffer() noexcept;
|
||||
~AudioSampleBuffer() noexcept;
|
||||
|
||||
//==============================================================================
|
||||
/** Returns the number of channels of audio data that this buffer contains.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue