iOS
On iOS the AudioEngine
class manages the shared AVAudioSession
instance. Controlling the same AVAudioSession
instance from multiple places can lead to strange audio problems, so when there is an active AudioEngine
instance (one that is running), please avoid calling any AVAudioSession
methods that change its state.
Microphone Access
If your app requires access to the microphone and you want to start receiving the microphone audio stream, you can set the microphoneEnabled
flag to true. This reconfigures the audio engine and activates the microphone input.
We recommend disabling the microphoneEnabled
flag when your app does not need to receive the microphone audio stream.
Voice Processing
Setting the voiceProcessingEnabled
flag activates Apple's built-in voice processing feature. This applies echo cancellation and automatic gain control on the microphone input. Using voice processing comes with the following caveats:
- Only mono audio output signal is supported.
- Applies various filters on the output signal.
- User won't be able to set the volume to zero.
Mixing Audio with Other Apps
By default the audio output of multiple audio apps' are non mixable. If you want to allow other apps to play audio while your app is used, you can set the mixWithOthers
flag to true.
Bluetooth Modes
The two Bluetooth modes that iOS supports are: A2DP and HFP. A2DP is uni-directional and transfers a high-quality audio stream with up to 2 channels. HFP supports two streams of audio (microphone + audio output) but with lower sample rate (typically below 24 kHz) and it is mono only.
When microphone access is not requested Bluetooth is enabled by default and A2DP is used. In this case no configuration is needed, using HFP is not possible.
When microphone access is requested, both A2DP or HFP can be used. The default is HFP, but A2DP can be enabled by setting the allowBluetoothA2DP
flag. Since A2DP cannot handle two streams, the device's built-in microphone is used and there is no way to read the headset's microphone.