cpal

Low-level, cross-platform audio I/O library for Rust with a unified API over ALSA, WASAPI, CoreAudio, JACK, and more.

Library
Cargo
v0.18.2
3,949 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
91 /100 Excellent
Development Activity 96
Maintenance 96
Community 72
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
75 /100 Good
Architecture 85
Code Quality 80
Innovation 72
Learning Curve 62

cpal is a low-level cross-platform audio input/output library for Rust, providing a single Host/Device/Stream API that abstracts over each platform’s native audio backend: ALSA, PulseAudio, PipeWire, and JACK on Linux; WASAPI and ASIO on Windows; CoreAudio on macOS/iOS; AAudio on Android; and the Web Audio API/AudioWorklet in WebAssembly. Applications enumerate available devices and their supported stream configurations, then open an input or output stream with a callback invoked on each buffer of audio samples.

As part of the RustAudio organization, cpal is the foundational audio I/O layer underneath much of the Rust audio ecosystem — used directly by synthesizers, DAWs, voice-processing tools, and games, and as the device-access layer beneath higher-level crates like rodio. With 16+ million cumulative downloads and a very active maintenance cadence, it is the standard choice whenever a Rust project needs to capture or play raw audio samples without depending on a single OS’s native API.

What You Get

  • A Host/Device/Stream trait hierarchy that abstracts over platform-specific audio backends behind one API
  • Device enumeration and supported stream configuration querying (sample rate, channel count, sample format)
  • Callback-based input and output streams that deliver/consume buffers of audio samples in real time
  • Optional backends behind Cargo features: ASIO (low-latency Windows), JACK, PipeWire, and an AudioWorklet backend for WebAssembly
  • A realtime feature for platform-specific real-time thread scheduling to reduce audio glitches/underruns
  • A custom feature for plugging in user-defined hosts, devices, and streams for testing or non-standard backends

Common Use Cases

  • Capturing microphone input for a voice-processing, transcription, or voice-chat application
  • Building a software synthesizer, DAW, or audio effect processor that needs low-latency playback
  • Recording audio to disk (e.g. WAV) from the system’s default or a specifically selected input device
  • Cross-compiling one audio codebase to Linux, Windows, macOS, Android, iOS, and WebAssembly targets

Under The Hood

Architecture — cpal’s public API (src/traits.rs, src/lib.rs) defines Host, Device, and Stream traits, with src/host/ containing one backend implementation per platform (alsa, pulseaudio, pipewire, jack, wasapi, asio, coreaudio, aaudio, webaudio, audioworklet, plus a null backend for headless/CI use), and src/platform/mod.rs selecting the appropriate backend set at compile time via cfg attributes. This lets application code write against the trait interface once while the correct OS-specific implementation is compiled in per target. Tech Stack — Rust 2021 edition (rust-version 1.85+); most backends bind to system libraries directly (ALSA via alsa-sys, ASIO via the companion asio-sys workspace crate, WASAPI/CoreAudio via OS-provided COM/Core Foundation bindings), with an audioworklet feature adding wasm-bindgen/web-sys for WebAssembly targets and a realtime feature adding audio_thread_priority for real-time thread scheduling. Code Quality — The crate maintains an examples/ directory covering desktop, Android, iOS, and WASM builds (beep.rs, record_wav.rs, feedback.rs, synth_tones.rs), a documented UPGRADING.md for breaking changes, and a maintenance = actively-developed badge backed by a very active commit and release cadence (health-score development-activity and maintenance-consistency both near maximum). API Design — The Host/Device/Stream/callback model is intentionally minimal and close to the underlying OS APIs it wraps, so switching between backends (e.g. ALSA to JACK) requires no application code changes beyond host selection, though understanding platform-specific audio concepts (buffer sizes, sample formats, real-time scheduling) is still necessary to use it effectively.

Used by 5 apps in this directory

TypeScript
64%
Other

Epicenter

Developer Tools · Knowledge Management · Note Taking

4,808

A local-first monorepo led by Whispering, an open-source speech-to-text app, built on an MIT toolkit that turns your data into plain Markdown and SQLite files you own instead of a database you rent.

View details
88
Repo Health
90
Technical
64
Dependency
Built with
TypeScript 64%
HTML 13%
Svelte 13%
Updated 5 days ago
Rust
59%
MIT

Handy

Productivity · Voice AI

32,320

Free, offline, open-source speech-to-text that pastes directly into any app on Windows, macOS, and Linux.

View details
87
Repo Health
78
Technical
72
Dependency
Built with
Rust 59%
TypeScript 30%
Updated 4 days ago
JavaScript
55%
Other

Lokus

Knowledge Management · Note Taking

802

Local-first note-taking with graph view, canvas & AI plugins—your Markdown files, zero telemetry, blazing-fast Rust performance.

View details
78
Repo Health
75
Technical
65
Dependency
Built with
JavaScript 55%
HTML 21%
Rust 12%
Updated 1 months ago
Rust
48%
MIT

Meetily

AI Assistants · Productivity

31,171

Privacy-first AI meeting assistant that transcribes and summarizes your meetings entirely on your local machine — no cloud, no data leakage.

View details
85
Repo Health
72
Technical
67
Dependency
Built with
Rust 48%
TypeScript 29%
Updated 2 weeks ago
TypeScript
53%
MIT

Voicebox

AI Development · Productivity · Voice AI

55,864

Clone voices, dictate anywhere, and give AI agents your voice — all locally.

View details
79
Repo Health
76
Technical
68
Dependency
Built with
TypeScript 53%
Python 35%
Updated 1 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers