AELimiter Class Reference

Limiter filter. More...

#import <AELimiter.h>

Inherits <NSObject>.

Instance Methods

(id) - initWithNumberOfChannels:sampleRate:
 Init.
 
(BOOL) - AELimiterEnqueue
 Enqueue audio.
 
(void) - AELimiterDequeue
 Dequeue audio.
 
(UInt32) - AELimiterFillCount
 Query the fill count of the limiter.
 
(void) - AELimiterDrain
 Dequeue all audio from the limiter, including those held back for the lookahead algorithm.
 
(void) - AELimiterReset
 Reset the buffer, clearing all enqueued audio.
 

Properties

UInt32 hold
 The hold interval, in frames.
 
UInt32 attack
 The attack duration, in frames.
 
UInt32 decay
 The decay duration, in frames.
 
float level
 The audio level limit.
 

Detailed Description

Limiter filter.

This class implements a lookahead audio limiter. Use it to smoothly limit output volume to a particular level.

The audio is delayed by the number of frames indicated by the attack property.

This class operates on non-interleaved floating point audio, as it is frequently used as part of larger audio processing operations. If your audio is not already in this format, you may wish to use it in conjunction with AEFloatConverter.

To use this as an AEAudioFilter, see the AELimiterFilter class.

Method Documentation

- (id) initWithNumberOfChannels: (int)  numberOfChannels
sampleRate: (Float32)  sampleRate 

Init.

Parameters
numberOfChannelsNumber of channels to use
sampleRateSample rate to use
- (BOOL) AELimiterEnqueue (AELimiter *)  limiter
(float **)  buffers
(UInt32)  length
(const AudioTimeStamp *)  timestamp 

Enqueue audio.

Add audio to be processed.

This C function is safe to be used in a Core Audio realtime thread.

Parameters
limiterA pointer to the limiter object.
buffersAn array of floating-point arrays containing noninterleaved audio to enqueue.
lengthThe length of the audio, in frames
timestampThe timestamp of the audio, or NULL
Returns
YES on success, NO on failure.
- (void) AELimiterDequeue (AELimiter *)  limiter
(float **)  buffers
(UInt32 *)  ioLength
(AudioTimeStamp *)  timestamp 

Dequeue audio.

Dequeue processed audio.

Note that the audio is delayed by the number of frames indicated by the attack property. If at the end of a processing operation you wish to dequeue all audio from the limiter, you should use AELimiterDrain.

This C function is safe to be used in a Core Audio realtime thread.

Parameters
limiterA pointer to the limiter object.
buffersAn array of floating-point arrays to store the dequeued noninterleaved audio.
ioLengthOn input, the length of the audio to dequeue, in frames; on output, the amount of audio dequeued.
timestampOn output, the timestamp of the next audio, if not NULL.
- (UInt32) AELimiterFillCount (AELimiter *)  limiter
(AudioTimeStamp *)  timestamp
(UInt32 *)  trueFillCount 

Query the fill count of the limiter.

Use this to determine how many frames can be dequeued.

Parameters
limiterA pointer to the limiter object.
timestampOn output, if not NULL, the timestamp of the next audio frames
trueFillCountOn output, if not NULL, the true fill count, including the attack frames held back for the lookahead algorithm.
Returns
The number of frames that can be dequeued
- (void) AELimiterDrain (AELimiter *)  limiter
(float **)  buffers
(UInt32 *)  ioLength
(AudioTimeStamp *)  timestamp 

Dequeue all audio from the limiter, including those held back for the lookahead algorithm.

During normal operation, the nmuber of frames given by the attack property are held back for the lookahead algorithm to function correctly. If you wish to finish audio processing and want to recover these frames, then you can use this function to do so. Note that the final frames may surpass the set level.

Parameters
limiterA pointer to the limiter object.
buffersAn array of floating-point arrays to store the dequeued noninterleaved audio.
ioLengthOn input, the length of the audio to dequeue, in frames; on output, the amount of audio dequeued.
timestampOn output, the timestamp of the next audio, if not NULL.
- (void) AELimiterReset (AELimiter *)  limiter

Reset the buffer, clearing all enqueued audio.

Parameters
limiterThe limiter object.

Property Documentation

- (UInt32) hold
readwritenonatomicassign

The hold interval, in frames.

This is the length of time the limiter will hold the gain, when it is in the active state.

Default: 22050 (0.5s at 44.1kHz)

- (UInt32) attack
readwritenonatomicassign

The attack duration, in frames.

This is the amount of time over which the limiter will smoothly activate when an audio level greater than the set limit is seen.

Note that the limiter will delay the audio by this duration.

Default: 2048 frames (~.046s at 44.1kHz)

- (UInt32) decay
readwritenonatomicassign

The decay duration, in frames.

This is the amount of time over which the limiter will smoothly deactivate, moving back to a 1.0 gain level, once the hold time expires.

Default: 44100 (1s at 44.1kHz)

- (float) level
readwritenonatomicassign

The audio level limit.

This is the audio level at which the limiter activates. The dequeued audio will not exceed this level, and will be smoothly gain-adjusted accordingly when a greater level is seen.

The value you provide here will depend on the original audio format you are working with. For example, if you are mixing a number of 16-bit signed integer streams, you may wish to use a limit value of INT16_MAX for the combined stream before converting back to 16-bit, to avoid clipping.

Default: INT16_MAX


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