OpenWareLaboratory
SimpleArray< T > Class Template Reference

SimpleArray holds a pointer to an array and the array size, and is designed to be passed by value. More...

Inheritance diagram for SimpleArray< T >:

Public Member Functions

void copyFrom (SimpleArray< T > source)
 Copies the content of another array into this array. More...
 
void copyTo (SimpleArray< T > destination)
 Copies the content of this array to another array. More...
 
bool equals (const SimpleArray< T > &other) const
 Compares two arrays. More...
 
T * getData ()
 Get the data stored in the Array. More...
 
getElement (size_t index)
 Get a single value stored in the array. More...
 
size_t getSize () const
 
void insert (SimpleArray< T > source, int destinationOffset, size_t len)
 Copies the content of an array into a subset of the array. More...
 
void insert (SimpleArray< T > source, int sourceOffset, int destinationOffset, size_t len)
 Copies the content of an array into a subset of the array. More...
 
bool isEmpty () const
 
void move (int fromIndex, int toIndex, size_t len)
 Copies values within an array. More...
 
 operator T* ()
 Casting operator to T*. More...
 
void setElement (size_t index, T value)
 Set a single value in the array. More...
 
 SimpleArray ()
 
 SimpleArray (T *data, size_t size)
 

Static Public Member Functions

static void copy (T *dst, T *src, size_t len)
 Optimised array copy for datatype T. More...
 

Protected Attributes

T * data
 
size_t size
 

Detailed Description

template<typename T>
class SimpleArray< T >

SimpleArray holds a pointer to an array and the array size, and is designed to be passed by value.

It does not define any virtual methods to prevent overheads in its subclasses.

Definition at line 14 of file SimpleArray.h.

Constructor & Destructor Documentation

◆ SimpleArray() [1/2]

template<typename T >
SimpleArray< T >::SimpleArray ( )
inline

Definition at line 19 of file SimpleArray.h.

◆ SimpleArray() [2/2]

template<typename T >
SimpleArray< T >::SimpleArray ( T *  data,
size_t  size 
)
inline

Definition at line 20 of file SimpleArray.h.

Member Function Documentation

◆ copy()

template<typename T >
static void SimpleArray< T >::copy ( T *  dst,
T *  src,
size_t  len 
)
inlinestatic

Optimised array copy for datatype T.

Copy four at a time to minimise loop overheads and allow SIMD optimisations. This performs well on external RAM but is slower on internal memory compared to memcpy.

Definition at line 134 of file SimpleArray.h.

◆ copyFrom()

template<typename T >
void SimpleArray< T >::copyFrom ( SimpleArray< T >  source)
inline

◆ copyTo()

template<typename T >
void SimpleArray< T >::copyTo ( SimpleArray< T >  destination)
inline

Copies the content of this array to another array.

The other array needs to be at least as big as this array.

Parameters
[out]destinationthe destination array

Definition at line 76 of file SimpleArray.h.

References ASSERT, SimpleArray< T >::data, and SimpleArray< T >::size.

Referenced by AudioBuffer::copyTo().

◆ equals()

template<typename T >
bool SimpleArray< T >::equals ( const SimpleArray< T > &  other) const
inline

Compares two arrays.

Performs an element-wise comparison of the values contained in the arrays.

Parameters
otherthe array to compare against.
Returns
true if the arrays have the same size and the value of each of the elements of the one match the value of the corresponding element of the other, or false otherwise.

Definition at line 61 of file SimpleArray.h.

References SimpleArray< T >::data, and SimpleArray< T >::size.

◆ getData()

◆ getElement()

template<typename T >
T SimpleArray< T >::getElement ( size_t  index)
inline

Get a single value stored in the array.

Returns
the value stored at index
Parameters
index

Definition at line 43 of file SimpleArray.h.

References SimpleArray< T >::data.

◆ getSize()

template<typename T >
size_t SimpleArray< T >::getSize ( ) const
inline

Definition at line 31 of file SimpleArray.h.

References SimpleArray< T >::size.

Referenced by KaiserWindow::buildTimeDerivativeWindow(), KaiserWindow::buildWindow(), ComplexFloatArray::complexByRealMultiplication(), FourierPitchDetector::computeFrequency(), FloatArray::convolve(), ShortArray::convolve(), FilterStage::copyCoefficients(), BiquadFilter::copyCoefficients(), FirFilter::copyCoefficients(), BiquadFilter::copyState(), FirFilter::copyState(), GaussianNoiseGenerator::create(), FloatArray::decibelToGain(), CrossFadingCircularBuffer< T >::delay(), Resampler::downsample(), ComplexFourierTransform::fft(), FastFourierTransform::fft(), ShortFastFourierTransform::fft(), SampleOscillator< im >::findZeroCrossing(), FirFilter::FirFilter(), ComplexFloatArray::fromFloat(), IntArray::fromFloat(), ShortArray::fromFloat(), FloatArray::gainToDecibel(), GaussianNoiseGenerator::generate(), QuadratureSineOscillator::generate(), FeedbackQuadratureSineOscillator::generate(), ComplexFeedbackQuadratureSineOscillator::generate(), ComplexSignalGenerator::generate(), ComplexOscillator::generate(), InterpolatingSignalGenerator< im >::generate(), PolyBlepOscillator::generate(), AntialiasedRampOscillator::generate(), SampleOscillator< im >::generate(), SignalGenerator::generate(), SineOscillator::generate(), AntialiasedSquareWaveOscillator::generate(), VosimOscillator::generate(), Oscillator::generate(), SimpleMovingAverage::getAverage(), ComplexFloatArray::getComplexConjugateValues(), VoltsPerOctave::getFrequency(), ComplexFloatArray::getMagnitudeSquaredValues(), ComplexShortArray::getMagnitudeSquaredValues(), SimpleMovingAverage::getNextAverage(), SimpleMovingAverage::getNextSum(), ComplexFloatArray::getPhaseValues(), ComplexFloatArray::getPolar(), WavetableOscillator::getSample(), AntialiasedWavetableOscillator::getSample(), VoltsPerOctave::getSample(), SampleOscillator< im >::getSampleLength(), PolyBlepOscillator::getSamples(), ComplexFourierTransform::getSize(), FastFourierTransform::getSize(), SimpleMovingAverage::getSize(), ShortFastFourierTransform::getSize(), ComplexFourierTransform::ifft(), FastFourierTransform::ifft(), ShortFastFourierTransform::ifft(), MultiStateVariableFilter::process(), InterpolatedCompositeTransform< matrix_order >::process(), ComplexSignalProcessor::process(), FirFilter::process(), BiquadFilter::process(), DcBlockingFilter::process(), SmoothingFilter::process(), EnvelopeFollower::process(), ExponentialMovingAverage::process(), SimpleMovingAverage::process(), FourierPitchDetector::process(), ZeroCrossingPitchDetector::process(), DelayProcessor::process(), FractionalDelayProcessor< im >::process(), CrossFadingDelayProcessor::process(), Envelope::process(), UpSampler::process(), DownSampler::process(), SignalProcessor::process(), StateVariableFilter::process(), BiquadFilter::processAllPass(), BiquadFilter::processBandPass(), StateVariableFilter::processBandPass(), BiquadFilter::processHighPass(), StateVariableFilter::processHighPass(), StateVariableFilter::processLowBandHighPass(), BiquadFilter::processLowPass(), StateVariableFilter::processLowPass(), WavFile::read(), FloatArray::rectify(), ShortArray::rectify(), SimpleMovingAverage::set(), BiquadFilter::setCoefficients(), ComplexFloatArray::setMagnitude(), ComplexFloatArray::setPhase(), SampleOscillator< im >::setSample(), BiquadFilter::setState(), InterpolatingWavetableOscillator< im >::setWavetable(), FastFractionalDelayProcessor::smooth(), ComplexFloatArray::toFloat(), IntArray::toFloat(), ShortArray::toFloat(), and Resampler::upsample().

◆ insert() [1/2]

template<typename T >
void SimpleArray< T >::insert ( SimpleArray< T >  source,
int  destinationOffset,
size_t  len 
)
inline

Copies the content of an array into a subset of the array.

Copies len elements from source to destinationOffset in the current array.

Parameters
[in]sourcethe source array
[in]destinationOffsetthe offset into the destination array
[in]lenthe number of samples to copy

Definition at line 99 of file SimpleArray.h.

Referenced by FourierPitchDetector::process().

◆ insert() [2/2]

template<typename T >
void SimpleArray< T >::insert ( SimpleArray< T >  source,
int  sourceOffset,
int  destinationOffset,
size_t  len 
)
inline

Copies the content of an array into a subset of the array.

Copies len elements starting from sourceOffset of source to destinationOffset in the current array.

Parameters
[in]sourcethe source array
[in]sourceOffsetthe offset into the source array
[in]destinationOffsetthe offset into the destination array
[in]lenthe number of samples to copy

Definition at line 111 of file SimpleArray.h.

References ASSERT, SimpleArray< T >::data, and SimpleArray< T >::size.

◆ isEmpty()

template<typename T >
bool SimpleArray< T >::isEmpty ( ) const
inline

Definition at line 35 of file SimpleArray.h.

References SimpleArray< T >::size.

◆ move()

template<typename T >
void SimpleArray< T >::move ( int  fromIndex,
int  toIndex,
size_t  len 
)
inline

Copies values within an array.

Copies length values starting from index fromIndex to locations starting with index toIndex

Parameters
[in]fromIndexthe first element to copy
[in]toIndexthe destination of the first element
[in]lenthe number of elements to copy

Definition at line 124 of file SimpleArray.h.

References ASSERT, SimpleArray< T >::data, and SimpleArray< T >::size.

◆ operator T*()

template<typename T >
SimpleArray< T >::operator T* ( )
inline

Casting operator to T*.

Returns
a T* pointer to the data stored in the Array

Definition at line 157 of file SimpleArray.h.

◆ setElement()

template<typename T >
void SimpleArray< T >::setElement ( size_t  index,
value 
)
inline

Set a single value in the array.

Definition at line 50 of file SimpleArray.h.

References SimpleArray< T >::data.

Field Documentation

◆ data

◆ size


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