Loading...
Searching...
No Matches
juce_AudioSampleBuffer.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
//==============================================================================
template <typename Type>
class AudioBuffer
{
public:
//==============================================================================
AudioBuffer() noexcept
: channels (static_cast<Type**> (preallocatedChannelSpace))
{
}
//==============================================================================
AudioBuffer (int numChannelsToAllocate,
int numSamplesToAllocate)
: numChannels (numChannelsToAllocate),
size (numSamplesToAllocate)
{
jassert (size >= 0 && numChannels >= 0);
allocateData();
}
AudioBuffer (Type* const* dataToReferTo,
int numChannelsToUse,
int numSamples)
: numChannels (numChannelsToUse),
size (numSamples)
{
jassert (dataToReferTo != nullptr);
jassert (numChannelsToUse >= 0 && numSamples >= 0);
allocateChannels (dataToReferTo, 0);
}
AudioBuffer (Type* const* dataToReferTo,
int numChannelsToUse,
int startSample,
int numSamples)
: numChannels (numChannelsToUse),
size (numSamples)
{
jassert (dataToReferTo != nullptr);
jassert (numChannelsToUse >= 0 && startSample >= 0 && numSamples >= 0);
allocateChannels (dataToReferTo, startSample);
}
AudioBuffer (const AudioBuffer& other)
: numChannels (other.numChannels),
size (other.size),
allocatedBytes (other.allocatedBytes)
{
if (allocatedBytes == 0)
{
allocateChannels (other.channels, 0);
}
else
{
allocateData();
if (other.isClear)
{
clear();
}
else
{
for (int i = 0; i < numChannels; ++i)
FloatVectorOperations::copy (channels[i], other.channels[i], size);
}
}
}
AudioBuffer& operator= (const AudioBuffer& other)
{
if (this != &other)
{
setSize (other.getNumChannels(), other.getNumSamples(), false, false, false);
if (other.isClear)
{
clear();
}
else
{
isClear = false;
for (int i = 0; i < numChannels; ++i)
FloatVectorOperations::copy (channels[i], other.channels[i], size);
}
}
return *this;
}
~AudioBuffer() = default;
AudioBuffer (AudioBuffer&& other) noexcept
: numChannels (other.numChannels),
size (other.size),
allocatedBytes (other.allocatedBytes),
allocatedData (std::move (other.allocatedData)),
isClear (other.isClear)
{
if (numChannels < (int) numElementsInArray (preallocatedChannelSpace))
{
channels = preallocatedChannelSpace;
for (int i = 0; i < numChannels; ++i)
preallocatedChannelSpace[i] = other.channels[i];
}
else
{
channels = other.channels;
}
other.numChannels = 0;
other.size = 0;
other.allocatedBytes = 0;
}
AudioBuffer& operator= (AudioBuffer&& other) noexcept
{
numChannels = other.numChannels;
size = other.size;
allocatedBytes = other.allocatedBytes;
allocatedData = std::move (other.allocatedData);
isClear = other.isClear;
if (numChannels < (int) numElementsInArray (preallocatedChannelSpace))
{
channels = preallocatedChannelSpace;
for (int i = 0; i < numChannels; ++i)
preallocatedChannelSpace[i] = other.channels[i];
}
else
{
channels = other.channels;
}
other.numChannels = 0;
other.size = 0;
other.allocatedBytes = 0;
return *this;
}
//==============================================================================
int getNumChannels() const noexcept { return numChannels; }
int getNumSamples() const noexcept { return size; }
const Type* getReadPointer (int channelNumber) const noexcept
{
jassert (isPositiveAndBelow (channelNumber, numChannels));
return channels[channelNumber];
}
const Type* getReadPointer (int channelNumber, int sampleIndex) const noexcept
{
jassert (isPositiveAndBelow (channelNumber, numChannels));
jassert (isPositiveAndBelow (sampleIndex, size));
return channels[channelNumber] + sampleIndex;
}
Type* getWritePointer (int channelNumber) noexcept
{
jassert (isPositiveAndBelow (channelNumber, numChannels));
isClear = false;
return channels[channelNumber];
}
Type* getWritePointer (int channelNumber, int sampleIndex) noexcept
{
jassert (isPositiveAndBelow (channelNumber, numChannels));
jassert (isPositiveAndBelow (sampleIndex, size));
isClear = false;
return channels[channelNumber] + sampleIndex;
}
const Type* const* getArrayOfReadPointers() const noexcept { return channels; }
Type* const* getArrayOfWritePointers() noexcept { isClear = false; return channels; }
//==============================================================================
void setSize (int newNumChannels,
int newNumSamples,
bool keepExistingContent = false,
bool clearExtraSpace = false,
bool avoidReallocating = false)
{
jassert (newNumChannels >= 0);
jassert (newNumSamples >= 0);
if (newNumSamples != size || newNumChannels != numChannels)
{
auto allocatedSamplesPerChannel = ((size_t) newNumSamples + 3) & ~3u;
auto channelListSize = ((static_cast<size_t> (1 + newNumChannels) * sizeof (Type*)) + 15) & ~15u;
auto newTotalBytes = ((size_t) newNumChannels * (size_t) allocatedSamplesPerChannel * sizeof (Type))
+ channelListSize + 32;
if (keepExistingContent)
{
if (avoidReallocating && newNumChannels <= numChannels && newNumSamples <= size)
{
// no need to do any remapping in this case, as the channel pointers will remain correct!
}
else
{
HeapBlock<char, true> newData;
newData.allocate (newTotalBytes, clearExtraSpace || isClear);
auto numSamplesToCopy = (size_t) jmin (newNumSamples, size);
auto newChannels = unalignedPointerCast<Type**> (newData.get());
auto newChan = unalignedPointerCast<Type*> (newData + channelListSize);
for (int j = 0; j < newNumChannels; ++j)
{
newChannels[j] = newChan;
newChan += allocatedSamplesPerChannel;
}
if (! isClear)
{
auto numChansToCopy = jmin (numChannels, newNumChannels);
for (int i = 0; i < numChansToCopy; ++i)
FloatVectorOperations::copy (newChannels[i], channels[i], (int) numSamplesToCopy);
}
allocatedData.swapWith (newData);
allocatedBytes = newTotalBytes;
channels = newChannels;
}
}
else
{
if (avoidReallocating && allocatedBytes >= newTotalBytes)
{
if (clearExtraSpace || isClear)
allocatedData.clear (newTotalBytes);
}
else
{
allocatedBytes = newTotalBytes;
allocatedData.allocate (newTotalBytes, clearExtraSpace || isClear);
channels = unalignedPointerCast<Type**> (allocatedData.get());
}
auto* chan = unalignedPointerCast<Type*> (allocatedData + channelListSize);
for (int i = 0; i < newNumChannels; ++i)
{
channels[i] = chan;
chan += allocatedSamplesPerChannel;
}
}
channels[newNumChannels] = nullptr;
size = newNumSamples;
numChannels = newNumChannels;
}
}
void setDataToReferTo (Type* const* dataToReferTo,
int newNumChannels,
int newStartSample,
int newNumSamples)
{
jassert (dataToReferTo != nullptr);
jassert (newNumChannels >= 0 && newNumSamples >= 0);
if (allocatedBytes != 0)
{
allocatedBytes = 0;
allocatedData.free();
}
numChannels = newNumChannels;
size = newNumSamples;
allocateChannels (dataToReferTo, newStartSample);
jassert (! isClear);
}
void setDataToReferTo (Type* const* dataToReferTo,
int newNumChannels,
int newNumSamples)
{
setDataToReferTo (dataToReferTo, newNumChannels, 0, newNumSamples);
}
template <typename OtherType>
void makeCopyOf (const AudioBuffer<OtherType>& other, bool avoidReallocating = false)
{
setSize (other.getNumChannels(), other.getNumSamples(), false, false, avoidReallocating);
if (other.hasBeenCleared())
{
clear();
}
else
{
isClear = false;
for (int chan = 0; chan < numChannels; ++chan)
{
auto* dest = channels[chan];
auto* src = other.getReadPointer (chan);
for (int i = 0; i < size; ++i)
dest[i] = static_cast<Type> (src[i]);
}
}
}
//==============================================================================
void clear() noexcept
{
if (! isClear)
{
for (int i = 0; i < numChannels; ++i)
{
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4661)
FloatVectorOperations::clear (channels[i], size);
JUCE_END_IGNORE_WARNINGS_MSVC
}
isClear = true;
}
}
void clear (int startSample, int numSamples) noexcept
{
jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
if (! isClear)
{
for (int i = 0; i < numChannels; ++i)
FloatVectorOperations::clear (channels[i] + startSample, numSamples);
isClear = (startSample == 0 && numSamples == size);
}
}
void clear (int channel, int startSample, int numSamples) noexcept
{
jassert (isPositiveAndBelow (channel, numChannels));
jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
if (! isClear)
FloatVectorOperations::clear (channels[channel] + startSample, numSamples);
}
bool hasBeenCleared() const noexcept { return isClear; }
void setNotClear() noexcept { isClear = false; }
//==============================================================================
Type getSample (int channel, int sampleIndex) const noexcept
{
jassert (isPositiveAndBelow (channel, numChannels));
jassert (isPositiveAndBelow (sampleIndex, size));
return *(channels[channel] + sampleIndex);
}
void setSample (int destChannel, int destSample, Type newValue) noexcept
{
jassert (isPositiveAndBelow (destChannel, numChannels));
jassert (isPositiveAndBelow (destSample, size));
*(channels[destChannel] + destSample) = newValue;
isClear = false;
}
void addSample (int destChannel, int destSample, Type valueToAdd) noexcept
{
jassert (isPositiveAndBelow (destChannel, numChannels));
jassert (isPositiveAndBelow (destSample, size));
*(channels[destChannel] + destSample) += valueToAdd;
isClear = false;
}
void applyGain (int channel, int startSample, int numSamples, Type gain) noexcept
{
jassert (isPositiveAndBelow (channel, numChannels));
jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
if (! approximatelyEqual (gain, Type (1)) && ! isClear)
{
auto* d = channels[channel] + startSample;
if (approximatelyEqual (gain, Type()))
FloatVectorOperations::clear (d, numSamples);
else
FloatVectorOperations::multiply (d, gain, numSamples);
}
}
void applyGain (int startSample, int numSamples, Type gain) noexcept
{
for (int i = 0; i < numChannels; ++i)
applyGain (i, startSample, numSamples, gain);
}
void applyGain (Type gain) noexcept
{
applyGain (0, size, gain);
}
void applyGainRamp (int channel, int startSample, int numSamples,
Type startGain, Type endGain) noexcept
{
if (! isClear)
{
if (approximatelyEqual (startGain, endGain))
{
applyGain (channel, startSample, numSamples, startGain);
}
else
{
jassert (isPositiveAndBelow (channel, numChannels));
jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
const auto increment = (endGain - startGain) / (float) numSamples;
auto* d = channels[channel] + startSample;
while (--numSamples >= 0)
{
*d++ *= startGain;
startGain += increment;
}
}
}
}
void applyGainRamp (int startSample, int numSamples,
Type startGain, Type endGain) noexcept
{
for (int i = 0; i < numChannels; ++i)
applyGainRamp (i, startSample, numSamples, startGain, endGain);
}
void addFrom (int destChannel,
int destStartSample,
const AudioBuffer& source,
int sourceChannel,
int sourceStartSample,
int numSamples,
Type gainToApplyToSource = Type (1)) noexcept
{
jassert (&source != this
|| sourceChannel != destChannel
|| sourceStartSample + numSamples <= destStartSample
|| destStartSample + numSamples <= sourceStartSample);
jassert (isPositiveAndBelow (destChannel, numChannels));
jassert (destStartSample >= 0 && numSamples >= 0 && destStartSample + numSamples <= size);
jassert (isPositiveAndBelow (sourceChannel, source.numChannels));
jassert (sourceStartSample >= 0 && sourceStartSample + numSamples <= source.size);
if (! approximatelyEqual (gainToApplyToSource, (Type) 0) && numSamples > 0 && ! source.isClear)
{
auto* d = channels[destChannel] + destStartSample;
auto* s = source.channels[sourceChannel] + sourceStartSample;
JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4661)
if (isClear)
{
isClear = false;
if (! approximatelyEqual (gainToApplyToSource, Type (1)))
FloatVectorOperations::copyWithMultiply (d, s, gainToApplyToSource, numSamples);
else
FloatVectorOperations::copy (d, s, numSamples);
}
else
{
if (! approximatelyEqual (gainToApplyToSource, Type (1)))
FloatVectorOperations::addWithMultiply (d, s, gainToApplyToSource, numSamples);
else
FloatVectorOperations::add (d, s, numSamples);
}
JUCE_END_IGNORE_WARNINGS_MSVC
}
}
void addFrom (int destChannel,
int destStartSample,
const Type* source,
int numSamples,
Type gainToApplyToSource = Type (1)) noexcept
{
jassert (isPositiveAndBelow (destChannel, numChannels));
jassert (destStartSample >= 0 && numSamples >= 0 && destStartSample + numSamples <= size);
jassert (source != nullptr);
if (! approximatelyEqual (gainToApplyToSource, Type()) && numSamples > 0)
{
auto* d = channels[destChannel] + destStartSample;
if (isClear)
{
isClear = false;
if (! approximatelyEqual (gainToApplyToSource, Type (1)))
FloatVectorOperations::copyWithMultiply (d, source, gainToApplyToSource, numSamples);
else
FloatVectorOperations::copy (d, source, numSamples);
}
else
{
if (! approximatelyEqual (gainToApplyToSource, Type (1)))
FloatVectorOperations::addWithMultiply (d, source, gainToApplyToSource, numSamples);
else
FloatVectorOperations::add (d, source, numSamples);
}
}
}
void addFromWithRamp (int destChannel,
int destStartSample,
const Type* source,
int numSamples,
Type startGain,
Type endGain) noexcept
{
if (approximatelyEqual (startGain, endGain))
{
addFrom (destChannel, destStartSample, source, numSamples, startGain);
}
else
{
jassert (isPositiveAndBelow (destChannel, numChannels));
jassert (destStartSample >= 0 && numSamples >= 0 && destStartSample + numSamples <= size);
jassert (source != nullptr);
if (numSamples > 0)
{
isClear = false;
const auto increment = (endGain - startGain) / (Type) numSamples;
auto* d = channels[destChannel] + destStartSample;
while (--numSamples >= 0)
{
*d++ += startGain * *source++;
startGain += increment;
}
}
}
}
void copyFrom (int destChannel,
int destStartSample,
const AudioBuffer& source,
int sourceChannel,
int sourceStartSample,
int numSamples) noexcept
{
jassert (&source != this
|| sourceChannel != destChannel
|| sourceStartSample + numSamples <= destStartSample
|| destStartSample + numSamples <= sourceStartSample);
jassert (isPositiveAndBelow (destChannel, numChannels));
jassert (destStartSample >= 0 && destStartSample + numSamples <= size);
jassert (isPositiveAndBelow (sourceChannel, source.numChannels));
jassert (sourceStartSample >= 0 && numSamples >= 0 && sourceStartSample + numSamples <= source.size);
if (numSamples > 0)
{
if (source.isClear)
{
if (! isClear)
FloatVectorOperations::clear (channels[destChannel] + destStartSample, numSamples);
}
else
{
isClear = false;
FloatVectorOperations::copy (channels[destChannel] + destStartSample,
source.channels[sourceChannel] + sourceStartSample,
numSamples);
}
}
}
void copyFrom (int destChannel,
int destStartSample,
const Type* source,
int numSamples) noexcept
{
jassert (isPositiveAndBelow (destChannel, numChannels));
jassert (destStartSample >= 0 && numSamples >= 0 && destStartSample + numSamples <= size);
jassert (source != nullptr);
if (numSamples > 0)
{
isClear = false;
FloatVectorOperations::copy (channels[destChannel] + destStartSample, source, numSamples);
}
}
void copyFrom (int destChannel,
int destStartSample,
const Type* source,
int numSamples,
Type gain) noexcept
{
jassert (isPositiveAndBelow (destChannel, numChannels));
jassert (destStartSample >= 0 && numSamples >= 0 && destStartSample + numSamples <= size);
jassert (source != nullptr);
if (numSamples > 0)
{
auto* d = channels[destChannel] + destStartSample;
if (! approximatelyEqual (gain, Type (1)))
{
if (approximatelyEqual (gain, Type()))
{
if (! isClear)
FloatVectorOperations::clear (d, numSamples);
}
else
{
isClear = false;
FloatVectorOperations::copyWithMultiply (d, source, gain, numSamples);
}
}
else
{
isClear = false;
FloatVectorOperations::copy (d, source, numSamples);
}
}
}
void copyFromWithRamp (int destChannel,
int destStartSample,
const Type* source,
int numSamples,
Type startGain,
Type endGain) noexcept
{
if (approximatelyEqual (startGain, endGain))
{
copyFrom (destChannel, destStartSample, source, numSamples, startGain);
}
else
{
jassert (isPositiveAndBelow (destChannel, numChannels));
jassert (destStartSample >= 0 && numSamples >= 0 && destStartSample + numSamples <= size);
jassert (source != nullptr);
if (numSamples > 0)
{
isClear = false;
const auto increment = (endGain - startGain) / (Type) numSamples;
auto* d = channels[destChannel] + destStartSample;
while (--numSamples >= 0)
{
*d++ = startGain * *source++;
startGain += increment;
}
}
}
}
Range<Type> findMinMax (int channel, int startSample, int numSamples) const noexcept
{
jassert (isPositiveAndBelow (channel, numChannels));
jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
if (isClear)
return { Type (0), Type (0) };
return FloatVectorOperations::findMinAndMax (channels[channel] + startSample, numSamples);
}
Type getMagnitude (int channel, int startSample, int numSamples) const noexcept
{
jassert (isPositiveAndBelow (channel, numChannels));
jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
if (isClear)
return Type (0);
auto r = findMinMax (channel, startSample, numSamples);
return jmax (r.getStart(), -r.getStart(), r.getEnd(), -r.getEnd());
}
Type getMagnitude (int startSample, int numSamples) const noexcept
{
Type mag (0);
if (! isClear)
for (int i = 0; i < numChannels; ++i)
mag = jmax (mag, getMagnitude (i, startSample, numSamples));
return mag;
}
Type getRMSLevel (int channel, int startSample, int numSamples) const noexcept
{
jassert (isPositiveAndBelow (channel, numChannels));
jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
if (numSamples <= 0 || channel < 0 || channel >= numChannels || isClear)
return Type (0);
auto* data = channels[channel] + startSample;
double sum = 0.0;
for (int i = 0; i < numSamples; ++i)
{
auto sample = data[i];
sum += sample * sample;
}
return static_cast<Type> (std::sqrt (sum / numSamples));
}
void reverse (int channel, int startSample, int numSamples) const noexcept
{
jassert (isPositiveAndBelow (channel, numChannels));
jassert (startSample >= 0 && numSamples >= 0 && startSample + numSamples <= size);
if (! isClear)
std::reverse (channels[channel] + startSample,
channels[channel] + startSample + numSamples);
}
void reverse (int startSample, int numSamples) const noexcept
{
for (int i = 0; i < numChannels; ++i)
reverse (i, startSample, numSamples);
}
//==============================================================================
using SampleType = Type;
private:
//==============================================================================
void allocateData()
{
#if (! JUCE_GCC || (__GNUC__ * 100 + __GNUC_MINOR__) >= 409)
static_assert (alignof (Type) <= maxAlignment,
"AudioBuffer cannot hold types with alignment requirements larger than that guaranteed by malloc");
#endif
jassert (size >= 0);
auto channelListSize = (size_t) (numChannels + 1) * sizeof (Type*);
auto requiredSampleAlignment = std::alignment_of_v<Type>;
size_t alignmentOverflow = channelListSize % requiredSampleAlignment;
if (alignmentOverflow != 0)
channelListSize += requiredSampleAlignment - alignmentOverflow;
allocatedBytes = (size_t) numChannels * (size_t) size * sizeof (Type) + channelListSize + 32;
allocatedData.malloc (allocatedBytes);
channels = unalignedPointerCast<Type**> (allocatedData.get());
auto chan = unalignedPointerCast<Type*> (allocatedData + channelListSize);
for (int i = 0; i < numChannels; ++i)
{
channels[i] = chan;
chan += size;
}
channels[numChannels] = nullptr;
isClear = false;
}
void allocateChannels (Type* const* dataToReferTo, int offset)
{
jassert (offset >= 0);
// (try to avoid doing a malloc here, as that'll blow up things like Pro-Tools)
if (numChannels < (int) numElementsInArray (preallocatedChannelSpace))
{
channels = static_cast<Type**> (preallocatedChannelSpace);
}
else
{
allocatedData.malloc (numChannels + 1, sizeof (Type*));
channels = unalignedPointerCast<Type**> (allocatedData.get());
}
for (int i = 0; i < numChannels; ++i)
{
// you have to pass in the same number of valid pointers as numChannels
jassert (dataToReferTo[i] != nullptr);
channels[i] = dataToReferTo[i] + offset;
}
channels[numChannels] = nullptr;
isClear = false;
}
/* On iOS/arm7 the alignment of `double` is greater than the alignment of
`std::max_align_t`, so we can't trust max_align_t. Instead, we query
lots of primitive types and use the maximum alignment of all of them.
*/
static constexpr size_t getMaxAlignment() noexcept
{
constexpr size_t alignments[] { alignof (std::max_align_t),
alignof (void*),
alignof (float),
alignof (double),
alignof (long double),
alignof (short int),
alignof (int),
alignof (long int),
alignof (long long int),
alignof (bool),
alignof (char),
alignof (char16_t),
alignof (char32_t),
alignof (wchar_t) };
size_t max = 0;
for (const auto elem : alignments)
max = jmax (max, elem);
return max;
}
int numChannels = 0, size = 0;
size_t allocatedBytes = 0;
Type** channels;
HeapBlock<char, true> allocatedData;
Type* preallocatedChannelSpace[32];
bool isClear = false;
static constexpr size_t maxAlignment = getMaxAlignment();
JUCE_LEAK_DETECTOR (AudioBuffer)
};
//==============================================================================
template <typename Type>
bool operator== (const AudioBuffer<Type>& a, const AudioBuffer<Type>& b)
{
if (a.getNumChannels() != b.getNumChannels())
return false;
for (auto c = 0; c < a.getNumChannels(); ++c)
{
const auto begin = [c] (auto& x) { return x.getReadPointer (c); };
const auto end = [c] (auto& x) { return x.getReadPointer (c) + x.getNumSamples(); };
if (! std::equal (begin (a), end (a), begin (b), end (b)))
return false;
}
return true;
}
template <typename Type>
bool operator!= (const AudioBuffer<Type>& a, const AudioBuffer<Type>& b)
{
return ! (a == b);
}
//==============================================================================
using AudioSampleBuffer = AudioBuffer<float>;
} // namespace juce
juce::AudioBuffer
Definition juce_AudioSampleBuffer.h:34
juce::AudioBuffer::AudioBuffer
AudioBuffer(Type *const *dataToReferTo, int numChannelsToUse, int startSample, int numSamples)
Definition juce_AudioSampleBuffer.h:104
juce::AudioBuffer::setSize
void setSize(int newNumChannels, int newNumSamples, bool keepExistingContent=false, bool clearExtraSpace=false, bool avoidReallocating=false)
Definition juce_AudioSampleBuffer.h:367
juce::AudioBuffer::getMagnitude
Type getMagnitude(int channel, int startSample, int numSamples) const noexcept
Definition juce_AudioSampleBuffer.h:1117
juce::AudioBuffer::AudioBuffer
AudioBuffer(Type *const *dataToReferTo, int numChannelsToUse, int numSamples)
Definition juce_AudioSampleBuffer.h:77
juce::AudioBuffer::getSample
Type getSample(int channel, int sampleIndex) const noexcept
Definition juce_AudioSampleBuffer.h:640
juce::AudioBuffer::applyGain
void applyGain(Type gain) noexcept
Definition juce_AudioSampleBuffer.h:712
juce::AudioBuffer::findMinMax
Range< Type > findMinMax(int channel, int startSample, int numSamples) const noexcept
Definition juce_AudioSampleBuffer.h:1105
juce::AudioBuffer::AudioBuffer
AudioBuffer(const AudioBuffer &other)
Definition juce_AudioSampleBuffer.h:122
juce::AudioBuffer::getReadPointer
const Type * getReadPointer(int channelNumber, int sampleIndex) const noexcept
Definition juce_AudioSampleBuffer.h:268
juce::AudioBuffer::makeCopyOf
void makeCopyOf(const AudioBuffer< OtherType > &other, bool avoidReallocating=false)
Definition juce_AudioSampleBuffer.h:525
juce::AudioBuffer::setNotClear
void setNotClear() noexcept
Definition juce_AudioSampleBuffer.h:631
juce::AudioBuffer::applyGain
void applyGain(int startSample, int numSamples, Type gain) noexcept
Definition juce_AudioSampleBuffer.h:705
juce::AudioBuffer::copyFromWithRamp
void copyFromWithRamp(int destChannel, int destStartSample, const Type *source, int numSamples, Type startGain, Type endGain) noexcept
Definition juce_AudioSampleBuffer.h:1067
juce::AudioBuffer::addSample
void addSample(int destChannel, int destSample, Type valueToAdd) noexcept
Definition juce_AudioSampleBuffer.h:671
juce::AudioBuffer::getRMSLevel
Type getRMSLevel(int channel, int startSample, int numSamples) const noexcept
Definition juce_AudioSampleBuffer.h:1143
juce::AudioBuffer::getWritePointer
Type * getWritePointer(int channelNumber) noexcept
Definition juce_AudioSampleBuffer.h:291
juce::AudioBuffer::copyFrom
void copyFrom(int destChannel, int destStartSample, const Type *source, int numSamples) noexcept
Definition juce_AudioSampleBuffer.h:983
juce::AudioBuffer::getNumChannels
int getNumChannels() const noexcept
Definition juce_AudioSampleBuffer.h:236
juce::AudioBuffer::getWritePointer
Type * getWritePointer(int channelNumber, int sampleIndex) noexcept
Definition juce_AudioSampleBuffer.h:314
juce::AudioBuffer::getNumSamples
int getNumSamples() const noexcept
Definition juce_AudioSampleBuffer.h:242
juce::AudioBuffer::clear
void clear() noexcept
Definition juce_AudioSampleBuffer.h:556
juce::AudioBuffer::clear
void clear(int channel, int startSample, int numSamples) noexcept
Definition juce_AudioSampleBuffer.h:606
juce::AudioBuffer::copyFrom
void copyFrom(int destChannel, int destStartSample, const Type *source, int numSamples, Type gain) noexcept
Definition juce_AudioSampleBuffer.h:1012
juce::AudioBuffer::~AudioBuffer
~AudioBuffer()=default
juce::AudioBuffer::applyGainRamp
void applyGainRamp(int channel, int startSample, int numSamples, Type startGain, Type endGain) noexcept
Definition juce_AudioSampleBuffer.h:726
juce::AudioBuffer::copyFrom
void copyFrom(int destChannel, int destStartSample, const AudioBuffer &source, int sourceChannel, int sourceStartSample, int numSamples) noexcept
Definition juce_AudioSampleBuffer.h:938
juce::AudioBuffer::reverse
void reverse(int startSample, int numSamples) const noexcept
Definition juce_AudioSampleBuffer.h:1175
juce::AudioBuffer::addFromWithRamp
void addFromWithRamp(int destChannel, int destStartSample, const Type *source, int numSamples, Type startGain, Type endGain) noexcept
Definition juce_AudioSampleBuffer.h:895
juce::AudioBuffer::getMagnitude
Type getMagnitude(int startSample, int numSamples) const noexcept
Definition juce_AudioSampleBuffer.h:1131
juce::AudioBuffer::reverse
void reverse(int channel, int startSample, int numSamples) const noexcept
Definition juce_AudioSampleBuffer.h:1164
juce::AudioBuffer::setSample
void setSample(int destChannel, int destSample, Type newValue) noexcept
Definition juce_AudioSampleBuffer.h:655
juce::AudioBuffer::addFrom
void addFrom(int destChannel, int destStartSample, const AudioBuffer &source, int sourceChannel, int sourceStartSample, int numSamples, Type gainToApplyToSource=Type(1)) noexcept
Definition juce_AudioSampleBuffer.h:784
juce::AudioBuffer::hasBeenCleared
bool hasBeenCleared() const noexcept
Definition juce_AudioSampleBuffer.h:622
juce::AudioBuffer::getReadPointer
const Type * getReadPointer(int channelNumber) const noexcept
Definition juce_AudioSampleBuffer.h:253
juce::AudioBuffer::operator=
AudioBuffer & operator=(const AudioBuffer &other)
Definition juce_AudioSampleBuffer.h:151
juce::AudioBuffer::setDataToReferTo
void setDataToReferTo(Type *const *dataToReferTo, int newNumChannels, int newStartSample, int newNumSamples)
Definition juce_AudioSampleBuffer.h:468
juce::AudioBuffer::getArrayOfReadPointers
const Type *const * getArrayOfReadPointers() const noexcept
Definition juce_AudioSampleBuffer.h:327
juce::AudioBuffer::setDataToReferTo
void setDataToReferTo(Type *const *dataToReferTo, int newNumChannels, int newNumSamples)
Definition juce_AudioSampleBuffer.h:509
juce::AudioBuffer::AudioBuffer
AudioBuffer(AudioBuffer &&other) noexcept
Definition juce_AudioSampleBuffer.h:180
juce::AudioBuffer::SampleType
Type SampleType
Definition juce_AudioSampleBuffer.h:1183
juce::AudioBuffer::getArrayOfWritePointers
Type *const * getArrayOfWritePointers() noexcept
Definition juce_AudioSampleBuffer.h:342
juce::AudioBuffer::AudioBuffer
AudioBuffer() noexcept
Definition juce_AudioSampleBuffer.h:38
juce::AudioBuffer::clear
void clear(int startSample, int numSamples) noexcept
Definition juce_AudioSampleBuffer.h:583
juce::AudioBuffer::AudioBuffer
AudioBuffer(int numChannelsToAllocate, int numSamplesToAllocate)
Definition juce_AudioSampleBuffer.h:53
juce::AudioBuffer::addFrom
void addFrom(int destChannel, int destStartSample, const Type *source, int numSamples, Type gainToApplyToSource=Type(1)) noexcept
Definition juce_AudioSampleBuffer.h:843
juce::AudioBuffer::applyGainRamp
void applyGainRamp(int startSample, int numSamples, Type startGain, Type endGain) noexcept
Definition juce_AudioSampleBuffer.h:761
juce::AudioBuffer::applyGain
void applyGain(int channel, int startSample, int numSamples, Type gain) noexcept
Definition juce_AudioSampleBuffer.h:684
juce::HeapBlock
Definition juce_HeapBlock.h:87
juce::HeapBlock::malloc
void malloc(SizeType newNumElements, size_t elementSize=sizeof(ElementType))
Definition juce_HeapBlock.h:249
juce::HeapBlock::get
ElementType * get() const noexcept
Definition juce_HeapBlock.h:185
juce::HeapBlock::allocate
void allocate(SizeType newNumElements, bool initialiseToZero)
Definition juce_HeapBlock.h:270
juce::Range
Definition juce_Range.h:40