Reference — AVFoundation audio APIs, AVAudioSession categories/modes, AVAudioEngine pipelines, bit-perfect DAC output, iOS 26+ spatial audio capture, ASAF/APAC, Audio Mix with Cinematic framework
View on GitHubSelect agents to install to:
npx add-skill https://github.com/CharlesWiltgen/Axiom/blob/main/.claude-plugin/plugins/axiom/skills/axiom-avfoundation-ref/SKILL.md -a claude-code --skill axiom-avfoundation-refInstallation paths:
.claude/skills/axiom-avfoundation-ref/# AVFoundation Audio Reference
## Quick Reference
```swift
// AUDIO SESSION SETUP
import AVFoundation
try AVAudioSession.sharedInstance().setCategory(
.playback, // or .playAndRecord, .ambient
mode: .default, // or .voiceChat, .measurement
options: [.mixWithOthers, .allowBluetooth]
)
try AVAudioSession.sharedInstance().setActive(true)
// AUDIO ENGINE PIPELINE
let engine = AVAudioEngine()
let player = AVAudioPlayerNode()
engine.attach(player)
engine.connect(player, to: engine.mainMixerNode, format: nil)
try engine.start()
player.scheduleFile(audioFile, at: nil)
player.play()
// INPUT PICKER (iOS 26+)
import AVKit
let picker = AVInputPickerInteraction()
picker.delegate = self
myButton.addInteraction(picker)
// In button action: picker.present()
// AIRPODS HIGH QUALITY (iOS 26+)
try AVAudioSession.sharedInstance().setCategory(
.playAndRecord,
options: [.bluetoothHighQualityRecording, .allowBluetoothA2DP]
)
```
---
## AVAudioSession
### Categories
| Category | Use Case | Silent Switch | Background |
|----------|----------|---------------|------------|
| `.ambient` | Game sounds, not primary | Silences | No |
| `.soloAmbient` | Default, interrupts others | Silences | No |
| `.playback` | Music player, podcast | Ignores | Yes |
| `.record` | Voice recorder | — | Yes |
| `.playAndRecord` | VoIP, voice chat | Ignores | Yes |
| `.multiRoute` | DJ apps, multiple outputs | Ignores | Yes |
### Modes
| Mode | Use Case |
|------|----------|
| `.default` | General audio |
| `.voiceChat` | VoIP, reduces echo |
| `.videoChat` | FaceTime-style |
| `.gameChat` | Voice chat in games |
| `.videoRecording` | Camera recording |
| `.measurement` | Flat response, no processing |
| `.moviePlayback` | Video playback |
| `.spokenAudio` | Podcasts, audiobooks |
### Options
```swift
// Mixing
.mixWithOthers // Play with other apps
.duckOthers // Lower other audio while playing
.interruptSp