AEIOAudioUnit Class Reference

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)
 

Detailed Description

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.

Method Documentation

- (BOOL) setup: (NSError *__autoreleasing _Nullable *_Nullable)  error

Setup the audio unit.

Call this after configuring the instance to initialize it, prior to calling start:.

Parameters
errorIf an error occured and this is not nil, it will be set to the error on output
Returns
YES on success, NO on failure
- (BOOL) start: (NSError *__autoreleasing _Nullable *_Nullable)  error

Start the audio unit.

Parameters
errorIf an error occured and this is not nil, it will be set to the error on output
Returns
YES on success, NO on failure
- (void) stop

Stop the audio unit.

- (AudioUnit _Nullable) AEIOAudioUnitGetAudioUnit (__unsafe_unretained AEIOAudioUnit *_Nonnull)  unit

Get access to audio unit.

Available for realtime thread usage

Parameters
unitThe unit instance
Returns
The audio unit
- (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.

Parameters
unitThe unit instance
bufferThe audio buffer list
framesNumber 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.

Parameters
unitThe unit instance
Returns
The most recent audio timestamp
- (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

Parameters
unitThe unit instance
Returns
The current sample rate
- (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.

Parameters
unitThe unit instance
Returns
The current input latency
- (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.

Parameters
unitThe unit instance
Returns
The current output latency

Property Documentation

- (AudioUnit _Nullable) audioUnit
readnonatomicassign

The audio unit. Will be NULL until setup: is called.

- (double) sampleRate
readwritenonatomicassign

The sample rate at which to run, or zero to track the hardware sample rate.

- (double) currentSampleRate
readnonatomicassign

The current sample rate in use.

- (BOOL) running
readnonatomicassign

Whether unit is currently active.

- (BOOL) outputEnabled
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.

- (AEIOAudioUnitRenderBlock _Nullable) renderBlock
readwritenonatomiccopy

The block to call when rendering output. May be changed at any time.

- (int) numberOfOutputChannels
readnonatomicassign

The current number of output channels.

- (BOOL) inputEnabled
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.

- (double) inputGain
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.

- (int) maximumInputChannels
readwritenonatomicassign

The maximum number of input channels to support, or zero for unlimited.

- (int) numberOfInputChannels
readnonatomicassign

The current number of input channels in use.

- (AESeconds) IOBufferDuration
readwritenonatomicassign

The IO buffer duration. On iOS, this is fetched from AVAudioSession; on the Mac, this is taken from HAL

- (BOOL) latencyCompensation
readwritenonatomicassign

Whether to automatically perform latency compensation (default YES)


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