JUCE

- Main Page
- Related Pages
- Topics
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
AudioBuffer< Type > Class Template Reference
juce_audio_basics » buffers

A multi-channel buffer containing floating point audio samples. More...

`#include <juce_AudioSampleBuffer.h>`

## Public Types
using | SampleType = Type
| This allows templated code that takes an AudioBuffer to access its sample type.

## Public Member Functions
| AudioBuffer () noexcept
| Creates an empty buffer with 0 channels and 0 length.
| AudioBuffer (int numChannelsToAllocate, int numSamplesToAllocate)
| Creates a buffer with a specified number of channels and samples.
| AudioBuffer (Type *const *dataToReferTo, int numChannelsToUse, int numSamples)
| Creates a buffer using a pre-allocated block of memory.
| AudioBuffer (Type *const *dataToReferTo, int numChannelsToUse, int startSample, int numSamples)
| Creates a buffer using a pre-allocated block of memory.
| AudioBuffer (const AudioBuffer &other)
| Copies another buffer.
AudioBuffer & | operator= (const AudioBuffer &other)
| Copies another buffer onto this one.
| ~AudioBuffer ()=default
| Destructor.
| AudioBuffer (AudioBuffer &&other) noexcept
| Move constructor.
AudioBuffer & | operator= (AudioBuffer &&other) noexcept
| Move assignment.
int | getNumChannels () const noexcept
| Returns the number of channels of audio data that this buffer contains.
int | getNumSamples () const noexcept
| Returns the number of samples allocated in each of the buffer's channels.
const Type * | getReadPointer (int channelNumber) const noexcept
| Returns a pointer to an array of read-only samples in one of the buffer's channels.
const Type * | getReadPointer (int channelNumber, int sampleIndex) const noexcept
| Returns a pointer to an array of read-only samples in one of the buffer's channels.
Type * | getWritePointer (int channelNumber) noexcept
| Returns a writeable pointer to one of the buffer's channels.
Type * | getWritePointer (int channelNumber, int sampleIndex) noexcept
| Returns a writeable pointer to one of the buffer's channels.
const Type *const * | getArrayOfReadPointers () const noexcept
| Returns an array of pointers to the channels in the buffer.
Type *const * | getArrayOfWritePointers () noexcept
| Returns an array of pointers to the channels in the buffer.
void | setSize (int newNumChannels, int newNumSamples, bool keepExistingContent=false, bool clearExtraSpace=false, bool avoidReallocating=false)
| Changes the buffer's size or number of channels.
void | setDataToReferTo (Type *const *dataToReferTo, int newNumChannels, int newStartSample, int newNumSamples)
| Makes this buffer point to a pre-allocated set of channel data arrays.
void | setDataToReferTo (Type *const *dataToReferTo, int newNumChannels, int newNumSamples)
| Makes this buffer point to a pre-allocated set of channel data arrays.
template<typename OtherType >
void | makeCopyOf (const AudioBuffer< OtherType > &other, bool avoidReallocating=false)
| Resizes this buffer to match the given one, and copies all of its content across.
void | clear () noexcept
| Clears all the samples in all channels and marks the buffer as cleared.
void | clear (int startSample, int numSamples) noexcept
| Clears a specified region of all the channels.
void | clear (int channel, int startSample, int numSamples) noexcept
| Clears a specified region of just one channel.
bool | hasBeenCleared () const noexcept
| Returns true if the buffer has been entirely cleared.
void | setNotClear () noexcept
| Forces the internal cleared flag of the buffer to false.
Type | getSample (int channel, int sampleIndex) const noexcept
| Returns a sample from the buffer.
void | setSample (int destChannel, int destSample, Type newValue) noexcept
| Sets a sample in the buffer.
void | addSample (int destChannel, int destSample, Type valueToAdd) noexcept
| Adds a value to a sample in the buffer.
void | applyGain (int channel, int startSample, int numSamples, Type gain) noexcept
| Applies a gain multiple to a region of one channel.
void | applyGain (int startSample, int numSamples, Type gain) noexcept
| Applies a gain multiple to a region of all the channels.
void | applyGain (Type gain) noexcept
| Applies a gain multiple to all the audio data.
void | applyGainRamp (int channel, int startSample, int numSamples, Type startGain, Type endGain) noexcept
| Applies a range of gains to a region of a channel.
void | applyGainRamp (int startSample, int numSamples, Type startGain, Type endGain) noexcept
| Applies a range of gains to a region of all channels.
void | addFrom (int destChannel, int destStartSample, const AudioBuffer &source, int sourceChannel, int sourceStartSample, int numSamples, Type gainToApplyToSource=Type(1)) noexcept
| Adds samples from another buffer to this one.
void | addFrom (int destChannel, int destStartSample, const Type *source, int numSamples, Type gainToApplyToSource=Type(1)) noexcept
| Adds samples from an array of floats to one of the channels.
void | addFromWithRamp (int destChannel, int destStartSample, const Type *source, int numSamples, Type startGain, Type endGain) noexcept
| Adds samples from an array of floats, applying a gain ramp to them.
void | copyFrom (int destChannel, int destStartSample, const AudioBuffer &source, int sourceChannel, int sourceStartSample, int numSamples) noexcept
| Copies samples from another buffer to this one.
void | copyFrom (int destChannel, int destStartSample, const Type *source, int numSamples) noexcept
| Copies samples from an array of floats into one of the channels.
void | copyFrom (int destChannel, int destStartSample, const Type *source, int numSamples, Type gain) noexcept
| Copies samples from an array of floats into one of the channels, applying a gain to it.
void | copyFromWithRamp (int destChannel, int destStartSample, const Type *source, int numSamples, Type startGain, Type endGain) noexcept
| Copies samples from an array of floats into one of the channels, applying a gain ramp.
Range< Type > | findMinMax (int channel, int startSample, int numSamples) const noexcept
| Returns a Range indicating the lowest and highest sample values in a given section.
Type | getMagnitude (int channel, int startSample, int numSamples) const noexcept
| Finds the highest absolute sample value within a region of a channel.
Type | getMagnitude (int startSample, int numSamples) const noexcept
| Finds the highest absolute sample value within a region on all channels.
Type | getRMSLevel (int channel, int startSample, int numSamples) const noexcept
| Returns the root mean squared level for a region of a channel.
void | reverse (int channel, int startSample, int numSamples) const noexcept
| Reverses a part of a channel.
void | reverse (int startSample, int numSamples) const noexcept
| Reverses a part of the buffer.

## Detailed Description

template<typename Type>
class AudioBuffer< Type >

A multi-channel buffer containing floating point audio samples.

## Member Typedef Documentation

## ◆ SampleType

template<typename Type >

using AudioBuffer< Type >::SampleType = Type

This allows templated code that takes an AudioBuffer to access its sample type.

## Constructor & Destructor Documentation

## ◆ AudioBuffer() [1/6]

template<typename Type >

AudioBuffer< Type >::AudioBuffer | ( |  | ) |
| noexcept

Creates an empty buffer with 0 channels and 0 length.

## ◆ AudioBuffer() [2/6]

template<typename Type >

AudioBuffer< Type >::AudioBuffer | ( | int | numChannelsToAllocate,
|  | int | numSamplesToAllocate )

Creates a buffer with a specified number of channels and samples.

The contents of the buffer will initially be undefined, so use clear() to set all the samples to zero.

The buffer will allocate its memory internally, and this will be released when the buffer is deleted. If the memory can't be allocated, this will throw a std::bad_alloc exception.

References jassert.

## ◆ AudioBuffer() [3/6]

template<typename Type >

AudioBuffer< Type >::AudioBuffer | ( | Type *const * | dataToReferTo,
|  | int | numChannelsToUse,
|  | int | numSamples )

Creates a buffer using a pre-allocated block of memory.

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.

Parameters

  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.
  numChannelsToUse | the number of channels to use - this must correspond to the number of elements in the array passed in
  numSamples | the number of samples to use - this must correspond to the size of the arrays passed in

References jassert.

## ◆ AudioBuffer() [4/6]

template<typename Type >

AudioBuffer< Type >::AudioBuffer | ( | Type *const * | dataToReferTo,
|  | int | numChannelsToUse,
|  | int | startSample,
|  | int | numSamples )

Creates a buffer using a pre-allocated block of memory.

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.

Parameters

  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.
  numChannelsToUse | the number of channels to use - this must correspond to the number of elements in the array passed in
  startSample | the offset within the arrays at which the data begins
  numSamples | the number of samples to use - this must correspond to the size of the arrays passed in

References jassert.

## ◆ AudioBuffer() [5/6]

template<typename Type >

AudioBuffer< Type >::AudioBuffer | ( | const AudioBuffer< Type > & | other | ) |

Copies another buffer.

This buffer will make its own copy of the other's data, unless the buffer was created using an external data buffer, in which case both buffers will just point to the same shared block of data.

References AudioBuffer< Type >::clear().

## ◆ ~AudioBuffer()

template<typename Type >

AudioBuffer< Type >::~AudioBuffer | ( |  | ) |
| default

Destructor.

This will free any memory allocated by the buffer.

## ◆ AudioBuffer() [6/6]

template<typename Type >

AudioBuffer< Type >::AudioBuffer | ( | AudioBuffer< Type > && | other | ) |
| noexcept

Move constructor.

References numElementsInArray().

## Member Function Documentation

## ◆ operator=() [1/2]

template<typename Type >

AudioBuffer & AudioBuffer< Type >::operator= | ( | const AudioBuffer< Type > & | other | ) |

Copies another buffer onto this one.

This buffer's size will be changed to that of the other buffer.

References AudioBuffer< Type >::clear(), AudioBuffer< Type >::getNumChannels(), AudioBuffer< Type >::getNumSamples(), and AudioBuffer< Type >::setSize().

## ◆ operator=() [2/2]

template<typename Type >

AudioBuffer & AudioBuffer< Type >::operator= | ( | AudioBuffer< Type > && | other | ) |
| noexcept

Move assignment.

References numElementsInArray().

## ◆ getNumChannels()

template<typename Type >

int AudioBuffer< Type >::getNumChannels | ( |  | ) | const
| noexcept

Returns the number of channels of audio data that this buffer contains.

See also
  getNumSamples, getReadPointer, getWritePointer

Referenced by ADSR::applyEnvelopeToBuffer(), AudioBuffer< Type >::makeCopyOf(), AudioBuffer< Type >::operator=(), and operator==().

## ◆ getNumSamples()

template<typename Type >

int AudioBuffer< Type >::getNumSamples | ( |  | ) | const
| noexcept

Returns the number of samples allocated in each of the buffer's channels.

See also
  getNumChannels, getReadPointer, getWritePointer

Referenced by ADSR::applyEnvelopeToBuffer(), AudioProcessor::getBusBuffer(), AudioBuffer< Type >::makeCopyOf(), and AudioBuffer< Type >::operator=().

## ◆ getReadPointer() [1/2]

template<typename Type >

const Type * AudioBuffer< Type >::getReadPointer | ( | int | channelNumber | ) | const
| noexcept

Returns a pointer to an array of read-only samples in one of the buffer's channels.

For speed, this doesn't check whether the channel number is out of range, so be careful when using it!

If you need to write to the data, do NOT call this method and const_cast the result! Instead, you must call getWritePointer so that the buffer knows you're planning on modifying the data.

References isPositiveAndBelow(), and jassert.

Referenced by AudioBuffer< Type >::makeCopyOf().

## ◆ getReadPointer() [2/2]

template<typename Type >

const Type * AudioBuffer< Type >::getReadPointer | ( | int | channelNumber,
|  | int | sampleIndex ) const
| noexcept

Returns a pointer to an array of read-only samples in one of the buffer's channels.

For speed, this doesn't check whether the channel number or index are out of range, so be careful when using it!

If you need to write to the data, do NOT call this method and const_cast the result! Instead, you must call getWritePointer so that the buffer knows you're planning on modifying the data.

References isPositiveAndBelow(), and jassert.

## ◆ getWritePointer() [1/2]

template<typename Type >

Type * AudioBuffer< Type >::getWritePointer | ( | int | channelNumber | ) |
| noexcept

Returns a writeable pointer to one of the buffer's channels.

For speed, this doesn't check whether the channel number is out of range, so be careful when using it!

Note that if you're not planning on writing to the data, you should always use getReadPointer instead.

This will mark the buffer as not cleared and the hasBeenCleared method will return false after this call. If you retain this write pointer and write some data to the buffer after calling its clear method, subsequent clear calls will do nothing. To avoid this either call this method each time you need to write data, or use the setNotClear method to force the internal cleared flag to false.

See also
  setNotClear

References isPositiveAndBelow(), and jassert.

Referenced by ADSR::applyEnvelopeToBuffer(), juce::dsp::Chorus< SampleType >::process(), and juce::dsp::Phaser< SampleType >::process().

## ◆ getWritePointer() [2/2]

template<typename Type >

Type * AudioBuffer< Type >::getWritePointer | ( | int | channelNumber,
|  | int | sampleIndex )
| noexcept

Returns a writeable pointer to one of the buffer's channels.

For speed, this doesn't check whether the channel number or index are out of range, so be careful when using it!

Note that if you're not planning on writing to the data, you should use getReadPointer instead.

This will mark the buffer as not cleared and the hasBeenCleared method will return false after this call. If you retain this write pointer and write some data to the buffer after calling its clear method, subsequent clear calls will do nothing. To avoid this either call this method each time you need to write data, or use the setNotClear method to force the internal cleared flag to false.

See also
  setNotClear

References isPositiveAndBelow(), and jassert.

## ◆ getArrayOfReadPointers()

template<typename Type >

const Type *const * AudioBuffer< Type >::getArrayOfReadPointers | ( |  | ) | const
| noexcept

Returns an array of pointers to the channels in the buffer.

Don't modify any of the pointers that are returned, and bear in mind that these will become invalid if the buffer is resized.

## ◆ getArrayOfWritePointers()

template<typename Type >

Type *const * AudioBuffer< Type >::getArrayOfWritePointers | ( |  | ) |
| noexcept

Returns an array of pointers to the channels in the buffer.

Don't modify any of the pointers that are returned, and bear in mind that these will become invalid if the buffer is resized.

This will mark the buffer as not cleared and the hasBeenCleared method will return false after this call. If you retain this write pointer and write some data to the buffer after calling its clear method, subsequent clear calls will do nothing. To avoid this either call this method each time you need to write data, or use the setNotClear method to force the internal cleared flag to false.

See also
  setNotClear

Referenced by AudioProcessor::getBusBuffer().

## ◆ setSize()

template<typename Type >

void AudioBuffer< Type >::setSize | ( | int | newNumChannels,
|  | int | newNumSamples,
|  | bool | keepExistingContent = false,
|  | bool | clearExtraSpace = false,
|  | bool | avoidReallocating = false )

Changes the buffer's size or number of channels.

This can expand or contract the buffer's length, and add or remove channels.

Note that if keepExistingContent and avoidReallocating are both true, then it will only avoid reallocating if neither the channel count or length in samples increase.

If the required memory can't be allocated, this will throw a std::bad_alloc exception.

Parameters

  newNumChannels | the new number of channels.
  newNumSamples | the new number of samples.
  keepExistingContent | if this is true, it will try to preserve as much of the old data as it can in the new buffer.
  clearExtraSpace | if this is true, then any extra channels or space that is allocated will be also be cleared. If false, then this space is left uninitialised.
  avoidReallocating | if this is true, then changing the buffer's size won't reduce the amount of memory that is currently allocated (but it will still increase it if the new size is bigger than the amount it currently has). If this is false, then a new allocation will be done so that the buffer uses takes up the minimum amount of memory that it needs.

References HeapBlock< ElementType, throwOnFailure >::allocate(), HeapBlock< ElementType, throwOnFailure >::clear(), HeapBlock< ElementType, throwOnFailure >::get(), jassert, jmin(), and HeapBlock< ElementType, throwOnFailure >::swapWith().

Referenced by AudioBuffer< Type >::makeCopyOf(), and AudioBuffer< Type >::operator=().

## ◆ setDataToReferTo() [1/2]

template<typename Type >

void AudioBuffer< Type >::setDataToReferTo | ( | Type *const * | dataToReferTo,
|  | int | newNumChannels,
|  | int | newStartSample,
|  | int | newNumSamples )

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.

The hasBeenCleared method will return false after this call.

Parameters

  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.
  newNumChannels | the number of channels to use - this must correspond to the number of elements in the array passed in
  newStartSample | the offset within the arrays at which the data begins
  newNumSamples | the number of samples to use - this must correspond to the size of the arrays passed in

References HeapBlock< ElementType, throwOnFailure >::free(), and jassert.

Referenced by AudioBuffer< Type >::setDataToReferTo().

## ◆ setDataToReferTo() [2/2]

template<typename Type >

void AudioBuffer< Type >::setDataToReferTo | ( | Type *const * | dataToReferTo,
|  | int | newNumChannels,
|  | int | newNumSamples )

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.

The hasBeenCleared method will return false after this call.

Parameters

  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.
  newNumChannels | the number of channels to use - this must correspond to the number of elements in the array passed in
  newNumSamples | the number of samples to use - this must correspond to the size of the arrays passed in

References AudioBuffer< Type >::setDataToReferTo().

## ◆ makeCopyOf()

template<typename Type >
template<typename OtherType >

void AudioBuffer< Type >::makeCopyOf | ( | const AudioBuffer< OtherType > & | other,
|  | bool | avoidReallocating = false )

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.

The hasBeenCleared method will return false after this call if the other buffer contains data.

References AudioBuffer< Type >::clear(), AudioBuffer< Type >::getNumChannels(), AudioBuffer< Type >::getNumSamples(), AudioBuffer< Type >::getReadPointer(), AudioBuffer< Type >::hasBeenCleared(), and AudioBuffer< Type >::setSize().

## ◆ clear() [1/3]

template<typename Type >

void AudioBuffer< Type >::clear | ( |  | ) |
| noexcept

Clears all the samples in all channels and marks the buffer as cleared.

This method will do nothing if the buffer has been marked as cleared (i.e. the hasBeenCleared method returns true.)

See also
  hasBeenCleared, setNotClear

References JUCE_BEGIN_IGNORE_WARNINGS_MSVC, and JUCE_END_IGNORE_WARNINGS_MSVC.

Referenced by ADSR::applyEnvelopeToBuffer(), AudioBuffer< Type >::AudioBuffer(), AudioSourceChannelInfo::clearActiveBufferRegion(), AudioBuffer< Type >::makeCopyOf(), and AudioBuffer< Type >::operator=().

## ◆ clear() [2/3]

template<typename Type >

void AudioBuffer< Type >::clear | ( | int | startSample,
|  | int | numSamples )
| noexcept

Clears a specified region of all the channels.

This will mark the buffer as cleared if the entire buffer contents are cleared.

For speed, this doesn't check whether the channel and sample number are in-range, so be careful!

This method will do nothing if the buffer has been marked as cleared (i.e. the hasBeenCleared method returns true.)

See also
  hasBeenCleared, setNotClear

References jassert.

## ◆ clear() [3/3]

template<typename Type >

void AudioBuffer< Type >::clear | ( | int | channel,
|  | int | startSample,
|  | int | numSamples )
| noexcept

Clears a specified region of just one channel.

For speed, this doesn't check whether the channel and sample number are in-range, so be careful!

This method will do nothing if the buffer has been marked as cleared (i.e. the hasBeenCleared method returns true.)

See also
  hasBeenCleared, setNotClear

References isPositiveAndBelow(), and jassert.

## ◆ hasBeenCleared()

template<typename Type >

bool AudioBuffer< Type >::hasBeenCleared | ( |  | ) | const
| noexcept

Returns true if the buffer has been entirely cleared.

Note that this does not actually measure the contents of the buffer - it simply returns a flag that is set when the buffer is cleared, and which is reset whenever functions like getWritePointer are invoked. That means the method is quick, but it may return false negatives when in fact the buffer is still empty.

Referenced by AudioBuffer< Type >::makeCopyOf().

## ◆ setNotClear()

template<typename Type >

void AudioBuffer< Type >::setNotClear | ( |  | ) |
| noexcept

Forces the internal cleared flag of the buffer to false.

This may be useful in the case where you are holding on to a write pointer and call the clear method before writing some data. You can then use this method to mark the buffer as containing data so that subsequent clear calls will succeed. However a better solution is to call getWritePointer each time you need to write data.

## ◆ getSample()

template<typename Type >

Type AudioBuffer< Type >::getSample | ( | int | channel,
|  | int | sampleIndex ) const
| noexcept

Returns a sample from the buffer.

The channel and index are not checked - they are expected to be in-range. If not, an assertion will be thrown, but in a release build, you're into 'undefined behaviour' territory.

References isPositiveAndBelow(), and jassert.

## ◆ setSample()

template<typename Type >

void AudioBuffer< Type >::setSample | ( | int | destChannel,
|  | int | destSample,
|  | Type | newValue )
| noexcept

Sets a sample in the buffer.

The channel and index are not checked - they are expected to be in-range. If not, an assertion will be thrown, but in a release build, you're into 'undefined behaviour' territory.

The hasBeenCleared method will return false after this call.

References isPositiveAndBelow(), and jassert.

## ◆ addSample()

template<typename Type >

void AudioBuffer< Type >::addSample | ( | int | destChannel,
|  | int | destSample,
|  | Type | valueToAdd )
| noexcept

Adds a value to a sample in the buffer.

The channel and index are not checked - they are expected to be in-range. If not, an assertion will be thrown, but in a release build, you're into 'undefined behaviour' territory.

The hasBeenCleared method will return false after this call.

References isPositiveAndBelow(), and jassert.

## ◆ applyGain() [1/3]

template<typename Type >

void AudioBuffer< Type >::applyGain | ( | int | channel,
|  | int | startSample,
|  | int | numSamples,
|  | Type | gain )
| noexcept

Applies a gain multiple to a region of one channel.

For speed, this doesn't check whether the channel and sample number are in-range, so be careful!

References approximatelyEqual(), isPositiveAndBelow(), and jassert.

Referenced by ADSR::applyEnvelopeToBuffer(), AudioBuffer< Type >::applyGain(), AudioBuffer< Type >::applyGain(), and AudioBuffer< Type >::applyGainRamp().

## ◆ applyGain() [2/3]

template<typename Type >

void AudioBuffer< Type >::applyGain | ( | int | startSample,
|  | int | numSamples,
|  | Type | gain )
| noexcept

Applies a gain multiple to a region of all the channels.

For speed, this doesn't check whether the sample numbers are in-range, so be careful!

References AudioBuffer< Type >::applyGain().

## ◆ applyGain() [3/3]

template<typename Type >

void AudioBuffer< Type >::applyGain | ( | Type | gain | ) |
| noexcept

Applies a gain multiple to all the audio data.

References AudioBuffer< Type >::applyGain().

## ◆ applyGainRamp() [1/2]

template<typename Type >

void AudioBuffer< Type >::applyGainRamp | ( | int | channel,
|  | int | startSample,
|  | int | numSamples,
|  | Type | startGain,
|  | Type | endGain )
| noexcept

Applies a range of gains to a region of a channel.

The gain that is applied to each sample will vary from startGain on the first sample to endGain on the last Sample, so it can be used to do basic fades.

For speed, this doesn't check whether the sample numbers are in-range, so be careful!

References AudioBuffer< Type >::applyGain(), approximatelyEqual(), isPositiveAndBelow(), and jassert.

Referenced by AudioBuffer< Type >::applyGainRamp().

## ◆ applyGainRamp() [2/2]

template<typename Type >

void AudioBuffer< Type >::applyGainRamp | ( | int | startSample,
|  | int | numSamples,
|  | Type | startGain,
|  | Type | endGain )
| noexcept

Applies a range of gains to a region of all channels.

The gain that is applied to each sample will vary from startGain on the first sample to endGain on the last Sample, so it can be used to do basic fades.

For speed, this doesn't check whether the sample numbers are in-range, so be careful!

References AudioBuffer< Type >::applyGainRamp().

## ◆ addFrom() [1/2]

template<typename Type >

void AudioBuffer< Type >::addFrom | ( | int | destChannel,
|  | int | destStartSample,
|  | const AudioBuffer< Type > & | source,
|  | int | sourceChannel,
|  | int | sourceStartSample,
|  | int | numSamples,
|  | Type | gainToApplyToSource = Type (1) )
| noexcept

Adds samples from another buffer to this one.

The hasBeenCleared method will return false after this call if samples have been added.

Parameters

  destChannel | the channel within this buffer to add the samples to
  destStartSample | the start sample within this buffer's channel
  source | the source buffer to add from
  sourceChannel | the channel within the source buffer to read from
  sourceStartSample | the offset within the source buffer's channel to start reading samples from
  numSamples | the number of samples to process
  gainToApplyToSource | an optional gain to apply to the source samples before they are added to this buffer's samples

See also
  copyFrom

References approximatelyEqual(), isPositiveAndBelow(), jassert, JUCE_BEGIN_IGNORE_WARNINGS_MSVC, and JUCE_END_IGNORE_WARNINGS_MSVC.

Referenced by AudioBuffer< Type >::addFromWithRamp().

## ◆ addFrom() [2/2]

template<typename Type >

void AudioBuffer< Type >::addFrom | ( | int | destChannel,
|  | int | destStartSample,
|  | const Type * | source,
|  | int | numSamples,
|  | Type | gainToApplyToSource = Type (1) )
| noexcept

Adds samples from an array of floats to one of the channels.

The hasBeenCleared method will return false after this call if samples have been added.

Parameters

  destChannel | the channel within this buffer to add the samples to
  destStartSample | the start sample within this buffer's channel
  source | the source data to use
  numSamples | the number of samples to process
  gainToApplyToSource | an optional gain to apply to the source samples before they are added to this buffer's samples

See also
  copyFrom

References approximatelyEqual(), isPositiveAndBelow(), and jassert.

## ◆ addFromWithRamp()

template<typename Type >

void AudioBuffer< Type >::addFromWithRamp | ( | int | destChannel,
|  | int | destStartSample,
|  | const Type * | source,
|  | int | numSamples,
|  | Type | startGain,
|  | Type | endGain )
| noexcept

Adds samples from an array of floats, applying a gain ramp to them.

The hasBeenCleared method will return false after this call if samples have been added.

Parameters

  destChannel | the channel within this buffer to add the samples to
  destStartSample | the start sample within this buffer's channel
  source | the source data to use
  numSamples | the number of samples to process
  startGain | the gain to apply to the first sample (this is multiplied with the source samples before they are added to this buffer)
  endGain | The gain that would apply to the sample after the final sample. The gain that applies to the final sample is (numSamples - 1) / numSamples * (endGain - startGain). This ensures a continuous ramp when supplying the same value in endGain and startGain in subsequent blocks. The gain is linearly interpolated between the first and last samples.

References AudioBuffer< Type >::addFrom(), approximatelyEqual(), isPositiveAndBelow(), and jassert.

## ◆ copyFrom() [1/3]

template<typename Type >

void AudioBuffer< Type >::copyFrom | ( | int | destChannel,
|  | int | destStartSample,
|  | const AudioBuffer< Type > & | source,
|  | int | sourceChannel,
|  | int | sourceStartSample,
|  | int | numSamples )
| noexcept

Copies samples from another buffer to this one.

Parameters

  destChannel | the channel within this buffer to copy the samples to
  destStartSample | the start sample within this buffer's channel
  source | the source buffer to read from
  sourceChannel | the channel within the source buffer to read from
  sourceStartSample | the offset within the source buffer's channel to start reading samples from
  numSamples | the number of samples to process

See also
  addFrom

References isPositiveAndBelow(), and jassert.

Referenced by AudioBuffer< Type >::copyFromWithRamp().

## ◆ copyFrom() [2/3]

template<typename Type >

void AudioBuffer< Type >::copyFrom | ( | int | destChannel,
|  | int | destStartSample,
|  | const Type * | source,
|  | int | numSamples )
| noexcept

Copies samples from an array of floats into one of the channels.

The hasBeenCleared method will return false after this call if samples have been copied.

Parameters

  destChannel | the channel within this buffer to copy the samples to
  destStartSample | the start sample within this buffer's channel
  source | the source buffer to read from
  numSamples | the number of samples to process

See also
  addFrom

References isPositiveAndBelow(), and jassert.

## ◆ copyFrom() [3/3]

template<typename Type >

void AudioBuffer< Type >::copyFrom | ( | int | destChannel,
|  | int | destStartSample,
|  | const Type * | source,
|  | int | numSamples,
|  | Type | gain )
| noexcept

Copies samples from an array of floats into one of the channels, applying a gain to it.

The hasBeenCleared method will return false after this call if samples have been copied.

Parameters

  destChannel | the channel within this buffer to copy the samples to
  destStartSample | the start sample within this buffer's channel
  source | the source buffer to read from
  numSamples | the number of samples to process
  gain | the gain to apply

See also
  addFrom

References approximatelyEqual(), isPositiveAndBelow(), and jassert.

## ◆ copyFromWithRamp()

template<typename Type >

void AudioBuffer< Type >::copyFromWithRamp | ( | int | destChannel,
|  | int | destStartSample,
|  | const Type * | source,
|  | int | numSamples,
|  | Type | startGain,
|  | Type | endGain )
| noexcept

Copies samples from an array of floats into one of the channels, applying a gain ramp.

The hasBeenCleared method will return false after this call if samples have been copied.

Parameters

  destChannel | the channel within this buffer to copy the samples to
  destStartSample | the start sample within this buffer's channel
  source | the source buffer to read from
  numSamples | the number of samples to process
  startGain | the gain to apply to the first sample (this is multiplied with the source samples before they are copied to this buffer)
  endGain | The gain that would apply to the sample after the final sample. The gain that applies to the final sample is (numSamples - 1) / numSamples * (endGain - startGain). This ensures a continuous ramp when supplying the same value in endGain and startGain in subsequent blocks. The gain is linearly interpolated between the first and last samples.

See also
  addFrom

References approximatelyEqual(), AudioBuffer< Type >::copyFrom(), isPositiveAndBelow(), and jassert.

## ◆ findMinMax()

template<typename Type >

Range< Type > AudioBuffer< Type >::findMinMax | ( | int | channel,
|  | int | startSample,
|  | int | numSamples ) const
| noexcept

Returns a Range indicating the lowest and highest sample values in a given section.

Parameters

  channel | the channel to read from
  startSample | the start sample within the channel
  numSamples | the number of samples to check

References isPositiveAndBelow(), and jassert.

Referenced by AudioBuffer< Type >::getMagnitude().

## ◆ getMagnitude() [1/2]

template<typename Type >

Type AudioBuffer< Type >::getMagnitude | ( | int | channel,
|  | int | startSample,
|  | int | numSamples ) const
| noexcept

Finds the highest absolute sample value within a region of a channel.

References AudioBuffer< Type >::findMinMax(), isPositiveAndBelow(), jassert, and jmax().

Referenced by AudioBuffer< Type >::getMagnitude().

## ◆ getMagnitude() [2/2]

template<typename Type >

Type AudioBuffer< Type >::getMagnitude | ( | int | startSample,
|  | int | numSamples ) const
| noexcept

Finds the highest absolute sample value within a region on all channels.

References AudioBuffer< Type >::getMagnitude(), and jmax().

## ◆ getRMSLevel()

template<typename Type >

Type AudioBuffer< Type >::getRMSLevel | ( | int | channel,
|  | int | startSample,
|  | int | numSamples ) const
| noexcept

Returns the root mean squared level for a region of a channel.

References isPositiveAndBelow(), and jassert.

## ◆ reverse() [1/2]

template<typename Type >

void AudioBuffer< Type >::reverse | ( | int | channel,
|  | int | startSample,
|  | int | numSamples ) const
| noexcept

Reverses a part of a channel.

References isPositiveAndBelow(), and jassert.

Referenced by AudioBuffer< Type >::reverse().

## ◆ reverse() [2/2]

template<typename Type >

void AudioBuffer< Type >::reverse | ( | int | startSample,
|  | int | numSamples ) const
| noexcept

Reverses a part of the buffer.

References AudioBuffer< Type >::reverse().

The documentation for this class was generated from the following file:

- juce_AudioSampleBuffer.h