#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. | |
#define AEDSPSilence AEAudioBufferListSilence |
Silence an audio buffer list (zero out frames)
bufferList | Pointer to an AudioBufferList containing audio |
offset | Offset into buffer |
length | Number of frames to silence (0 for whole buffer) |
void AEDSPApplyGain | ( | const AudioBufferList * | bufferList, |
float | gain, | ||
UInt32 | frames | ||
) |
Scale values in a buffer list by some gain value.
bufferList | Audio buffer list, in non-interleaved float format |
gain | Gain amount (power ratio) |
frames | Length of buffer in frames |
void AEDSPApplyRamp | ( | const AudioBufferList * | bufferList, |
float * | start, | ||
float | step, | ||
UInt32 | frames | ||
) |
Apply a ramp to values in a buffer list.
bufferList | Audio buffer list, in non-interleaved float format |
start | Starting gain (power ratio) on input; final gain value on output |
step | Amount per frame to advance gain |
frames | Length 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.
bufferList | Audio buffer list, in non-interleaved float format |
start | Starting gain (power ratio) on input; final gain value on output |
step | Amount per frame to advance gain |
frames | Length of buffer in frames |
scratch | A 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.
bufferList | Audio buffer list, in non-interleaved float format |
targetGain | Target gain amount (power ratio) |
currentGain | On input, current gain; on output, the new gain. Store this and pass it back to this function on successive calls for a smooth ramp |
frames | Length 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.
bufferList | Audio buffer list, in non-interleaved float format |
targetGain | Target gain amount (power ratio) |
currentGain | On input, current gain; on output, the new gain. Store this and pass it back to this function on successive calls for a smooth ramp |
frames | Length of buffer in frames |
rampDuration | Duration 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.
buffer | Float array |
targetGain | Target gain amount (power ratio) |
currentGain | On input, current gain; on output, the new gain |
frames | Length 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.
bufferList | Audio buffer list, in non-interleaved float format |
targetVolume | The target volume (power ratio) |
currentVolume | On 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. |
targetBalance | The target balance |
currentBalance | On 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. |
frames | Length 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.
bufferList1 | First buffer list, in non-interleaved float format |
bufferList2 | Second buffer list, in non-interleaved float format |
gain1 | Gain factor for first buffer list (power ratio) |
gain2 | Gain factor for second buffer list |
monoToStereo | Whether to double mono tracks to stereo, if output is stereo |
frames | Length of buffer in frames, or 0 for entire buffer (based on mDataByteSize fields) |
output | Output 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.
buffer1 | First buffer |
buffer2 | Second buffer |
gain1 | Gain factor for first buffer (power ratio) |
gain2 | Gain factor for second buffer |
frames | Number of frames |
output | Output buffer |