Swift access to the Core Audio Hardware Abstraction Layer on macOS: audio devices, their
properties, and property-change notifications. Devices are Sendable and the manager is an actor,
with async reads and writes.
- List all devices, or filter by input, output, aggregate, Bluetooth, or matched input/output pairs
- Get and set the default input, output and system output devices
- List the devices another process is using
- Read and write device properties: name, UID, transport type, sample rate, volume (scalar and dB), balance, mute, channel counts and names, stream formats, latency, safety offset, buffer size, clock source, hog mode
- Change sample rate and wait for the device to confirm it (
SampleRateState) - Create and remove aggregate devices
- Hardware, device and stream property changes posted to
NotificationCenterasAudioHardwareNotification,AudioDeviceNotificationandAudioStreamNotification
let hardware = AudioHardwareManager.shared
try await hardware.start()
let outputs = try await hardware.outputDevices()
let device = await hardware.defaultOutputDevice
try await device?.sampleRateUpdater.updateAndWait(sampleRate: 48000)for await note in NotificationCenter.default.notifications(named: .deviceListChanged) {
guard case let .deviceListChanged(_, event) = note.object as? AudioHardwareNotification else { continue }
print(event.addedDevices, event.removedDevices)
}- Call
start()before use. Nothing is observed until it has been called; calling it again is harmless. - The manager's device list is a cache updated from HAL notifications and can lag the hardware.
AudioDevice.lookup(uid:)queries the HAL directly. setNominalSampleRatereturns before the rate has changed. UsesampleRateUpdaterto wait for it.- Notifications are posted on the main actor.
MIT. Derived from SimplyCoreAudio by Ruben Nine.
Spongefork is the personal software projects of musician and developer Ryan Francesconi. Dedicated to creative sound manipulation, his first application, Spongefork, was released in 1999 for macOS 8. From 2026, Spongefork returns as his software container for more musical experimentation. In addition to software releases, open source components can be found on his GitHub page.