18.2 · The audio session, interruptions, routes and AVAudioEngine
On iOS, audio is a shared resource with rules. The session tells the system what your app is doing with sound, and the system answers with who gets to play, who is silenced and where it goes.
Mental model. Declare intent (the category), listen for interruptions and route changes, and build processing graphs only when you need them.
Sharing the speaker
Audio session categories, interruptions and route changes.
- What is the AVAudioSession, how do categories and modes decide behaviour, and how do you handle interruptions and route changes?
The audio session (AVAudioSession.sharedInstance()) is your app’s contract with the system about audio. Its category declares intent and decides defaults…
Processing sound
AVAudioEngine graphs, formats and buffers.
- How does AVAudioEngine work: nodes, formats, buffers, and when do you use it instead of AVAudioPlayer?
Use AVAudioPlayer to play a file with minimal code, and AVAudioEngine when you need a processing graph: mixing several sources, effects (reverb, EQ, delay…
More in Media & graphics
- 18.1 · AVPlayer, time, and editing with compositions
- 18.3 · AVCaptureSession, and zero-copy pixel buffers
- 18.4 · HLS, buffering, Now Playing, remote commands, Picture in Picture and AirPlay
- 18.5 · ImageIO formats, Core Image, Metal, and SceneKit versus RealityKit
- 18.6 · VideoToolbox, tvOS focus and media, and building a playback platform
- 18.7 · Thumbnails and orientation, GIF timing, bitmap layout, and colour spaces
- 18.8 · Extents, working colour space, and a compute pass from start to finish
- 18.9 · Reading an asset, grabbing frames, reading samples, frame-exact time, and pixel buffers