Jamoma API  0.6.0.a19
TTAverage Class Reference

TTAverage - measuring averaged and RMS signal energy. More...

#include <TTAverage.h>

+ Inheritance diagram for TTAverage:
+ Collaboration diagram for TTAverage:

Public Member Functions

TTErr calculateBipolarValue (const TTFloat64 &anInput, TTFloat64 &anOutput, TTPtrSizedInt aChannel)
 A method for single sample calculation of bipolar average value. More...
 
TTErr calculateAbsoluteValue (const TTFloat64 &anInput, TTFloat64 &anOutput, TTPtrSizedInt aChannel)
 A method for single sample calculation of absolute average value. More...
 
TTErr calculateRmsValue (const TTFloat64 &anInput, TTFloat64 &anOutput, TTPtrSizedInt aChannel)
 A method for single sample calculation of rms (root mean square) average value. More...
 
TTErr clear ()
 Reset (clear) the history used in the analysis. More...
 
TTErr setMode (const TTValue &newValue)
 Set the mode attribute that controlles what averaging mode to use. More...
 
TTErr setInterval (const TTValue &aNewInterval)
 Set the interval to use when averaging. More...
 
TTErr setMaxInterval (const TTValue &aNewMaxInterval)
 Set the maximum interval that can be used when averaging. More...
 

Protected Member Functions

TTErr updateMaxNumChannels (const TTValue &anOldMaxNumChannels, TTValue &aNotUsed)
 This method gets called when the inherited maxNumChannels attribute is changed. More...
 
TTErr updateSampleRate (const TTValue &aNotUsed1, TTValue &aNotUsed2)
 Receives notifications when there are changes to the inherited sr attribute. More...
 
TTErr init (TTUInt64 newDelayMaxInSamples)
 Internal method - set up the buffer memory. More...
 
void reset ()
 Internal method - Position the buffer pointers.
 
TTErr processBipolarAverage (TTAudioSignalArrayPtr anInputs, TTAudioSignalArrayPtr anOutputs)
 Audio process method to use when doing bipolar averaging. More...
 
TTErr calculateBipolarValue (const TTFloat64 &anInput, TTFloat64 &anOutput, TTDelayBufferPtr aDelayBuffer, TTPtrSizedInt aChannel)
 An inline method for single sample calculation of bipolar average value. More...
 
TTErr processAbsoluteAverage (TTAudioSignalArrayPtr anInputs, TTAudioSignalArrayPtr anOutputs)
 Audio process method to use when doing absolute value averaging. More...
 
TTErr calculateAbsoluteValue (const TTFloat64 &anInput, TTFloat64 &anOutput, TTDelayBufferPtr aDelayBuffer, TTPtrSizedInt aChannel)
 An inline method for single sample calculation of absolute average value. More...
 
TTErr processRmsAverage (TTAudioSignalArrayPtr anInputs, TTAudioSignalArrayPtr anOutputs)
 Audio process method to use when doing root-mean-square averaging. More...
 
TTErr calculateRmsValue (const TTFloat64 &anInput, TTFloat64 &anOutput, TTDelayBufferPtr aDelayBuffer, TTPtrSizedInt aChannel)
 An inline method for single sample calculation of rms (root mean square) average value. More...
 
virtual TTErr test (TTValue &returnedTestInfo)
 Unit test. More...
 

Protected Attributes

TTUInt64 mMaxInterval
 The largest possible interval or window to do running averaging over.
 
TTUInt64 mInterval
 The interval to do running averaging over.
 
TTFloat64 mIntervalReciprocal
 The inverse of mInterval. Calculated and stored for conviniency and efficiency.
 
TTSampleVector mAccumulator
 An accumulator used for calculation of running averages.
 
TTSymbol mMode
 Averaging mode, options are absolute, bipolar and rms.
 

Detailed Description

TTAverage - measuring averaged and RMS signal energy.

Definition at line 25 of file TTAverage.h.

Member Function Documentation

TTErr TTAverage::calculateAbsoluteValue ( const TTFloat64 anInput,
TTFloat64 anOutput,
TTDelayBufferPtr  aDelayBuffer,
TTPtrSizedInt  aChannel 
)
inlineprotected

An inline method for single sample calculation of absolute average value.

Parameters
anInputAn input sample value
anOutputAn output (processed) sample value
aDelayBufferDelay buffer used for calculation of running averages
aChannelThe audio channel to perform to processing for
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 186 of file TTAverage.cpp.

References kTTErrNone, mAccumulator, mIntervalReciprocal, TTDelayBuffer::mReadPointer, and TTDelayBuffer::mWritePointer.

Referenced by calculateAbsoluteValue(), and processAbsoluteAverage().

TTErr TTAverage::calculateAbsoluteValue ( const TTFloat64 anInput,
TTFloat64 anOutput,
TTPtrSizedInt  aChannel 
)

A method for single sample calculation of absolute average value.

Parameters
anInputAn input sample value
anOutputAn output (processed) sample value
aChannelThe audio channel to perform to processing for
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 173 of file TTAverage.cpp.

References calculateAbsoluteValue().

+ Here is the call graph for this function:

TTErr TTAverage::calculateBipolarValue ( const TTFloat64 anInput,
TTFloat64 anOutput,
TTDelayBufferPtr  aDelayBuffer,
TTPtrSizedInt  aChannel 
)
inlineprotected

An inline method for single sample calculation of bipolar average value.

Parameters
anInputAn input sample value
anOutputAn output (processed) sample value
aDelayBufferDelay buffer used for calculation of running averages
aChannelThe audio channel to perform to processing for
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 213 of file TTAverage.cpp.

References kTTErrNone, mAccumulator, mIntervalReciprocal, TTDelayBuffer::mReadPointer, and TTDelayBuffer::mWritePointer.

Referenced by calculateBipolarValue(), and processBipolarAverage().

TTErr TTAverage::calculateBipolarValue ( const TTFloat64 anInput,
TTFloat64 anOutput,
TTPtrSizedInt  aChannel 
)

A method for single sample calculation of bipolar average value.

Parameters
anInputAn input sample value
anOutputAn output (processed) sample value
aChannelThe audio channel to perform to processing for
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 202 of file TTAverage.cpp.

References calculateBipolarValue().

+ Here is the call graph for this function:

TTErr TTAverage::calculateRmsValue ( const TTFloat64 anInput,
TTFloat64 anOutput,
TTDelayBufferPtr  aDelayBuffer,
TTPtrSizedInt  aChannel 
)
inlineprotected

An inline method for single sample calculation of rms (root mean square) average value.

Parameters
anInputAn input sample value
anOutputAn output (processed) sample value
aDelayBufferDelay buffer used for calculation of running averages
aChannelThe audio channel to perform to processing for
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 241 of file TTAverage.cpp.

References kTTErrNone, mAccumulator, mIntervalReciprocal, TTDelayBuffer::mReadPointer, and TTDelayBuffer::mWritePointer.

Referenced by calculateRmsValue(), and processRmsAverage().

TTErr TTAverage::calculateRmsValue ( const TTFloat64 anInput,
TTFloat64 anOutput,
TTPtrSizedInt  aChannel 
)

A method for single sample calculation of rms (root mean square) average value.

Parameters
anInputAn input sample value
anOutputAn output (processed) sample value
aChannelThe audio channel to perform to processing for
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 229 of file TTAverage.cpp.

References calculateRmsValue().

+ Here is the call graph for this function:

TTErr TTAverage::clear ( )

Reset (clear) the history used in the analysis.

Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 88 of file TTAverage.cpp.

References kTTErrNone, mAccumulator, and TTAudioObjectBase::mMaxNumChannels.

Referenced by setInterval(), and setMode().

TTErr TTAverage::init ( TTUInt64  newDelayMaxInSamples)
protected

Internal method - set up the buffer memory.

Parameters
newDelayMaxInSamplesNew value for maximum samples to permit.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 60 of file TTAverage.cpp.

References TTValue::clear(), kTTErrNone, mMaxInterval, reset(), and TTValue::resize().

Referenced by setMaxInterval(), and updateMaxNumChannels().

+ Here is the call graph for this function:

TTErr TTAverage::processAbsoluteAverage ( TTAudioSignalArrayPtr  anInputs,
TTAudioSignalArrayPtr  anOutputs 
)
protected

Audio process method to use when doing absolute value averaging.

Parameters
anInputsA pointer to a TTAudioSignal object that may contain any number of channels. This signal is considered the master, and thus it provides the vectorsize and number of channels should the two signals not be matched.
anOutputsA pointer to a TTAudioSignal object that has the output sample vectors.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 180 of file TTAverage.cpp.

References calculateAbsoluteValue().

Referenced by setMode().

+ Here is the call graph for this function:

TTErr TTAverage::processBipolarAverage ( TTAudioSignalArrayPtr  anInputs,
TTAudioSignalArrayPtr  anOutputs 
)
protected

Audio process method to use when doing bipolar averaging.

Parameters
anInputsA pointer to a TTAudioSignal object that may contain any number of channels. This signal is considered the master, and thus it provides the vectorsize and number of channels should the two signals not be matched.
anOutputsA pointer to a TTAudioSignal object that has the output sample vectors.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 208 of file TTAverage.cpp.

References calculateBipolarValue().

Referenced by setMode().

+ Here is the call graph for this function:

TTErr TTAverage::processRmsAverage ( TTAudioSignalArrayPtr  anInputs,
TTAudioSignalArrayPtr  anOutputs 
)
protected

Audio process method to use when doing root-mean-square averaging.

Parameters
anInputsA pointer to a TTAudioSignal object that may contain any number of channels. This signal is considered the master, and thus it provides the vectorsize and number of channels should the two signals not be matched.
anOutputsA pointer to a TTAudioSignal object that has the output sample vectors.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 235 of file TTAverage.cpp.

References calculateRmsValue().

Referenced by setMode().

+ Here is the call graph for this function:

TTErr TTAverage::setInterval ( const TTValue aNewInterval)

Set the interval to use when averaging.

Parameters
aNewIntervalThe new interval to use when averaging.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 118 of file TTAverage.cpp.

References clear(), kTTErrNone, mInterval, mIntervalReciprocal, and reset().

+ Here is the call graph for this function:

TTErr TTAverage::setMaxInterval ( const TTValue aNewMaxInterval)

Set the maximum interval that can be used when averaging.

Parameters
aNewMaxIntervalThe outcome from the performed unit test.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 127 of file TTAverage.cpp.

References init(), and mMaxInterval.

+ Here is the call graph for this function:

TTErr TTAverage::setMode ( const TTValue newValue)

Set the mode attribute that controlles what averaging mode to use.

Options are bipolar, absolute and rms. This method also ensures that the correct process method will be used.

Parameters
aNewModeThe new mode to use.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 96 of file TTAverage.cpp.

References clear(), kTTErrInvalidValue, mMode, processAbsoluteAverage(), processBipolarAverage(), processRmsAverage(), reset(), setProcessMethod, and TT.

+ Here is the call graph for this function:

TTErr TTAverage::test ( TTValue returnedTestInfo)
protectedvirtual

Unit test.

Parameters
returnedTestInfoThe outcome from the performed unit test.
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Reimplemented from TTAudioObjectBase.

Definition at line 20 of file TTAverage.test.cpp.

References TTAudioSignal::allocWithVectorSize(), TTAudioSignal::clear(), TTAudioSignal::mSampleVectors, TTAudioObjectBase::process(), TTObjectBase::setAttributeValue(), TT, TTObjectBaseInstantiate(), and TTObjectBaseRelease().

+ Here is the call graph for this function:

TTErr TTAverage::updateMaxNumChannels ( const TTValue anOldMaxNumChannels,
TTValue aNotUsed 
)
protected

This method gets called when the inherited maxNumChannels attribute is changed.

Parameters
aNotUsed1Not used
aNotUsed2Not used
Returns
TTErr error code if the method fails to execute, else kTTErrNone.

Definition at line 73 of file TTAverage.cpp.

References init(), mAccumulator, mMaxInterval, and TTAudioObjectBase::mMaxNumChannels.

+ Here is the call graph for this function:

TTErr TTAverage::updateSampleRate ( const TTValue aNotUsed1,
TTValue aNotUsed2 
)
protected

Receives notifications when there are changes to the inherited sr attribute.

Definition at line 135 of file TTAverage.cpp.

References kTTErrNone.


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