Search guides and the APICtrl K
  1. API reference
  2. System, devices and network

audio_ios.h

Audio in and out on iOS and iPadOS, through RemoteIO.

#include <sonore/audio_ios.h>
On this page

Design notes

iOS has one audio unit that is the hardware: RemoteIO, whose bus 0 plays and whose bus 1 records. It runs under the app's AVAudioSession, which says what kind of audio app this is (playback, or play-and-record), asks for a rate and a buffer, and is where the system says the route changed or a phone call took the audio away. The two classes here are the standalone's PlatformAudio and PlatformAudioInput on iOS, the same surface every other backend offers (scripts/backend-surface.mjs checks it), over ONE RemoteIO unit both share (RemoteIo below) -- an app with two would have two clocks.

What iOS does differently:

  • No device list. The route is the system's: the speaker, headphones, a USB or Lightning interface, AirPods. RemoteIO follows it by itself.
  • The rate is the session's. 48 kHz is asked for and usually given; the DSP is prepared at whatever came. The buffer asked for is 5 ms.
  • Recording needs the user's permission and a usage string in the app's Info.plist (NSMicrophoneUsageDescription; sonore_add_standalone writes one). The input opens only when RemoteIo was opened with it, which the app does once the permission is granted.
  • An interruption -- a call, an alarm, Siri -- stops the unit. When it ends the session is made active again and the unit restarted. Media services being reset (rare, and drastic) is reported as a lost device, so the app reopens everything.

Written against the Objective-C runtime for the session and the C AudioComponent API for the unit, like every Apple file here.

Types 3

The one RemoteIO unit, its render callback, and the session around it. Opened by IosAudioOutput; IosAudioInput reads what its bus 1 records.

The system output on iOS: RemoteIO's bus 0.

The system input on iOS: what RemoteIO's bus 1 records, into a ring.

Functions 11

Aliases 1

Enums 1

Constants 4

↑↓ to move↵ to openEvery public name in the headers, and every guide