Audio unit interface. More...
#import <AEIOAudioUnit.h>
Inherits NSObject.
Instance Methods | |
(BOOL) | - setup: |
Setup the audio unit. | |
(BOOL) | - start: |
Start the audio unit. | |
(void) | - stop |
Stop the audio unit. | |
(AudioUnit _Nullable) | - AEIOAudioUnitGetAudioUnit |
Get access to audio unit. | |
(OSStatus) | - AEIOAudioUnitRenderInput |
Render the input. | |
(AudioTimeStamp) | - AEIOAudioUnitGetInputTimestamp |
Get the last received input timestamp. | |
(double) | - AEIOAudioUnitGetSampleRate |
Get the current sample rate. | |
(AESeconds) | - AEIOAudioUnitGetInputLatency |
Get the input latency. | |
(AESeconds) | - AEIOAudioUnitGetOutputLatency |
Get the output latency. | |
Properties | |
AudioUnit _Nullable | audioUnit |
The audio unit. Will be NULL until setup: is called. | |
double | sampleRate |
The sample rate at which to run, or zero to track the hardware sample rate. | |
double | currentSampleRate |
The current sample rate in use. | |
BOOL | running |
Whether unit is currently active. | |
BOOL | outputEnabled |
AEIOAudioUnitRenderBlock _Nullable | renderBlock |
The block to call when rendering output. May be changed at any time. | |
int | numberOfOutputChannels |
The current number of output channels. | |
BOOL | inputEnabled |
double | inputGain |
int | maximumInputChannels |
The maximum number of input channels to support, or zero for unlimited. | |
int | numberOfInputChannels |
The current number of input channels in use. | |
AESeconds | IOBufferDuration |
BOOL | latencyCompensation |
Whether to automatically perform latency compensation (default YES) | |
Audio unit interface.
This class manages an input/output/input-output audio unit. To use it, create an instance, set the properties, then call setup: to initialize, and start: to begin processing.
Typically, you do not use this class directly; instead, use AEAudioUnitOutput and/or AEAudioUnitInputModule to provide an interface with the audio hardware.
Important note: an audio unit with both input and output enabled is only possible on iOS. On the Mac, you must create two separate audio units.
- (BOOL) setup: | (NSError *__autoreleasing _Nullable *_Nullable) | error |
Setup the audio unit.
Call this after configuring the instance to initialize it, prior to calling start:.
error | If an error occured and this is not nil, it will be set to the error on output |
- (BOOL) start: | (NSError *__autoreleasing _Nullable *_Nullable) | error |
Start the audio unit.
error | If an error occured and this is not nil, it will be set to the error on output |
- (void) stop |
Stop the audio unit.
- (AudioUnit _Nullable) AEIOAudioUnitGetAudioUnit | (__unsafe_unretained AEIOAudioUnit *_Nonnull) | unit |
Get access to audio unit.
Available for realtime thread usage
unit | The unit instance |
- (OSStatus) AEIOAudioUnitRenderInput | (__unsafe_unretained AEIOAudioUnit *_Nonnull) | unit | |
(const AudioBufferList *_Nonnull) | buffer | ||
(UInt32) | frames | ||
Render the input.
For use with input-enabled instance, this fills the provided AudioBufferList with audio from the input.
unit | The unit instance |
buffer | The audio buffer list |
frames | Number of frames |
- (AudioTimeStamp) AEIOAudioUnitGetInputTimestamp | (__unsafe_unretained AEIOAudioUnit *_Nonnull) | unit |
Get the last received input timestamp.
For use with input-enabled instances, this gives access to the most recent AudioTimeStamp associated with input audio. Use this to perform synchronization.
unit | The unit instance |
- (double) AEIOAudioUnitGetSampleRate | (__unsafe_unretained AEIOAudioUnit *_Nonnull) | unit |
Get the current sample rate.
The sample rate is normally obtained from the current render context, but this function allows access when the render context is not available
unit | The unit instance |
- (AESeconds) AEIOAudioUnitGetInputLatency | (__unsafe_unretained AEIOAudioUnit *_Nonnull) | unit |
Get the input latency.
This function returns the hardware input latency, in seconds. If you have disabled latency compensation, and timing is important in your app, then you should factor this value into your timing calculations.
unit | The unit instance |
- (AESeconds) AEIOAudioUnitGetOutputLatency | (__unsafe_unretained AEIOAudioUnit *_Nonnull) | unit |
Get the output latency.
This function returns the hardware output latency, in seconds. If you have disabled latency compensation, and timing is important in your app, then you should factor this value into your timing calculations.
unit | The unit instance |
|
readnonatomicassign |
The audio unit. Will be NULL until setup: is called.
|
readwritenonatomicassign |
The sample rate at which to run, or zero to track the hardware sample rate.
|
readnonatomicassign |
The current sample rate in use.
|
readnonatomicassign |
Whether unit is currently active.
|
readwritenonatomicassign |
Whether output is enabled. Note that changing this value will cause the audio unit to be uninitialized, reconfigured, and initialized again, temporarily interrupting audio rendering.
|
readwritenonatomiccopy |
The block to call when rendering output. May be changed at any time.
|
readnonatomicassign |
The current number of output channels.
|
readwritenonatomicassign |
Whether input is enabled. Note that changing this value will cause the audio unit to be uninitialized, reconfigured, and initialized again, temporarily interrupting audio rendering.
|
readwritenonatomicassign |
The microphone gain, as power ratio. If the current audio session permits, this will be applied using AVAudioSession's gain controls. Otherwise, it will be applied by affecting the input signal directly.
|
readwritenonatomicassign |
The maximum number of input channels to support, or zero for unlimited.
|
readnonatomicassign |
The current number of input channels in use.
|
readwritenonatomicassign |
The IO buffer duration. On iOS, this is fetched from AVAudioSession; on the Mac, this is taken from HAL
|
readwritenonatomicassign |
Whether to automatically perform latency compensation (default YES)