Jamoma API  0.6.0.a19
TTLimiter Class Reference

TTLimiter implements a lookahead limiter processor for controlling the dynamics of an input. More...

#include <TTLimiter.h>

+ Inheritance diagram for TTLimiter:
+ Collaboration diagram for TTLimiter:

Protected Member Functions

TTErr updateMaxNumChannels (const TTValue &oldMaxNumChannels, TTValue &)
 Override the setter for the inherited maxNumChannels attribute. More...
 
TTErr updateSampleRate (const TTValue &oldSampleRate, TTValue &)
 Receives notifications when there are changes to the inherited sr attribute. More...
 
void setRecover ()
 Private utility used by the audio processing routine. More...
 
TTErr processAudio (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
 Standard audio processing method as used by TTBlue objects. More...
 
TTErr setPreamp (TTValue &value)
 Setter for the threshold attribute. More...
 
TTErr getPreamp (TTValue &value)
 Getter for the threshold attribute. More...
 
TTErr setPostamp (const TTValue &value)
 Setter for the threshold attribute. More...
 
TTErr getPostamp (TTValue &value)
 Getter for the threshold attribute. More...
 
TTErr setThreshold (const TTValue &value)
 Setter for the threshold attribute. More...
 
TTErr getThreshold (TTValue &value)
 Getter for the threshold attribute. More...
 
TTErr setLookahead (TTValue &newValue)
 Setter for the lookahead attribute, value is in samples. More...
 
TTErr setMode (TTValue &newValue)
 Setter for the mode attribute. More...
 
TTErr setRelease (TTValue &newValue)
 Setter for the release attribute. More...
 
TTErr setDCBlocker (TTValue &newValue)
 Setter for the dcblocker attribute. More...
 
TTErr clear ()
 Clear the history: reset the limiter. More...
 
- Protected Member Functions inherited from TTAudioObjectBase
TTErr setProcess (TTProcessMethod processMethod)
 Set the audio processing routine to point to a method that is defined as an arg to this function. More...
 
TTErr setCalculate (TTCalculateMethod newCalculateMethod)
 Set the sample calculate routine to point to a method that is defined as an arg to this function. More...
 
TTErr setBypass (const TTValue &value)
 Bypass the audio processing routine and copy all input samples to the output unchanged. More...
 
TTErr resetBenchmarking ()
 Reset the benchmarking accumulation used to calculate the results of getProcessingBenchmark(). More...
 
TTErr getProcessingBenchmark (TTValueConstRef, TTValueRef v)
 Return the average time spent by this object processing audio since the last reset. More...
 
 TTAudioObjectBase (const TTValue &arguments)
 Constructor. More...
 
- Protected Member Functions inherited from TTObjectBase
 TTObjectBase (const TTValue arguments)
 Constructor. More...
 

Protected Attributes

TTFloat64 lookaheadInv
 reciprocal (inverse) of the lookahead attribute
 
TTSampleValue ** lookaheadBuffer
 keep a lookahead buffer for each channel
 
TTBoolean isLinear
 is attrMode set to linear?
 
TTAudioObject dcBlocker
 TTDCBlock object
 
TTAudioObject preamp
 TTGain object to apply preamp
 
TTUInt32 maxBufferSize
 TODO: make this settable.
 
TTBoolean attrDCBlocker
 If toggled to NO, the internal DC Blocker will be turned off.
 
TTSymbol attrMode
 may be one of two symbols: "linear" or "exponential".
 
TTFloat64 attrRelease
 number of seconds for the release to recover after a peak in the audio signal.
 
TTUInt32 attrLookahead
 number of samples by which to look forward.
 
TTFloat64 attrThreshold
 linear amplitude threshold at which the limiting should kick in (attr setter used dB).
 
TTFloat64 attrPostamp
 linear gain scaling factor after the limiting (attr setter used dB).
 
- Protected Attributes inherited from TTAudioObjectBase
TTUInt32 sr
 Current sample rate being used by this object.
 
TTFloat64 srInv
 1.0 over the current sample rate (inverse)
 
TTFloat64 srMill
 1/1000 of the current sample rate (samples per millisecond)
 
TTChannelCount mMaxNumChannels
 This is the maximum number of channels that can be guaranteed to work.
 
TTBoolean unused
 Old var that is not used anymore, but we want to keep the struct size the same.
 
TTBoolean attrBypass
 Are we bypassing the processMethod?
 
TTBoolean attrMute
 Mute the processMethod.
 
TTProcessMethod processMethod
 This function pointer points to the active (non-bypass) processing routine.
 
TTProcessMethod currentProcessMethod
 This function pointer always points to the current processing routine.
 
TTCalculateMethod calculateMethod
 This function pointer points to the active (non-bypass) calculate routine.
 
TTCalculateMethod currentCalculateMethod
 This function pointer always points to the current calculate routine.
 
TTObject inputArray
 If the process method is passed a signal, rather than an array of signals, we wrap the signal in this array.
 
TTObject outputArray
 If the process method is passed a signal, rather than an array of signals, we wrap the signal in this array.
 
TTFloat64 startProcessingTime
 The time at which this object's process method was last invoked (for benchmarking)
 
TTFloat64 accumulatedProcessingTime
 The amount of time spent in this object's process method (for benchmarking)
 
TTFloat64 accumulatedProcessingCalls
 The number of times the process method has been called (for benchmarking)
 
- Protected Attributes inherited from TTObjectBase
TTList observers
 List of all objects watching this object for life-cycle and other changes.
 

Additional Inherited Members

- Public Member Functions inherited from TTAudioObjectBase
TTErr setMute (const TTValue &value)
 Mute the audio processing routine and zero all output. More...
 
TTErr setMaxNumChannels (const TTValue &newValue)
 Setter for the maxNumChannels attribute. More...
 
TTErr adaptMaxNumChannels (const TTChannelCount newMaxNumChannels)
 Increase the maxNumChannels attribute, if neccessary. More...
 
TTErr setSr (const TTValue &newValue)
 Setter for the sample-rate attribute. More...
 
TTErr setSampleRate (const TTUInt32 &newSampleRate)
 Convenience method for updating the sample-rate. More...
 
virtual ~TTAudioObjectBase ()
 Destructor.
 
TTErr calculate (const TTFloat64 &x, TTFloat64 &y)
 Calculate a single sample of output for a single sample of input. More...
 
TTErr calculateMessage (TTValueConstRef input, TTValueRef output)
 
TTErr process (TTAudioSignal &in, TTAudioSignal &out)
 Process the input signal, resulting in an output signal. More...
 
TTErr process (TTAudioSignal &out)
 Process the an output signal only, e.g. More...
 
TTErr process (TTAudioSignal &in1, TTAudioSignal &in2, TTAudioSignal &out1, TTAudioSignal &out2)
 Process two input signals, resulting in two output signals. More...
 
TTErr process (TTAudioSignal &in1, TTAudioSignal &in2, TTAudioSignal &out)
 Process two input signals, resulting in an output signal. More...
 
TTErr process (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
 Process an array of audio signals. More...
 
TTErr bypassProcess (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
 The default audio processing method, which simply copies a signal through with no modifications. More...
 
TTErr bypassCalculate (const TTFloat64 &x, TTFloat64 &y, TTPtr data)
 Produces a result for calls to calculate when the unit is bypassed. More...
 
TTErr muteProcess (TTAudioSignalArrayPtr inputs, TTAudioSignalArrayPtr outputs)
 A muted audio processing method, which simply copies zeroes to the output. More...
 
TTErr defaultCalculateMethod (const TTFloat64 &x, TTFloat64 &y, TTPtr data)
 A default calculate method, which simply calls the process method with 1 channel signals that are 1 sample in length. More...
 
TTFloat64 hertzToRadians (const TTFloat64 hz)
 Convert Hertz to radians. More...
 
TTFloat64 radiansToHertz (const TTFloat64 radians)
 Convert radians into Hertz. More...
 
TTFloat64 degreesToRadians (const TTFloat64 degrees)
 Degrees-to-radians conversion. More...
 
TTFloat64 radiansToDegrees (const TTFloat64 radians)
 Radians-to-degrees conversion. More...
 
TTFloat64 decayToFeedback (const TTFloat64 decay_time, TTFloat64 delay)
 Decay Time (seconds) to feedback coefficient conversion. More...
 
TTFloat64 feedbackToDecay (const TTFloat64 feedback, const TTFloat64 delay)
 Return the decay time based on the feedback coefficient. More...
 
virtual TTErr test (TTValue &)
 Default (empty) template for unit tests. More...
 
- Public Member Functions inherited from TTObjectBase
virtual ~TTObjectBase ()
 Destructor.
 
TTUInt16 getReferenceCount ()
 Query an object to get its current reference count. More...
 
TTUInt32 getObserverCount () const
 Query an object to get the number of observers. More...
 
TTErr registerAttribute (const TTSymbol name, const TTDataType type, void *address)
 Register an attribute. More...
 
TTErr extendAttribute (const TTSymbol name, const TTObjectBasePtr extendedObject, const TTSymbol extendedName)
 Extend the attribute of an existing TTObjectBase to this TTObjectBase (using another attribute name) More...
 
TTErr removeAttribute (const TTSymbol name)
 Remove an attribute. More...
 
TTErr findAttribute (const TTSymbol name, TTAttribute **attr)
 Find an attribute. More...
 
TTErr setAttributeValue (const TTSymbol name, TTValue &value)
 Set an attribute value for an object. More...
 
template<class T >
TTErr set (const TTSymbol aName, T aValue)
 Set an attribute value for an object This is the same as calling setAttributeValue(). More...
 
TTErr getAttributeValue (const TTSymbol name, TTValue &value)
 Get an attribute value for an object. More...
 
template<class T >
TTErr get (const TTSymbol aName, T &aReturnedValue)
 Get an attribute value for an object This is the same as calling getAttributeValue(). More...
 
TTSymbol getAttributeType (const TTSymbol name)
 Return the type of an attribute as a symbol. More...
 
TTErr getAttributeGetterFlags (const TTSymbol name, TTAttributeFlags &value)
 Get the getterFlags of an attribute. More...
 
TTErr setAttributeGetterFlags (const TTSymbol name, TTAttributeFlags &value)
 Set the getterFlags of an attribute. More...
 
TTErr getAttributeSetterFlags (const TTSymbol name, TTAttributeFlags &value)
 Get the setterFlags of an attribute. More...
 
TTErr setAttributeSetterFlags (const TTSymbol name, TTAttributeFlags &value)
 Set the setterFlags of an attribute. More...
 
TTErr registerAttributeProperty (const TTSymbol attributeName, const TTSymbol propertyName, const TTValue &initialValue, TTGetterMethod getter, TTSetterMethod setter)
 Register an attribute property. More...
 
TTErr registerMessageProperty (const TTSymbol messageName, const TTSymbol propertyName, const TTValue &initialValue, TTGetterMethod getter, TTSetterMethod setter)
 Register an message property. More...
 
TTErr getAttribute (const TTSymbol name, TTAttributePtr *attributeObject)
 Search for and locate an attribute. More...
 
TTErr getMessage (const TTSymbol name, TTMessagePtr *messageObject)
 Search for and locate a message. More...
 
void getAttributeNames (TTValue &attributeNameList)
 Return a list of names of the available attributes. More...
 
void getMessageNames (TTValue &messageNameList)
 Return a list of names of the available messages. More...
 
TTSymbol getName () const
 Return the name of this class. More...
 
TTErr registerMessage (const TTSymbol name, TTMethod method)
 Register a message with this object. More...
 
TTErr findMessage (const TTSymbol name, TTMessage **message)
 Find a message registered with this object. More...
 
TTErr removeMessage (const TTSymbol name)
 Remove a message. More...
 
TTErr sendMessage (const TTSymbol name)
 TODO: Document this function. More...
 
TTErr registerObserverForMessage (const TTObject &observingObject, const TTSymbol messageName)
 Register an observer for a message. More...
 
TTErr registerObserverForAttribute (const TTObject &observingObject, const TTSymbol attributeName)
 Register an observer for an attribute. More...
 
TTErr registerObserverForNotifications (const TTObject &observingObject)
 Register an observer. More...
 
TTErr unregisterObserverForMessage (const TTObject &observingObject, const TTSymbol messageName)
 Unregister an observer for a message. More...
 
TTErr unregisterObserverForAttribute (const TTObject &observingObject, const TTSymbol attributeName)
 Unregister an observer for an attribute. More...
 
TTErr unregisterObserverForNotifications (const TTObject &observingObject)
 Unregister an observer for notifications. More...
 
TTErr sendNotification (const TTSymbol name, const TTValue &arguments)
 Send a notification. More...
 
TTErr logMessage (TTImmutableCString fmtstring,...)
 Log messages scoped to this object instance. More...
 
TTErr logWarning (TTImmutableCString fmtstring,...)
 Log warnings scoped to this object instance. More...
 
TTErr logError (TTImmutableCString fmtstring,...)
 Log errors scoped to this object instance. More...
 
TTErr logDebug (TTImmutableCString fmtstring,...)
 Log messages (scoped to this object instance) to output only if the basic debugging flag is enabled in the environment. More...
 
TTErr lock ()
 Lock the object in order to ensure thread-safe processing. More...
 
TTErr unlock ()
 Unlock the object when thread-safe processing is no longer required. More...
 
TTBoolean isLocked ()
 Query if the object currently is locked for thread-safe processing. More...
 
TTBoolean waitForLock ()
 If the object is locked (e.g. More...
 
- Public Attributes inherited from TTObjectBase
TTBoolean valid
 If the object isn't completely built, or is in the process of freeing, this will be false.
 
TTBoolean track
 enable the print of a log message to ease the track of reference counting mechanism on an instance More...
 

Detailed Description

TTLimiter implements a lookahead limiter processor for controlling the dynamics of an input.

The way this works is by buffering the input, and delaying it by N samples. That way we are able to see what the output will be some amount of time prior to actually outputting it, and adjust the gain accordingly.

After some preprocessing to adjust gain and filter DC offsets on the input, we have an analysis stage. The analysis stage looks at the sample value for each channel at the input, and then uses the hottest sample to calculate the gain adjust that needs to be applied.

The release attribute (specified in seconds) determines how long it takes for a gain reduction to "wear off" once the amplitude level of the input has been reduced.

Definition at line 40 of file TTLimiter.h.

Member Function Documentation

TTErr TTLimiter::clear ( )
protected

Clear the history: reset the limiter.

Definition at line 191 of file TTLimiter.cpp.

References dcBlocker, kTTErrNone, lookaheadBuffer, maxBufferSize, TTAudioObjectBase::mMaxNumChannels, TTObject::send(), and setRecover().

Referenced by updateMaxNumChannels().

+ Here is the call graph for this function:

TTErr TTLimiter::getPostamp ( TTValue value)
protected

Getter for the threshold attribute.

Definition at line 136 of file TTLimiter.cpp.

References attrPostamp, kTTErrNone, and TTLinearGainToDecibels().

+ Here is the call graph for this function:

TTErr TTLimiter::getPreamp ( TTValue value)
protected

Getter for the threshold attribute.

Definition at line 124 of file TTLimiter.cpp.

References TTObject::get(), and preamp.

+ Here is the call graph for this function:

TTErr TTLimiter::getThreshold ( TTValue value)
protected

Getter for the threshold attribute.

Definition at line 149 of file TTLimiter.cpp.

References attrThreshold, kTTErrNone, and TTLinearGainToDecibels().

+ Here is the call graph for this function:

TTErr TTLimiter::processAudio ( TTAudioSignalArrayPtr  inputs,
TTAudioSignalArrayPtr  outputs 
)
protected

Standard audio processing method as used by TTBlue objects.

Definition at line 223 of file TTLimiter.cpp.

References attrLookahead, attrPostamp, attrThreshold, dcBlocker, TTAudioSignal::getMinChannelCount(), isLinear, kTTErrNone, lookaheadBuffer, lookaheadInv, maxBufferSize, TTAudioSignal::mSampleVectors, and preamp.

+ Here is the call graph for this function:

TTErr TTLimiter::setDCBlocker ( TTValue newValue)
protected

Setter for the dcblocker attribute.

Definition at line 184 of file TTLimiter.cpp.

References attrDCBlocker, dcBlocker, and TTObject::set().

+ Here is the call graph for this function:

TTErr TTLimiter::setLookahead ( TTValue newValue)
protected

Setter for the lookahead attribute, value is in samples.

Definition at line 156 of file TTLimiter.cpp.

References attrLookahead, kTTErrNone, lookaheadInv, and maxBufferSize.

TTErr TTLimiter::setMode ( TTValue newValue)
protected

Setter for the mode attribute.

Definition at line 172 of file TTLimiter.cpp.

References attrMode, isLinear, kTTErrNone, and setRecover().

+ Here is the call graph for this function:

TTErr TTLimiter::setPostamp ( const TTValue value)
protected

Setter for the threshold attribute.

Definition at line 130 of file TTLimiter.cpp.

References attrPostamp, kTTErrNone, and TTDecibelsToLinearGain().

+ Here is the call graph for this function:

TTErr TTLimiter::setPreamp ( TTValue value)
protected

Setter for the threshold attribute.

Definition at line 119 of file TTLimiter.cpp.

References preamp, and TTObject::set().

+ Here is the call graph for this function:

void TTLimiter::setRecover ( )
protected

Private utility used by the audio processing routine.

Definition at line 213 of file TTLimiter.cpp.

References attrMode, attrRelease, and TTAudioObjectBase::sr.

Referenced by clear(), setMode(), setRelease(), and updateSampleRate().

TTErr TTLimiter::setRelease ( TTValue newValue)
protected

Setter for the release attribute.

Definition at line 164 of file TTLimiter.cpp.

References attrRelease, kTTErrNone, and setRecover().

+ Here is the call graph for this function:

TTErr TTLimiter::setThreshold ( const TTValue value)
protected

Setter for the threshold attribute.

Definition at line 143 of file TTLimiter.cpp.

References attrThreshold, kTTErrNone, and TTDecibelsToLinearGain().

+ Here is the call graph for this function:

TTErr TTLimiter::updateMaxNumChannels ( const TTValue oldMaxNumChannels,
TTValue  
)
protected

Override the setter for the inherited maxNumChannels attribute.

Definition at line 86 of file TTLimiter.cpp.

References clear(), dcBlocker, kTTErrNone, lookaheadBuffer, maxBufferSize, TTAudioObjectBase::mMaxNumChannels, preamp, and TTObject::set().

+ Here is the call graph for this function:

TTErr TTLimiter::updateSampleRate ( const TTValue oldSampleRate,
TTValue  
)
protected

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

Definition at line 112 of file TTLimiter.cpp.

References kTTErrNone, and setRecover().

+ Here is the call graph for this function:


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