Public Types | Public Member Functions | Static Public Member Functions | List of all members
dsp::AudioBlock< SampleType > Class Template Reference

Minimal and lightweight data-structure which contains a list of pointers to channels containing some kind of sample data. More...

Public Types

using NumericType = typename SampleTypeHelpers::ElementType< SampleType >::Type
 

Public Member Functions

forcedinline AudioBlock () noexcept
 Create a zero-sized AudioBlock. More...
 
forcedinline AudioBlock (SampleType *const *channelData, size_t numberOfChannels, size_t numberOfSamples) noexcept
 Creates an AudioBlock from a pointer to an array of channels. More...
 
forcedinline 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. More...
 
 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. More...
 
 AudioBlock (AudioBuffer< SampleType > &buffer) noexcept
 Creates an AudioBlock that points to the data in an AudioBuffer. More...
 
 AudioBlock (AudioBuffer< SampleType > &buffer, size_t startSampleIndex) noexcept
 Creates an AudioBlock that points to the data in an AudioBuffer. More...
 
 AudioBlock (const AudioBlock &other) noexcept=default
 
AudioBlockoperator= (const AudioBlock &other) noexcept=default
 
forcedinline size_t getNumSamples () const noexcept
 
forcedinline size_t getNumChannels () const noexcept
 
forcedinline const SampleType * getChannelPointer (size_t channel) const noexcept
 Returns a raw pointer into one of the channels in this block. More...
 
forcedinline SampleType * getChannelPointer (size_t channel) noexcept
 Returns a raw pointer into one of the channels in this block. More...
 
forcedinline AudioBlock getSingleChannelBlock (size_t channel) const noexcept
 Returns an AudioBlock that represents one of the channels in this block. More...
 
forcedinline AudioBlock getSubsetChannelBlock (size_t channelStart, size_t numChannelsToUse) noexcept
 Returns a subset of continguous channels. More...
 
SampleType getSample (int channel, int sampleIndex) const noexcept
 Returns a sample from the buffer. More...
 
void setSample (int destChannel, int destSample, SampleType newValue) noexcept
 Modifies a sample in the buffer. More...
 
void addSample (int destChannel, int destSample, SampleType valueToAdd) noexcept
 Adds a value to a sample in the buffer. More...
 
forcedinline AudioBlockclear () noexcept
 Clear the memory described by this AudioBlock. More...
 
forcedinline AudioBlock &JUCE_VECTOR_CALLTYPE fill (SampleType value) noexcept
 Fill memory with value. More...
 
forcedinline AudioBlockcopy (AudioBlock src) noexcept
 Copy the values in src to the receiver. More...
 
forcedinline AudioBlockmove (size_t srcPos, size_t dstPos, size_t numElements=std::numeric_limits< size_t >::max()) noexcept
 Move memory within the receiver from the position srcPos to the position dstPos. More...
 
AudioBlock getSubBlock (size_t newOffset, size_t newLength) const noexcept
 Return a new AudioBlock pointing to a sub-block inside the receiver. More...
 
AudioBlock getSubBlock (size_t newOffset) const noexcept
 Return a new AudioBlock pointing to a sub-block inside the receiver. More...
 
forcedinline AudioBlock &JUCE_VECTOR_CALLTYPE add (SampleType value) noexcept
 Adds a fixed value to the receiver. More...
 
forcedinline AudioBlockadd (AudioBlock src) noexcept
 Adds the source values to the receiver. More...
 
forcedinline AudioBlock &JUCE_VECTOR_CALLTYPE add (AudioBlock src, SampleType value) noexcept
 Adds a fixed value to each source value and stores it in the destination array of the receiver. More...
 
forcedinline AudioBlockadd (AudioBlock src1, AudioBlock src2) noexcept
 Adds each source1 value to the corresponding source2 value and stores it in the destination array of the receiver. More...
 
forcedinline AudioBlock &JUCE_VECTOR_CALLTYPE subtract (SampleType value) noexcept
 Subtracts a fixed value from the receiver. More...
 
forcedinline AudioBlocksubtract (AudioBlock src) noexcept
 Subtracts the source values from the receiver. More...
 
forcedinline AudioBlock &JUCE_VECTOR_CALLTYPE subtract (AudioBlock src, SampleType value) noexcept
 Subtracts a fixed value from each source value and stores it in the destination array of the receiver. More...
 
forcedinline AudioBlocksubtract (AudioBlock src1, AudioBlock src2) noexcept
 Subtracts each source2 value from the corresponding source1 value and stores it in the destination array of the receiver. More...
 
forcedinline AudioBlock &JUCE_VECTOR_CALLTYPE multiply (SampleType value) noexcept
 Multiplies a fixed value to the receiver. More...
 
forcedinline AudioBlockmultiply (AudioBlock src) noexcept
 Multiplies the source values to the receiver. More...
 
forcedinline AudioBlock &JUCE_VECTOR_CALLTYPE multiply (AudioBlock src, SampleType value) noexcept
 Multiplies a fixed value to each source value and stores it in the destination array of the receiver. More...
 
forcedinline AudioBlockmultiply (AudioBlock src1, AudioBlock src2) noexcept
 Multiplies each source1 value to the corresponding source2 value and stores it in the destination array of the receiver. More...
 
AudioBlockmultiply (LinearSmoothedValue< SampleType > &value) noexcept
 Multiplies all channels of the AudioBlock by a smoothly changing value and stores them . More...
 
AudioBlockmultiply (AudioBlock src, LinearSmoothedValue< SampleType > &value) noexcept
 Multiplies all channels of the source by a smoothly changing value and stores them in the receiver. More...
 
forcedinline AudioBlock &JUCE_VECTOR_CALLTYPE addWithMultiply (AudioBlock src, SampleType factor) noexcept
 Multiplies each value in src with factor and adds the result to the receiver. More...
 
forcedinline AudioBlockaddWithMultiply (AudioBlock src1, AudioBlock src2) noexcept
 Multiplies each value in srcA with the corresponding value in srcB and adds the result to the receiver. More...
 
forcedinline AudioBlocknegate () noexcept
 Negates each value of the receiver. More...
 
forcedinline AudioBlockreplaceWithNegativeOf (AudioBlock src) noexcept
 Negates each value of source and stores it in the receiver. More...
 
forcedinline AudioBlockreplaceWithAbsoluteValueOf (AudioBlock src) noexcept
 Takes the absolute value of each element of src and stores it inside the receiver. More...
 
forcedinline AudioBlockmin (AudioBlock src1, AudioBlock src2) noexcept
 Each element of receiver will be the minimum of the corresponding element of the source arrays. More...
 
forcedinline AudioBlockmax (AudioBlock src1, AudioBlock src2) noexcept
 Each element of the receiver will be the maximum of the corresponding element of the source arrays. More...
 
forcedinline Range< NumericTypefindMinAndMax () const noexcept
 Finds the minimum and maximum value of the buffer. More...
 
forcedinline AudioBlock &JUCE_VECTOR_CALLTYPE operator+= (SampleType src) noexcept
 
forcedinline AudioBlockoperator+= (AudioBlock src) noexcept
 
forcedinline AudioBlock &JUCE_VECTOR_CALLTYPE operator-= (SampleType src) noexcept
 
forcedinline AudioBlockoperator-= (AudioBlock src) noexcept
 
forcedinline AudioBlock &JUCE_VECTOR_CALLTYPE operator*= (SampleType src) noexcept
 
forcedinline AudioBlockoperator*= (AudioBlock src) noexcept
 
forcedinline AudioBlockoperator*= (LinearSmoothedValue< SampleType > &value) noexcept
 

Static Public Member Functions

template<typename FunctionType >
static void process (AudioBlock inBlock, AudioBlock outBlock, FunctionType &&function)
 Applies a function to each value in an input block, putting the result into an output block. More...
 

Detailed Description

template<typename SampleType>
class dsp::AudioBlock< SampleType >

Minimal and lightweight data-structure which contains a list of pointers to channels containing some kind of sample data.

This class doesn't own any of the data which it points to, it's simply a view into data that is owned elsewhere. You can construct one from some raw data that you've allocated yourself, or give it a HeapBlock to use, or give it an AudioBuffer which it can refer to, but in all cases the user is responsible for making sure that the data doesn't get deleted while there's still an AudioBlock using it.

Member Typedef Documentation

◆ NumericType

template<typename SampleType>
using dsp::AudioBlock< SampleType >::NumericType = typename SampleTypeHelpers::ElementType<SampleType>::Type

Constructor & Destructor Documentation

◆ AudioBlock() [1/7]

template<typename SampleType>
forcedinline dsp::AudioBlock< SampleType >::AudioBlock ( )
noexcept

◆ AudioBlock() [2/7]

template<typename SampleType>
forcedinline dsp::AudioBlock< SampleType >::AudioBlock ( SampleType *const *  channelData,
size_t  numberOfChannels,
size_t  numberOfSamples 
)
noexcept

Creates an AudioBlock from a pointer to an array of channels.

AudioBlock does not copy nor own the memory pointed to by dataToUse. Therefore it is the user's responsibility to ensure that the memory is retained throughout the life-time of the AudioBlock and released when no longer needed.

◆ AudioBlock() [3/7]

template<typename SampleType>
forcedinline dsp::AudioBlock< SampleType >::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 does not copy nor own the memory pointed to by dataToUse. Therefore it is the user's responsibility to ensure that the memory is retained throughout the life-time of the AudioBlock and released when no longer needed.

◆ AudioBlock() [4/7]

template<typename SampleType>
dsp::AudioBlock< SampleType >::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.

The HeapBlock must of course not be freed or re-allocated while this object is still in use, because it will be referencing its data.

◆ AudioBlock() [5/7]

template<typename SampleType>
dsp::AudioBlock< SampleType >::AudioBlock ( AudioBuffer< SampleType > &  buffer)
noexcept

Creates an AudioBlock that points to the data in an AudioBuffer.

AudioBlock does not copy nor own the memory pointed to by dataToUse. Therefore it is the user's responsibility to ensure that the buffer is retained throughout the life-time of the AudioBlock without being modified.

◆ AudioBlock() [6/7]

template<typename SampleType>
dsp::AudioBlock< SampleType >::AudioBlock ( AudioBuffer< SampleType > &  buffer,
size_t  startSampleIndex 
)
noexcept

Creates an AudioBlock that points to the data in an AudioBuffer.

AudioBlock does not copy nor own the memory pointed to by dataToUse. Therefore it is the user's responsibility to ensure that the buffer is retained throughout the life-time of the AudioBlock without being modified.

◆ AudioBlock() [7/7]

template<typename SampleType>
dsp::AudioBlock< SampleType >::AudioBlock ( const AudioBlock< SampleType > &  other)
defaultnoexcept

Member Function Documentation

◆ operator=()

template<typename SampleType>
AudioBlock& dsp::AudioBlock< SampleType >::operator= ( const AudioBlock< SampleType > &  other)
defaultnoexcept

◆ getNumSamples()

template<typename SampleType>
forcedinline size_t dsp::AudioBlock< SampleType >::getNumSamples ( ) const
noexcept

◆ getNumChannels()

template<typename SampleType>
forcedinline size_t dsp::AudioBlock< SampleType >::getNumChannels ( ) const
noexcept

◆ getChannelPointer() [1/2]

template<typename SampleType>
forcedinline const SampleType* dsp::AudioBlock< SampleType >::getChannelPointer ( size_t  channel) const
noexcept

Returns a raw pointer into one of the channels in this block.

Referenced by dsp::AudioBlock< float >::move(), and dsp::AudioBlock< float >::process().

◆ getChannelPointer() [2/2]

template<typename SampleType>
forcedinline SampleType* dsp::AudioBlock< SampleType >::getChannelPointer ( size_t  channel)
noexcept

Returns a raw pointer into one of the channels in this block.

◆ getSingleChannelBlock()

template<typename SampleType>
forcedinline AudioBlock dsp::AudioBlock< SampleType >::getSingleChannelBlock ( size_t  channel) const
noexcept

Returns an AudioBlock that represents one of the channels in this block.

◆ getSubsetChannelBlock()

template<typename SampleType>
forcedinline AudioBlock dsp::AudioBlock< SampleType >::getSubsetChannelBlock ( size_t  channelStart,
size_t  numChannelsToUse 
)
noexcept

Returns a subset of continguous channels.

Parameters
channelStartFirst channel of the subset
numChannelsToUseCount of channels in the subset

◆ getSample()

template<typename SampleType>
SampleType dsp::AudioBlock< SampleType >::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.

◆ setSample()

template<typename SampleType>
void dsp::AudioBlock< SampleType >::setSample ( int  destChannel,
int  destSample,
SampleType  newValue 
)
noexcept

Modifies 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.

◆ addSample()

template<typename SampleType>
void dsp::AudioBlock< SampleType >::addSample ( int  destChannel,
int  destSample,
SampleType  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.

◆ clear()

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::clear ( )
noexcept

Clear the memory described by this AudioBlock.

◆ fill()

template<typename SampleType>
forcedinline AudioBlock& JUCE_VECTOR_CALLTYPE dsp::AudioBlock< SampleType >::fill ( SampleType  value)
noexcept

Fill memory with value.

◆ copy()

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::copy ( AudioBlock< SampleType >  src)
noexcept

Copy the values in src to the receiver.

Referenced by dsp::AudioBlock< float >::multiply().

◆ move()

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::move ( size_t  srcPos,
size_t  dstPos,
size_t  numElements = std::numeric_limits<size_t>::max() 
)
noexcept

Move memory within the receiver from the position srcPos to the position dstPos.

If numElements is not specified then move will move the maximum amount of memory.

◆ getSubBlock() [1/2]

template<typename SampleType>
AudioBlock dsp::AudioBlock< SampleType >::getSubBlock ( size_t  newOffset,
size_t  newLength 
) const
noexcept

Return a new AudioBlock pointing to a sub-block inside the receiver.

This function does not copy the memory and you must ensure that the original memory pointed to by the receiver remains valid through-out the life-time of the returned sub-block.

Parameters
newOffsetThe index of an element inside the reciever which will will become the first element of the return value.
newLengthThe number of elements of the newly created sub-block.

Referenced by dsp::AudioBlock< float >::getSubBlock().

◆ getSubBlock() [2/2]

template<typename SampleType>
AudioBlock dsp::AudioBlock< SampleType >::getSubBlock ( size_t  newOffset) const
noexcept

Return a new AudioBlock pointing to a sub-block inside the receiver.

This function does not copy the memory and you must ensure that the original memory pointed to by the receiver remains valid through-out the life-time of the returned sub-block.

Parameters
newOffsetThe index of an element inside the reciever which will will become the first element of the return value. The return value will include all subsequent elements of the receiver.

◆ add() [1/4]

template<typename SampleType>
forcedinline AudioBlock& JUCE_VECTOR_CALLTYPE dsp::AudioBlock< SampleType >::add ( SampleType  value)
noexcept

Adds a fixed value to the receiver.

Referenced by dsp::AudioBlock< float >::operator+=(), and dsp::AudioBlock< float >::subtract().

◆ add() [2/4]

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::add ( AudioBlock< SampleType >  src)
noexcept

Adds the source values to the receiver.

◆ add() [3/4]

template<typename SampleType>
forcedinline AudioBlock& JUCE_VECTOR_CALLTYPE dsp::AudioBlock< SampleType >::add ( AudioBlock< SampleType >  src,
SampleType  value 
)
noexcept

Adds a fixed value to each source value and stores it in the destination array of the receiver.

◆ add() [4/4]

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::add ( AudioBlock< SampleType >  src1,
AudioBlock< SampleType >  src2 
)
noexcept

Adds each source1 value to the corresponding source2 value and stores it in the destination array of the receiver.

◆ subtract() [1/4]

template<typename SampleType>
forcedinline AudioBlock& JUCE_VECTOR_CALLTYPE dsp::AudioBlock< SampleType >::subtract ( SampleType  value)
noexcept

Subtracts a fixed value from the receiver.

Referenced by dsp::AudioBlock< float >::operator-=().

◆ subtract() [2/4]

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::subtract ( AudioBlock< SampleType >  src)
noexcept

Subtracts the source values from the receiver.

◆ subtract() [3/4]

template<typename SampleType>
forcedinline AudioBlock& JUCE_VECTOR_CALLTYPE dsp::AudioBlock< SampleType >::subtract ( AudioBlock< SampleType >  src,
SampleType  value 
)
noexcept

Subtracts a fixed value from each source value and stores it in the destination array of the receiver.

◆ subtract() [4/4]

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::subtract ( AudioBlock< SampleType >  src1,
AudioBlock< SampleType >  src2 
)
noexcept

Subtracts each source2 value from the corresponding source1 value and stores it in the destination array of the receiver.

◆ multiply() [1/6]

template<typename SampleType>
forcedinline AudioBlock& JUCE_VECTOR_CALLTYPE dsp::AudioBlock< SampleType >::multiply ( SampleType  value)
noexcept

Multiplies a fixed value to the receiver.

Referenced by dsp::AudioBlock< float >::negate(), and dsp::AudioBlock< float >::operator*=().

◆ multiply() [2/6]

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::multiply ( AudioBlock< SampleType >  src)
noexcept

Multiplies the source values to the receiver.

◆ multiply() [3/6]

template<typename SampleType>
forcedinline AudioBlock& JUCE_VECTOR_CALLTYPE dsp::AudioBlock< SampleType >::multiply ( AudioBlock< SampleType >  src,
SampleType  value 
)
noexcept

Multiplies a fixed value to each source value and stores it in the destination array of the receiver.

◆ multiply() [4/6]

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::multiply ( AudioBlock< SampleType >  src1,
AudioBlock< SampleType >  src2 
)
noexcept

Multiplies each source1 value to the corresponding source2 value and stores it in the destination array of the receiver.

◆ multiply() [5/6]

template<typename SampleType>
AudioBlock& dsp::AudioBlock< SampleType >::multiply ( LinearSmoothedValue< SampleType > &  value)
noexcept

Multiplies all channels of the AudioBlock by a smoothly changing value and stores them .

◆ multiply() [6/6]

template<typename SampleType>
AudioBlock& dsp::AudioBlock< SampleType >::multiply ( AudioBlock< SampleType >  src,
LinearSmoothedValue< SampleType > &  value 
)
noexcept

Multiplies all channels of the source by a smoothly changing value and stores them in the receiver.

◆ addWithMultiply() [1/2]

template<typename SampleType>
forcedinline AudioBlock& JUCE_VECTOR_CALLTYPE dsp::AudioBlock< SampleType >::addWithMultiply ( AudioBlock< SampleType >  src,
SampleType  factor 
)
noexcept

Multiplies each value in src with factor and adds the result to the receiver.

◆ addWithMultiply() [2/2]

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::addWithMultiply ( AudioBlock< SampleType >  src1,
AudioBlock< SampleType >  src2 
)
noexcept

Multiplies each value in srcA with the corresponding value in srcB and adds the result to the receiver.

◆ negate()

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::negate ( )
noexcept

Negates each value of the receiver.

◆ replaceWithNegativeOf()

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::replaceWithNegativeOf ( AudioBlock< SampleType >  src)
noexcept

Negates each value of source and stores it in the receiver.

◆ replaceWithAbsoluteValueOf()

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::replaceWithAbsoluteValueOf ( AudioBlock< SampleType >  src)
noexcept

Takes the absolute value of each element of src and stores it inside the receiver.

◆ min()

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::min ( AudioBlock< SampleType >  src1,
AudioBlock< SampleType >  src2 
)
noexcept

Each element of receiver will be the minimum of the corresponding element of the source arrays.

◆ max()

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::max ( AudioBlock< SampleType >  src1,
AudioBlock< SampleType >  src2 
)
noexcept

Each element of the receiver will be the maximum of the corresponding element of the source arrays.

◆ findMinAndMax()

template<typename SampleType>
forcedinline Range<NumericType> dsp::AudioBlock< SampleType >::findMinAndMax ( ) const
noexcept

Finds the minimum and maximum value of the buffer.

◆ operator+=() [1/2]

template<typename SampleType>
forcedinline AudioBlock& JUCE_VECTOR_CALLTYPE dsp::AudioBlock< SampleType >::operator+= ( SampleType  src)
noexcept

◆ operator+=() [2/2]

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::operator+= ( AudioBlock< SampleType >  src)
noexcept

◆ operator-=() [1/2]

template<typename SampleType>
forcedinline AudioBlock& JUCE_VECTOR_CALLTYPE dsp::AudioBlock< SampleType >::operator-= ( SampleType  src)
noexcept

◆ operator-=() [2/2]

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::operator-= ( AudioBlock< SampleType >  src)
noexcept

◆ operator*=() [1/3]

template<typename SampleType>
forcedinline AudioBlock& JUCE_VECTOR_CALLTYPE dsp::AudioBlock< SampleType >::operator*= ( SampleType  src)
noexcept

◆ operator*=() [2/3]

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::operator*= ( AudioBlock< SampleType >  src)
noexcept

◆ operator*=() [3/3]

template<typename SampleType>
forcedinline AudioBlock& dsp::AudioBlock< SampleType >::operator*= ( LinearSmoothedValue< SampleType > &  value)
noexcept

◆ process()

template<typename SampleType>
template<typename FunctionType >
static void dsp::AudioBlock< SampleType >::process ( AudioBlock< SampleType >  inBlock,
AudioBlock< SampleType >  outBlock,
FunctionType &&  function 
)
static

Applies a function to each value in an input block, putting the result into an output block.

The function supplied must take a SampleType as its parameter, and return a SampleType. The two blocks must have the same number of channels and samples.

Referenced by dsp::WaveShaper< FloatType, Function >::process().


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