AEDSPUtilities.h File Reference
#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import "AEAudioBufferListUtilities.h"

Go to the source code of this file.

Macros

#define AEDSPSilence   AEAudioBufferListSilence
 Silence an audio buffer list (zero out frames)
 

Functions

void AEDSPApplyGain (const AudioBufferList *bufferList, float gain, UInt32 frames)
 Scale values in a buffer list by some gain value.
 
void AEDSPApplyRamp (const AudioBufferList *bufferList, float *start, float step, UInt32 frames)
 Apply a ramp to values in a buffer list.
 
void AEDSPApplyEqualPowerRamp (const AudioBufferList *bufferList, float *start, float step, UInt32 frames, float *scratch)
 Apply an equal-power ramp to values in a buffer list.
 
void AEDSPApplyGainSmoothed (const AudioBufferList *bufferList, float targetGain, float *currentGain, UInt32 frames)
 Scale values in a buffer list by some gain value, with smoothing to avoid discontinuities.
 
void AEDSPApplyGainWithRamp (const AudioBufferList *bufferList, float targetGain, float *currentGain, UInt32 frames, UInt32 rampDuration)
 Scale values in a buffer list by some gain value, with smoothing to avoid discontinuities.
 
void AEDSPApplyGainSmoothedMono (float *buffer, float targetGain, float *currentGain, UInt32 frames)
 Scale values in a single buffer by some gain value, with smoothing to avoid discontinuities.
 
void AEDSPApplyVolumeAndBalance (const AudioBufferList *bufferList, float targetVolume, float *currentVolume, float targetBalance, float *currentBalance, UInt32 frames)
 Apply volume and balance controls to the buffer.
 
void AEDSPMix (const AudioBufferList *bufferList1, const AudioBufferList *bufferList2, float gain1, float gain2, BOOL monoToStereo, UInt32 frames, const AudioBufferList *output)
 Mix two buffer lists.
 
void AEDSPMixMono (const float *buffer1, const float *buffer2, float gain1, float gain2, UInt32 frames, float *output)
 Mix two single mono buffers.
 

Macro Definition Documentation

#define AEDSPSilence   AEAudioBufferListSilence

Silence an audio buffer list (zero out frames)

Parameters
bufferListPointer to an AudioBufferList containing audio
offsetOffset into buffer
lengthNumber of frames to silence (0 for whole buffer)

Function Documentation

void AEDSPApplyGain ( const AudioBufferList *  bufferList,
float  gain,
UInt32  frames 
)

Scale values in a buffer list by some gain value.

Parameters
bufferListAudio buffer list, in non-interleaved float format
gainGain amount (power ratio)
framesLength of buffer in frames
void AEDSPApplyRamp ( const AudioBufferList *  bufferList,
float *  start,
float  step,
UInt32  frames 
)

Apply a ramp to values in a buffer list.

Parameters
bufferListAudio buffer list, in non-interleaved float format
startStarting gain (power ratio) on input; final gain value on output
stepAmount per frame to advance gain
framesLength of buffer in frames
void AEDSPApplyEqualPowerRamp ( const AudioBufferList *  bufferList,
float *  start,
float  step,
UInt32  frames,
float *  scratch 
)

Apply an equal-power ramp to values in a buffer list.

This uses a quarter-cycle cosine ramp envelope to preserve the power level, useful when crossfading two signals without causing a bump in gain in the middle of the fade.

Parameters
bufferListAudio buffer list, in non-interleaved float format
startStarting gain (power ratio) on input; final gain value on output
stepAmount per frame to advance gain
framesLength of buffer in frames
scratchA scratch buffer to use, or NULL to use an internal buffer. Not thread-safe if the latter is used.
void AEDSPApplyGainSmoothed ( const AudioBufferList *  bufferList,
float  targetGain,
float *  currentGain,
UInt32  frames 
)

Scale values in a buffer list by some gain value, with smoothing to avoid discontinuities.

Parameters
bufferListAudio buffer list, in non-interleaved float format
targetGainTarget gain amount (power ratio)
currentGainOn input, current gain; on output, the new gain. Store this and pass it back to this function on successive calls for a smooth ramp
framesLength of buffer in frames
void AEDSPApplyGainWithRamp ( const AudioBufferList *  bufferList,
float  targetGain,
float *  currentGain,
UInt32  frames,
UInt32  rampDuration 
)

Scale values in a buffer list by some gain value, with smoothing to avoid discontinuities.

Parameters
bufferListAudio buffer list, in non-interleaved float format
targetGainTarget gain amount (power ratio)
currentGainOn input, current gain; on output, the new gain. Store this and pass it back to this function on successive calls for a smooth ramp
framesLength of buffer in frames
rampDurationDuration of full 0.0-1.0/1.0-0.0 transition, in frames
void AEDSPApplyGainSmoothedMono ( float *  buffer,
float  targetGain,
float *  currentGain,
UInt32  frames 
)

Scale values in a single buffer by some gain value, with smoothing to avoid discontinuities.

Parameters
bufferFloat array
targetGainTarget gain amount (power ratio)
currentGainOn input, current gain; on output, the new gain
framesLength of buffer in frames
void AEDSPApplyVolumeAndBalance ( const AudioBufferList *  bufferList,
float  targetVolume,
float *  currentVolume,
float  targetBalance,
float *  currentBalance,
UInt32  frames 
)

Apply volume and balance controls to the buffer.

This function applies gains to the given buffer to affect volume and balance, with a smoothing ramp applied to avoid discontinuities.

Parameters
bufferListAudio buffer list, in non-interleaved float format
targetVolumeThe target volume (power ratio)
currentVolumeOn input, the current volume; on output, the new volume. Store this and pass it back to this function on successive calls for a smooth ramp. If NULL, no smoothing will be applied.
targetBalanceThe target balance
currentBalanceOn input, the current balance; on output, the new balance. Store this and pass it back to this function on successive calls for a smooth ramp. If NULL, no smoothing will be applied.
framesLength of buffer in frames
void AEDSPMix ( const AudioBufferList *  bufferList1,
const AudioBufferList *  bufferList2,
float  gain1,
float  gain2,
BOOL  monoToStereo,
UInt32  frames,
const AudioBufferList *  output 
)

Mix two buffer lists.

Combines values in each buffer list, after scaling by given factors. If monoToStereo is YES, then if a buffer is mono, and the output is stereo, the buffer will have its channels doubled If the output is mono, any buffers with more channels will have these mixed down into the mono output.

This method assumes the number of frames in each buffer is the same.

Note that input buffer contents may be modified during this operation.

Parameters
bufferList1First buffer list, in non-interleaved float format
bufferList2Second buffer list, in non-interleaved float format
gain1Gain factor for first buffer list (power ratio)
gain2Gain factor for second buffer list
monoToStereoWhether to double mono tracks to stereo, if output is stereo
framesLength of buffer in frames, or 0 for entire buffer (based on mDataByteSize fields)
outputOutput buffer list (may be same as bufferList1 or bufferList2)
void AEDSPMixMono ( const float *  buffer1,
const float *  buffer2,
float  gain1,
float  gain2,
UInt32  frames,
float *  output 
)

Mix two single mono buffers.

Parameters
buffer1First buffer
buffer2Second buffer
gain1Gain factor for first buffer (power ratio)
gain2Gain factor for second buffer
framesNumber of frames
outputOutput buffer