andrewrk/libsoundio logo

andrewrk/libsoundio

Free

C library for cross-platform real-time audio input and output

FreeFree tier
Inputs: audioOutputs: audio
Type
Open Source
Company
andrewrk (Andrew Kelley)

About andrewrk/libsoundio

libsoundio is a C library that provides cross-platform real-time audio input and output. It abstracts over multiple audio backends including JACK, PulseAudio, ALSA, CoreAudio, and WASAPI, and supports Windows 7+, macOS 10.10+, and Linux 3.7+. The API is designed for both professional audio applications like digital audio workstations and consumer software such as music players. It exposes raw devices for low-latency performance and shared devices with sample rate and format conversion. The library also supports channel layouts for surround sound, device monitoring, backend disconnect events, and default device detection. It depends only on the respective backend libraries and libc, and communicates errors via return codes.

Key Features

Supports Windows 7+, macOS 10.10+, and Linux 3.7+
Backends: JACK, PulseAudio, ALSA, CoreAudio, WASAPI, Dummy (silence)
Exposes both raw devices (low-latency, exclusive) and shared devices (with conversion)
Provides device ID and friendly name for configuration and UI
Supports channel layouts (channel maps) for surround sound
Monitors devices and notifies on changes
Handles backend disconnect events (e.g., JACK or PulseAudio server shutdown)
Detects default input and output devices
Allows connecting to multiple backends simultaneously
Meticulously checks all return codes and memory allocations

Pros & Cons

Pros
  • Cross-platform (Windows, macOS, Linux) with unified API
  • Low-latency raw device mode for performance-critical applications
  • Minimal dependencies: only libc and backend libraries
  • Meticulous error handling with meaningful return codes
  • Supports advanced features like channel layouts and device monitoring
  • Free and open-source (MIT license)
Cons
  • C library, not suitable for developers who prefer higher-level languages without bindings
  • Abstraction may hide some backend-specific advanced features
  • Requires installing appropriate backend libraries on each platform
  • Documentation consists mainly of API headers and a single code example
  • No built-in support for audio encoding/decoding or file I/O

Best For

Digital audio workstations (DAWs)Consumer music playersSurround sound applicationsReal-time audio processing software

FAQ

What platforms does libsoundio support?
Windows 7+, macOS 10.10+, and Linux 3.7+.
Which audio backends are supported?
JACK, PulseAudio, ALSA, CoreAudio, WASAPI, and a Dummy (silence) backend.
What is the difference between raw and shared devices?
Raw devices provide the best performance and prevent other applications from using them. Shared devices are the default and usually provide sample rate and format conversion.
Does libsoundio depend on libstdc++?
No, it depends only on the respective backend API libraries and libc. It does not use exceptions, run-time type information, or setjmp.