37 namespace SampleTypeHelpers
39 template <typename T, bool = std::is_floating_point<T>::value>
46 struct ElementType<T, false>
48 using Type =
typename T::value_type;
67 template <
typename SampleType>
71 template <
typename OtherSampleType>
72 using MayUseConvertingConstructor =
73 std::enable_if_t<std::is_same<std::remove_const_t<SampleType>,
74 std::remove_const_t<OtherSampleType>>::value
75 && std::is_const<SampleType>::value
76 && ! std::is_const<OtherSampleType>::value,
81 using NumericType =
typename SampleTypeHelpers::ElementType<SampleType>::Type;
93 size_t numberOfChannels,
size_t numberOfSamples) noexcept
94 : channels (channelData),
95 numChannels (static_cast<ChannelCountType> (numberOfChannels)),
96 numSamples (numberOfSamples)
105 constexpr
AudioBlock (SampleType*
const* channelData,
size_t numberOfChannels,
106 size_t startSampleIndex,
size_t numberOfSamples) noexcept
107 : channels (channelData),
108 numChannels (static_cast<ChannelCountType> (numberOfChannels)),
109 startSample (startSampleIndex),
110 numSamples (numberOfSamples)
120 size_t numberOfChannels,
size_t numberOfSamples,
121 size_t alignmentInBytes = defaultAlignment) noexcept
122 : numChannels (static_cast<ChannelCountType> (numberOfChannels)),
123 numSamples (numberOfSamples)
125 auto roundedUpNumSamples = (numberOfSamples + elementMask) & ~elementMask;
126 auto channelSize =
sizeof (SampleType) * roundedUpNumSamples;
127 auto channelListBytes =
sizeof (SampleType*) * numberOfChannels;
128 auto extraBytes = alignmentInBytes - 1;
130 heapBlockToUseForAllocation.malloc (channelListBytes + extraBytes + channelSize * numberOfChannels);
132 auto* chanArray =
reinterpret_cast<SampleType**
> (heapBlockToUseForAllocation.getData());
133 channels = chanArray;
135 auto* data =
reinterpret_cast<SampleType*
> (addBytesToPointer (chanArray, channelListBytes));
136 data = snapPointerToAlignment (data, alignmentInBytes);
138 for (ChannelCountType i = 0; i < numChannels; ++i)
141 data += roundedUpNumSamples;
150 template <
typename OtherSampleType>
152 : channels (buffer.getArrayOfWritePointers()),
153 numChannels (static_cast<ChannelCountType> (buffer.getNumChannels())),
154 numSamples (static_cast<size_t> (buffer.getNumSamples()))
163 template <
typename OtherSampleType>
165 : channels (buffer.getArrayOfWritePointers()),
166 numChannels (static_cast<ChannelCountType> (buffer.getNumChannels())),
167 startSample (startSampleIndex),
168 numSamples (static_cast<size_t> (buffer.getNumSamples()) - startSampleIndex)
170 jassert (startSample < static_cast<size_t> (buffer.getNumSamples()));
176 template <
typename OtherSampleType, MayUseConvertingConstructor<OtherSampleType> = 0>
178 : channels { other.channels },
179 numChannels { other.numChannels },
180 startSample { other.startSample },
181 numSamples { other.numSamples }
185 template <
typename OtherSampleType, MayUseConvertingConstructor<OtherSampleType> = 0>
195 std::swap (other.channels, channels);
196 std::swap (other.numChannels, numChannels);
197 std::swap (other.startSample, startSample);
198 std::swap (other.numSamples, numSamples);
202 template <
typename OtherSampleType>
205 return std::equal (channels,
206 channels + numChannels,
208 other.channels + other.numChannels)
209 && startSample == other.startSample
210 && numSamples == other.numSamples;
213 template <
typename OtherSampleType>
216 return ! (*
this == other);
221 constexpr
size_t getNumChannels() const noexcept {
return static_cast<size_t> (numChannels); }
229 jassert (channel < numChannels);
230 jassert (numSamples > 0);
231 return channels[channel] + startSample;
237 jassert (channel < numChannels);
238 return AudioBlock (channels + channel, 1, startSample, numSamples);
247 jassert (channelStart < numChannels);
248 jassert ((channelStart + numChannelsToUse) <= numChannels);
250 return AudioBlock (channels + channelStart, numChannelsToUse, startSample, numSamples);
258 SampleType
getSample (
int channel,
int sampleIndex)
const noexcept
260 jassert (isPositiveAndBelow (channel, numChannels));
261 jassert (isPositiveAndBelow (sampleIndex, numSamples));
262 return channels[channel][(size_t) startSample + (
size_t) sampleIndex];
270 void setSample (
int destChannel,
int destSample, SampleType newValue)
const noexcept
272 jassert (isPositiveAndBelow (destChannel, numChannels));
273 jassert (isPositiveAndBelow (destSample, numSamples));
274 channels[destChannel][(size_t) startSample + (
size_t) destSample] = newValue;
282 void addSample (
int destChannel,
int destSample, SampleType valueToAdd)
const noexcept
284 jassert (isPositiveAndBelow (destChannel, numChannels));
285 jassert (isPositiveAndBelow (destSample, numSamples));
286 channels[destChannel][(size_t) startSample + (
size_t) destSample] += valueToAdd;
292 const AudioBlock& clear()
const noexcept { clearInternal();
return *
this; }
295 AudioBlock& JUCE_VECTOR_CALLTYPE
fill (NumericType value) noexcept { fillInternal (value);
return *
this; }
296 const AudioBlock& JUCE_VECTOR_CALLTYPE fill (NumericType value)
const noexcept { fillInternal (value);
return *
this; }
299 template <
typename OtherSampleType>
301 template <
typename OtherSampleType>
310 template <
typename OtherNumericType>
312 size_t srcPos = 0,
size_t dstPos = 0,
313 size_t numElements = std::numeric_limits<size_t>::max()) { copyFromInternal (src, srcPos, dstPos, numElements);
return *
this; }
314 template <
typename OtherNumericType>
316 size_t srcPos = 0,
size_t dstPos = 0,
317 size_t numElements = std::numeric_limits<size_t>::max())
const { copyFromInternal (src, srcPos, dstPos, numElements);
return *
this; }
326 void copyTo (
AudioBuffer<
typename std::remove_const<NumericType>::type>& dst,
size_t srcPos = 0,
size_t dstPos = 0,
327 size_t numElements = std::numeric_limits<size_t>::max())
const 329 auto dstlen =
static_cast<size_t> (dst.getNumSamples()) / sizeFactor;
330 auto n =
static_cast<int> (jmin (numSamples - srcPos, dstlen - dstPos, numElements) * sizeFactor);
331 auto maxChannels = jmin (static_cast<size_t> (dst.getNumChannels()), static_cast<size_t> (numChannels));
333 for (
size_t ch = 0; ch < maxChannels; ++ch)
335 static_cast<int> (dstPos * sizeFactor)),
336 getDataPointer (ch) + (srcPos * sizeFactor),
344 size_t numElements = std::numeric_limits<size_t>::max()) noexcept { moveInternal (srcPos, dstPos, numElements);
return *
this; }
345 const AudioBlock& move (
size_t srcPos,
size_t dstPos,
346 size_t numElements = std::numeric_limits<size_t>::max())
const noexcept { moveInternal (srcPos, dstPos, numElements);
return *
this; }
360 jassert (newOffset < numSamples);
361 jassert (newOffset + newLength <= numSamples);
363 return AudioBlock (channels, numChannels, startSample + newOffset, newLength);
378 return getSubBlock (newOffset, getNumSamples() - newOffset);
383 AudioBlock& JUCE_VECTOR_CALLTYPE
add (NumericType value) noexcept { addInternal (value);
return *
this; }
384 const AudioBlock& JUCE_VECTOR_CALLTYPE add (NumericType value)
const noexcept { addInternal (value);
return *
this; }
387 template <
typename OtherSampleType>
389 template <
typename OtherSampleType>
393 template <
typename OtherSampleType>
395 template <
typename OtherSampleType>
399 template <
typename Src1SampleType,
typename Src2SampleType>
401 template <
typename Src1SampleType,
typename Src2SampleType>
406 AudioBlock& JUCE_VECTOR_CALLTYPE
subtract (NumericType value) noexcept { subtractInternal (value);
return *
this; }
407 const AudioBlock& JUCE_VECTOR_CALLTYPE subtract (NumericType value)
const noexcept { subtractInternal (value);
return *
this; }
410 template <
typename OtherSampleType>
412 template <
typename OtherSampleType>
416 template <
typename OtherSampleType>
418 template <
typename OtherSampleType>
419 const AudioBlock& JUCE_VECTOR_CALLTYPE replaceWithDifferenceOf (
AudioBlock<OtherSampleType> src, NumericType value)
const noexcept { replaceWithDifferenceOfInternal (src, value);
return *
this; }
422 template <
typename Src1SampleType,
typename Src2SampleType>
424 template <
typename Src1SampleType,
typename Src2SampleType>
429 AudioBlock& JUCE_VECTOR_CALLTYPE
multiplyBy (NumericType value) noexcept { multiplyByInternal (value);
return *
this; }
430 const AudioBlock& JUCE_VECTOR_CALLTYPE multiplyBy (NumericType value)
const noexcept { multiplyByInternal (value);
return *
this; }
433 template <
typename OtherSampleType>
435 template <
typename OtherSampleType>
439 template <
typename OtherSampleType>
441 template <
typename OtherSampleType>
442 const AudioBlock& JUCE_VECTOR_CALLTYPE replaceWithProductOf (
AudioBlock<OtherSampleType> src, NumericType value)
const noexcept { replaceWithProductOfInternal (src, value);
return *
this; }
445 template <
typename Src1SampleType,
typename Src2SampleType>
447 template <
typename Src1SampleType,
typename Src2SampleType>
452 template <
typename SmoothingType>
454 template <
typename SmoothingType>
458 template <
typename OtherSampleType,
typename SmoothingType>
460 template <
typename OtherSampleType,
typename SmoothingType>
465 template <
typename OtherSampleType>
467 template <
typename OtherSampleType>
471 template <
typename Src1SampleType,
typename Src2SampleType>
473 template <
typename Src1SampleType,
typename Src2SampleType>
479 const AudioBlock& negate()
const noexcept { negateInternal();
return *
this; }
482 template <
typename OtherSampleType>
484 template <
typename OtherSampleType>
488 template <
typename OtherSampleType>
490 template <
typename OtherSampleType>
495 template <
typename Src1SampleType,
typename Src2SampleType>
497 template <
typename Src1SampleType,
typename Src2SampleType>
501 template <
typename Src1SampleType,
typename Src2SampleType>
503 template <
typename Src1SampleType,
typename Src2SampleType>
510 if (numChannels == 0)
513 auto n =
static_cast<int> (numSamples * sizeFactor);
516 for (
size_t ch = 1; ch < numChannels; ++ch)
524 AudioBlock& JUCE_VECTOR_CALLTYPE operator+= (NumericType value) noexcept {
return add (value); }
525 const AudioBlock& JUCE_VECTOR_CALLTYPE operator+= (NumericType value)
const noexcept {
return add (value); }
530 AudioBlock& JUCE_VECTOR_CALLTYPE operator-= (NumericType value) noexcept {
return subtract (value); }
531 const AudioBlock& JUCE_VECTOR_CALLTYPE operator-= (NumericType value)
const noexcept {
return subtract (value); }
536 AudioBlock& JUCE_VECTOR_CALLTYPE operator*= (NumericType value) noexcept {
return multiplyBy (value); }
537 const AudioBlock& JUCE_VECTOR_CALLTYPE operator*= (NumericType value)
const noexcept {
return multiplyBy (value); }
542 template <
typename SmoothingType>
544 template <
typename SmoothingType>
549 static_assert (std::is_same<std::remove_const_t<SampleType>,
float>::value
550 || std::is_same<std::remove_const_t<SampleType>,
double>::value
555 ,
"AudioBlock only supports single or double precision floating point types");
562 template <
typename Src1SampleType,
typename Src2SampleType,
typename FunctionType>
571 for (ChannelCountType c = 0; c < numChans; ++c)
576 for (
size_t i = 0; i < len; ++i)
577 dst[i] =
function (src[i]);
582 NumericType* getDataPointer (
size_t channel)
const noexcept
584 return reinterpret_cast<NumericType*
> (getChannelPointer (channel));
588 void JUCE_VECTOR_CALLTYPE clearInternal()
const noexcept
590 auto n =
static_cast<int> (numSamples * sizeFactor);
592 for (
size_t ch = 0; ch < numChannels; ++ch)
596 void JUCE_VECTOR_CALLTYPE fillInternal (NumericType value)
const noexcept
598 auto n =
static_cast<int> (numSamples * sizeFactor);
600 for (
size_t ch = 0; ch < numChannels; ++ch)
604 template <
typename OtherSampleType>
607 auto maxChannels = jmin (src.numChannels, numChannels);
608 auto n =
static_cast<int> (jmin (src.numSamples * src.sizeFactor,
609 numSamples * sizeFactor));
611 for (
size_t ch = 0; ch < maxChannels; ++ch)
615 template <
typename OtherNumericType>
618 auto srclen =
static_cast<size_t> (src.
getNumSamples()) / sizeFactor;
619 auto n =
static_cast<int> (jmin (srclen - srcPos, numSamples - dstPos, numElements) * sizeFactor);
620 auto maxChannels = jmin (static_cast<size_t> (src.
getNumChannels()), static_cast<size_t> (numChannels));
622 for (
size_t ch = 0; ch < maxChannels; ++ch)
625 static_cast<int> (srcPos * sizeFactor)),
629 void moveInternal (
size_t srcPos,
size_t dstPos,
630 size_t numElements = std::numeric_limits<size_t>::max())
const noexcept
632 jassert (srcPos <= numSamples && dstPos <= numSamples);
633 auto len = jmin (numSamples - srcPos, numSamples - dstPos, numElements) *
sizeof (SampleType);
636 for (
size_t ch = 0; ch < numChannels; ++ch)
637 ::memmove (getChannelPointer (ch) + dstPos,
638 getChannelPointer (ch) + srcPos, len);
642 void JUCE_VECTOR_CALLTYPE addInternal (NumericType value)
const noexcept
644 auto n =
static_cast<int> (numSamples * sizeFactor);
646 for (
size_t ch = 0; ch < numChannels; ++ch)
650 template <
typename OtherSampleType>
653 jassert (numChannels == src.numChannels);
654 auto n =
static_cast<int> (jmin (numSamples, src.numSamples) * sizeFactor);
656 for (
size_t ch = 0; ch < numChannels; ++ch)
660 template <
typename OtherSampleType>
663 jassert (numChannels == src.numChannels);
664 auto n =
static_cast<int> (jmin (numSamples, src.numSamples) * sizeFactor);
666 for (
size_t ch = 0; ch < numChannels; ++ch)
670 template <
typename Src1SampleType,
typename Src2SampleType>
673 jassert (numChannels == src1.numChannels && src1.numChannels == src2.numChannels);
674 auto n =
static_cast<int> (jmin (numSamples, src1.numSamples, src2.numSamples) * sizeFactor);
676 for (
size_t ch = 0; ch < numChannels; ++ch)
681 constexpr
void JUCE_VECTOR_CALLTYPE subtractInternal (NumericType value)
const noexcept
683 addInternal (value * static_cast<NumericType> (-1.0));
686 template <
typename OtherSampleType>
689 jassert (numChannels == src.numChannels);
690 auto n =
static_cast<int> (jmin (numSamples, src.numSamples) * sizeFactor);
692 for (
size_t ch = 0; ch < numChannels; ++ch)
696 template <
typename OtherSampleType>
699 replaceWithSumOfInternal (src, static_cast<NumericType> (-1.0) * value);
702 template <
typename Src1SampleType,
typename Src2SampleType>
705 jassert (numChannels == src1.numChannels && src1.numChannels == src2.numChannels);
706 auto n =
static_cast<int> (jmin (numSamples, src1.numSamples, src2.numSamples) * sizeFactor);
708 for (
size_t ch = 0; ch < numChannels; ++ch)
713 void JUCE_VECTOR_CALLTYPE multiplyByInternal (NumericType value)
const noexcept
715 auto n =
static_cast<int> (numSamples * sizeFactor);
717 for (
size_t ch = 0; ch < numChannels; ++ch)
721 template <
typename OtherSampleType>
724 jassert (numChannels == src.numChannels);
725 auto n =
static_cast<int> (jmin (numSamples, src.numSamples) * sizeFactor);
727 for (
size_t ch = 0; ch < numChannels; ++ch)
731 template <
typename OtherSampleType>
734 jassert (numChannels == src.numChannels);
735 auto n =
static_cast<int> (jmin (numSamples, src.numSamples) * sizeFactor);
737 for (
size_t ch = 0; ch < numChannels; ++ch)
741 template <
typename Src1SampleType,
typename Src2SampleType>
744 jassert (numChannels == src1.numChannels && src1.numChannels == src2.numChannels);
745 auto n =
static_cast<int> (jmin (numSamples, src1.numSamples, src2.numSamples) * sizeFactor);
747 for (
size_t ch = 0; ch < numChannels; ++ch)
751 template <
typename SmoothingType>
760 for (
size_t i = 0; i < numSamples; ++i)
764 for (
size_t ch = 0; ch < numChannels; ++ch)
765 getDataPointer (ch)[i] *= scaler;
770 template <
typename OtherSampleType,
typename SmoothingType>
773 jassert (numChannels == src.numChannels);
781 auto n = jmin (numSamples, src.numSamples) * sizeFactor;
783 for (
size_t i = 0; i < n; ++i)
787 for (
size_t ch = 0; ch < numChannels; ++ch)
794 template <
typename OtherSampleType>
797 jassert (numChannels == src.numChannels);
798 auto n =
static_cast<int> (jmin (numSamples, src.numSamples) * sizeFactor);
800 for (
size_t ch = 0; ch < numChannels; ++ch)
804 template <
typename Src1SampleType,
typename Src2SampleType>
807 jassert (numChannels == src1.numChannels && src1.numChannels == src2.numChannels);
808 auto n =
static_cast<int> (jmin (numSamples, src1.numSamples, src2.numSamples) * sizeFactor);
810 for (
size_t ch = 0; ch < numChannels; ++ch)
815 constexpr
void negateInternal()
const noexcept
817 multiplyByInternal (static_cast<NumericType> (-1.0));
820 template <
typename OtherSampleType>
823 jassert (numChannels == src.numChannels);
824 auto n =
static_cast<int> (jmin (numSamples, src.numSamples) * sizeFactor);
826 for (
size_t ch = 0; ch < numChannels; ++ch)
830 template <
typename OtherSampleType>
833 jassert (numChannels == src.numChannels);
834 auto n =
static_cast<int> (jmin (numSamples, src.numSamples) * sizeFactor);
836 for (
size_t ch = 0; ch < numChannels; ++ch)
841 template <
typename Src1SampleType,
typename Src2SampleType>
844 jassert (numChannels == src1.numChannels && src1.numChannels == src2.numChannels);
845 auto n =
static_cast<int> (jmin (src1.numSamples, src2.numSamples, numSamples) * sizeFactor);
847 for (
size_t ch = 0; ch < numChannels; ++ch)
851 template <
typename Src1SampleType,
typename Src2SampleType>
854 jassert (numChannels == src1.numChannels && src1.numChannels == src2.numChannels);
855 auto n =
static_cast<int> (jmin (src1.numSamples, src2.numSamples, numSamples) * sizeFactor);
857 for (
size_t ch = 0; ch < numChannels; ++ch)
862 using ChannelCountType =
unsigned int;
865 static constexpr
size_t sizeFactor =
sizeof (SampleType) /
sizeof (NumericType);
866 static constexpr
size_t elementMask = sizeFactor - 1;
867 static constexpr
size_t byteMask = (sizeFactor *
sizeof (NumericType)) - 1;
872 static constexpr
size_t defaultAlignment =
sizeof (NumericType);
875 SampleType*
const* channels;
876 ChannelCountType numChannels = 0;
877 size_t startSample = 0, numSamples = 0;
879 template <
typename OtherSampleType>
FloatType getNextValue() noexcept
Compute the next value.
AudioBlock & copyFrom(const AudioBlock< OtherSampleType > &src) noexcept
Copies the values in src to this block.
FloatType getTargetValue() const noexcept
Returns the target value towards which the smoothed value is currently moving.
AudioBlock &JUCE_VECTOR_CALLTYPE replaceWithProductOf(AudioBlock< OtherSampleType > src, NumericType value) noexcept
Replaces the elements in this block with the product of the elements in the source src block and a fi...
static void JUCE_CALLTYPE add(float *dest, float amountToAdd, int numValues) noexcept
Adds a fixed value to the destination values.
A utility class for values that need smoothing to avoid audio glitches.
static void JUCE_CALLTYPE copy(float *dest, const float *src, int numValues) noexcept
Copies a vector of floats.
AudioBlock & replaceWithNegativeOf(AudioBlock< OtherSampleType > src) noexcept
Replaces the contents of this block with the negative of the values in the src block.
AudioBlock & negate() noexcept
Negates each value of this block.
AudioBlock & replaceWithDifferenceOf(AudioBlock< Src1SampleType > src1, AudioBlock< Src2SampleType > src2) noexcept
Subtracts each source2 value from the corresponding source1 value and replaces the contents of this b...
AudioBlock & copyFrom(const AudioBuffer< OtherNumericType > &src, size_t srcPos=0, size_t dstPos=0, size_t numElements=std::numeric_limits< size_t >::max())
Copy the values from an AudioBuffer to this block.
Minimal and lightweight data-structure which contains a list of pointers to channels containing some ...
AudioBlock getSubBlock(size_t newOffset) const noexcept
Return a new AudioBlock pointing to a sub-block inside this block.
AudioBlock &JUCE_VECTOR_CALLTYPE addProductOf(AudioBlock< OtherSampleType > src, NumericType factor) noexcept
Multiplies each value in src by a fixed value and adds the result to this block.
AudioBlock getSingleChannelBlock(size_t channel) const noexcept
Returns an AudioBlock that represents one of the channels in this block.
static void JUCE_CALLTYPE fill(float *dest, float valueToFill, int numValues) noexcept
Copies a repeated value into a vector of floats.
A wrapper around the platform's native SIMD register type.
static void JUCE_CALLTYPE multiply(float *dest, const float *src, int numValues) noexcept
Multiplies the destination values by the source values.
AudioBlock & replaceWithMaxOf(AudioBlock< Src1SampleType > src1, AudioBlock< Src2SampleType > src2) noexcept
Replaces each element of this block with the maximum of the corresponding element of the source array...
AudioBlock &JUCE_VECTOR_CALLTYPE fill(NumericType value) noexcept
Fills the memory referenced by this AudioBlock with value.
static void process(AudioBlock< Src1SampleType > inBlock, AudioBlock< Src2SampleType > outBlock, FunctionType &&function)
Applies a function to each value in an input block, putting the result into an output block...
Range< typename std::remove_const< NumericType >::type > findMinAndMax() const noexcept
Finds the minimum and maximum value of the buffer.
SampleType getSample(int channel, int sampleIndex) const noexcept
Returns a sample from the buffer.
bool isSmoothing() const noexcept
Returns true if the current value is currently being interpolated.
constexpr AudioBlock(SampleType *const *channelData, size_t numberOfChannels, size_t startSampleIndex, size_t numberOfSamples) noexcept
Creates an AudioBlock from a pointer to an array of channels.
AudioBlock &JUCE_VECTOR_CALLTYPE subtract(NumericType value) noexcept
Subtracts a fixed value from the elements in this block.
constexpr size_t getNumSamples() const noexcept
Returns the number of samples referenced by this block.
AudioBlock & replaceWithMinOf(AudioBlock< Src1SampleType > src1, AudioBlock< Src2SampleType > src2) noexcept
Replaces each element of this block with the minimum of the corresponding element of the source array...
static void JUCE_CALLTYPE abs(float *dest, const float *src, int numValues) noexcept
Copies a source vector to a destination, taking the absolute of each value.
const Type * getReadPointer(int channelNumber) const noexcept
Returns a pointer to an array of read-only samples in one of the buffer's channels.
AudioBlock & replaceWithAbsoluteValueOf(AudioBlock< OtherSampleType > src) noexcept
Replaces the contents of this block with the absolute values of the src block.
AudioBlock & multiplyBy(SmoothedValue< SampleType, SmoothingType > &value) noexcept
Multiplies each channels of this block by a smoothly changing value.
A multi-channel buffer containing floating point audio samples.
AudioBlock &JUCE_VECTOR_CALLTYPE replaceWithDifferenceOf(AudioBlock< OtherSampleType > src, NumericType value) noexcept
Subtracts a fixed value from each source value and replaces the contents of this block.
AudioBlock & replaceWithProductOf(AudioBlock< Src1SampleType > src1, AudioBlock< Src2SampleType > src2) noexcept
Replaces the elements in this block with the product of the elements in the src1 and scr2 blocks...
AudioBlock &JUCE_VECTOR_CALLTYPE add(NumericType value) noexcept
Adds a fixed value to the elements in this block.
AudioBlock & multiplyBy(AudioBlock< OtherSampleType > src) noexcept
Multiplies the elements in this block by the elements in the src block.
static Range< float > JUCE_CALLTYPE findMinAndMax(const float *src, int numValues) noexcept
Finds the minimum and maximum values in the given array.
AudioBlock &JUCE_VECTOR_CALLTYPE replaceWithSumOf(AudioBlock< OtherSampleType > src, NumericType value) noexcept
Adds a fixed value to each source value and replaces the contents of this block.
int getNumChannels() const noexcept
Returns the number of channels of audio data that this buffer contains.
static void JUCE_CALLTYPE subtract(float *dest, const float *src, int numValues) noexcept
Subtracts the source values from the destination values.
static void JUCE_CALLTYPE clear(float *dest, int numValues) noexcept
Clears a vector of floats.
constexpr AudioBlock(SampleType *const *channelData, size_t numberOfChannels, size_t numberOfSamples) noexcept
Creates an AudioBlock from a pointer to an array of channels.
AudioBlock & replaceWithSumOf(AudioBlock< Src1SampleType > src1, AudioBlock< Src2SampleType > src2) noexcept
Adds each source1 value to the corresponding source2 value and replaces the contents of this block...
AudioBlock & replaceWithProductOf(AudioBlock< OtherSampleType > src, SmoothedValue< SampleType, SmoothingType > &value) noexcept
Replaces each channel of this block with the product of the src block and a smoothed value...
static void JUCE_CALLTYPE max(float *dest, const float *src, float comp, int num) noexcept
Each element of dest will be the maximum of the corresponding element of the source array and the giv...
constexpr AudioBlock(AudioBuffer< OtherSampleType > &buffer) noexcept
Creates an AudioBlock that points to the data in an AudioBuffer.
void setSample(int destChannel, int destSample, SampleType newValue) const noexcept
Modifies a sample in the buffer.
AudioBlock & addProductOf(AudioBlock< Src1SampleType > src1, AudioBlock< Src2SampleType > src2) noexcept
Multiplies each value in srcA with the corresponding value in srcB and adds the result to this block...
AudioBlock getSubBlock(size_t newOffset, size_t newLength) const noexcept
Return a new AudioBlock pointing to a sub-block inside this block.
static void JUCE_CALLTYPE negate(float *dest, const float *src, int numValues) noexcept
Copies a source vector to a destination, negating each value.
AudioBlock &JUCE_VECTOR_CALLTYPE multiplyBy(NumericType value) noexcept
Multiplies the elements in this block by a fixed value.
static void JUCE_CALLTYPE addWithMultiply(float *dest, const float *src, float multiplier, int numValues) noexcept
Multiplies each source value by the given multiplier, then adds it to the destination value...
AudioBlock & clear() noexcept
Clears the memory referenced by this AudioBlock.
SampleType * getChannelPointer(size_t channel) const noexcept
Returns a raw pointer into one of the channels in this block.
void copyTo(AudioBuffer< typename std::remove_const< NumericType >::type > &dst, size_t srcPos=0, size_t dstPos=0, size_t numElements=std::numeric_limits< size_t >::max()) const
Copies the values from this block to an AudioBuffer.
int getNumSamples() const noexcept
Returns the number of samples allocated in each of the buffer's channels.
static void JUCE_CALLTYPE min(float *dest, const float *src, float comp, int num) noexcept
Each element of dest will be the minimum of the corresponding element of the source array and the giv...
AudioBlock(HeapBlock< char > &heapBlockToUseForAllocation, size_t numberOfChannels, size_t numberOfSamples, size_t alignmentInBytes=defaultAlignment) noexcept
Allocates a suitable amount of space in a HeapBlock, and initialises this object to point into it...
AudioBlock & add(AudioBlock< OtherSampleType > src) noexcept
Adds the elements in the src block to the elements in this block.
constexpr size_t getNumChannels() const noexcept
Returns the number of channels referenced by this block.
AudioBlock & subtract(AudioBlock< OtherSampleType > src) noexcept
Subtracts the source values from the elements in this block.
AudioBlock & move(size_t srcPos, size_t dstPos, size_t numElements=std::numeric_limits< size_t >::max()) noexcept
Move memory within this block from the position srcPos to the position dstPos.
AudioBlock(AudioBuffer< OtherSampleType > &buffer, size_t startSampleIndex) noexcept
Creates an AudioBlock that points to the data in an AudioBuffer.
AudioBlock getSubsetChannelBlock(size_t channelStart, size_t numChannelsToUse) const noexcept
Returns a subset of contiguous channels.
void addSample(int destChannel, int destSample, SampleType valueToAdd) const noexcept
Adds a value to a sample in the buffer.
A general-purpose range object, that simply represents any linear range with a start and end point...