19 #define thisTTClass TTAverage
20 #define thisTTClassName "average"
21 #define thisTTClassTags "dspAnalysisLib, audio, analysis, rms, energy, movingAverage"
24 #ifndef TT_PLATFORM_MAC
45 setAttributeValue(kTTSym_maxNumChannels, initialMaxNumChannels);
46 setAttributeValue(
TT(
"maxInterval"), 2000);
47 setAttributeValue(
TT(
"mode"),
TT(
"bipolar"));
48 setAttributeValue(
TT(
"interval"), 100);
54 TTAverage::~TTAverage()
63 for (TTDelayBufferIter buffer = mBins.begin(); buffer != mBins.end(); ++buffer) {
82 for (TTDelayBufferIter buffer = mBins.begin(); buffer != mBins.end(); ++buffer)
90 for_each(mBins.begin(), mBins.end(), std::mem_fun_ref(&TTDelayBuffer::clear));
100 if (
mMode != newMode) {
143 #pragma mark dsp routines
148 #define TTAVERAGE_WRAP_CALCULATE_METHOD(methodName) \
149 TTAudioSignal& in = anInputs->getSignal(0); \
150 TTAudioSignal& out = anOutputs->getSignal(0); \
152 TTSampleValue* inSample; \
153 TTSampleValue* outSample; \
154 TTChannelCount numchannels = TTAudioSignal::getMinChannelCount(in, out); \
155 TTPtrSizedInt channel; \
156 TTDelayBufferPtr buffer; \
158 for (channel=0; channel<numchannels; channel++) { \
159 inSample = in.mSampleVectors[channel]; \
160 outSample = out.mSampleVectors[channel]; \
161 vs = in.getVectorSizeAsInt(); \
162 buffer = &mBins[channel]; \
165 methodName (*inSample, *outSample, buffer, channel); \
TTSampleVector mAccumulator
An accumulator used for calculation of running averages.
TTErr updateMaxNumChannels(const TTValue &anOldMaxNumChannels, TTValue &aNotUsed)
This method gets called when the inherited maxNumChannels attribute is changed.
An inappropriate value was specified for an attribute or variable.
std::uint64_t TTUInt64
64 bit unsigned integer
TTErr setInterval(const TTValue &aNewInterval)
Set the interval to use when averaging.
TTChannelCount mMaxNumChannels
This is the maximum number of channels that can be guaranteed to work.
TTSampleValuePtr mWritePointer
"record" pointer for buffer
TTErr clear()
Reset (clear) the history used in the analysis.
#define setProcessMethod(methodName)
A convenience macro to be used by subclasses for setting the process method.
TTAverage - measuring of averaged and RMS signal energy
TTUInt64 mInterval
The interval to do running averaging over.
double TTFloat64
64 bit floating point number
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
TTErr setMode(const TTValue &newValue)
Set the mode attribute that controlles what averaging mode to use.
TTErr updateSampleRate(const TTValue &aNotUsed1, TTValue &aNotUsed2)
Receives notifications when there are changes to the inherited sr attribute.
#define addAttributeProperty(attributeName, propertyName, initialValue)
A convenience macro to be used for registering properties of attributes.
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
TTSampleValuePtr mReadPointer
"playback" pointer
TTErr setMaxInterval(const TTValue &aNewMaxInterval)
Set the maximum interval that can be used when averaging.
TTErr processBipolarAverage(TTAudioSignalArrayPtr anInputs, TTAudioSignalArrayPtr anOutputs)
Audio process method to use when doing bipolar averaging.
TTErr calculateBipolarValue(const TTFloat64 &anInput, TTFloat64 &anOutput, TTDelayBufferPtr aDelayBuffer, TTPtrSizedInt aChannel)
An inline method for single sample calculation of bipolar average value.
TTSymbol mMode
Averaging mode, options are absolute, bipolar and rms.
TTErr init(TTUInt64 newDelayMaxInSamples)
Internal method - set up the buffer memory.
TTUInt16 TTChannelCount
Data type used when counting the number of channels in multi-channel audio signals and processes...
64-bit signed integer, ragne is −9,223,372,036,854,775,808 through 9,223,372,036,854,775,807
TTFloat64 mIntervalReciprocal
The inverse of mInterval. Calculated and stored for conviniency and efficiency.
TTErr processRmsAverage(TTAudioSignalArrayPtr anInputs, TTAudioSignalArrayPtr anOutputs)
Audio process method to use when doing root-mean-square averaging.
A simple container for an array of TTAudioSignal pointers.
void clear()
Clear all values from the vector, leaving with size of 0.
long TTPtrSizedInt
An integer that is the same size as a pointer.
TTErr processAbsoluteAverage(TTAudioSignalArrayPtr anInputs, TTAudioSignalArrayPtr anOutputs)
Audio process method to use when doing absolute value averaging.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
#define addAttributeWithSetter(name, type)
A convenience macro to be used by subclasses for registering attributes with a custom setter...
#define addMessage(name)
A convenience macro to be used by subclasses for registering messages.
TTErr calculateAbsoluteValue(const TTFloat64 &anInput, TTFloat64 &anOutput, TTDelayBufferPtr aDelayBuffer, TTPtrSizedInt aChannel)
An inline method for single sample calculation of absolute average value.
void reset()
Internal method - Position the buffer pointers.
void resize(size_type n)
Change the number of elements.
[doxygenAppendixC_copyExample]
TTUInt64 mMaxInterval
The largest possible interval or window to do running averaging over.
TTDelayBuffer is a container object that holds some audio in a chunk of memory, with accessors for us...
#define addUpdates(updateName)
An 'update' is a message sent to a subclass instance from its parent class.
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.