# rustaudio/cpal

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/rustaudio-cpal).**

3,551 stars · 477 forks · Rust · apache-2.0

## Links

- GitHub: https://github.com/RustAudio/cpal
- awesome-repositories: https://awesome-repositories.com/repository/rustaudio-cpal.md

## Topics

`audio` `rust` `sound`

## Description

cpal is a low-level Rust audio hardware abstraction layer and cross-platform API. It serves as a unified interface for managing audio input and output streams across Windows, macOS, and Linux hardware, acting as a device driver wrapper to discover audio hosts and configure hardware devices.

The project functions as a real-time audio streamer, utilizing a high-priority callback system to stream audio samples to hardware devices with minimal latency.

The library covers audio hardware integration, including the discovery and configuration of sample rates and channel counts. It supports audio input capture and cross-platform playback, providing tools for digital signal processing workflows through audio sample format conversion.

## Tags

### Graphics & Multimedia

- [Cross-Platform Audio APIs](https://awesome-repositories.com/f/graphics-multimedia/audio-music/audio-streaming-engines/audio-playback-engines/cross-platform-audio-apis.md) — Provides a unified cross-platform API for managing audio input and output streams across Windows, macOS, and Linux.
- [Audio Input Capture](https://awesome-repositories.com/f/graphics-multimedia/audio-input-capture.md) — Enables recording raw audio data from microphones or other input hardware.
- [Sample-Based Buffer Callbacks](https://awesome-repositories.com/f/graphics-multimedia/audio-music/audio-processing/asynchronous-callbacks/sample-based-buffer-callbacks.md) — Implements a requested-buffer callback mechanism to feed raw PCM samples to hardware backends.
- [Real-Time Audio Threading](https://awesome-repositories.com/f/graphics-multimedia/audio-music/audio-processing/real-time-audio-threading.md) — Requests elevated execution priority for audio threads to minimize playback latency and glitches.
- [Callback-Driven Streaming](https://awesome-repositories.com/f/graphics-multimedia/audio-music/audio-processing/real-time-audio-threading/callback-driven-streaming.md) — Utilizes a high-priority callback system to stream audio samples to hardware with minimal latency.
- [Cross-Platform Audio Engines](https://awesome-repositories.com/f/graphics-multimedia/audio-music/audio-streaming-engines/audio-playback-engines/cross-platform-audio-engines.md) — Implements a consistent cross-platform engine for streaming and playing audio across different OS hardware.
- [Raw Audio Sample Streaming](https://awesome-repositories.com/f/graphics-multimedia/audio-music/audio-streaming-engines/raw-audio-sample-streaming.md) — Opens a non-blocking flow of raw PCM float samples to audio backends via high-priority callbacks. ([source](https://docs.rs/cpal/))
- [Real-Time Audio Processing](https://awesome-repositories.com/f/graphics-multimedia/real-time-audio-processing.md) — Provides a high-priority callback system for low-latency audio stream processing suitable for professional software and synthesizers.
- [Audio Playback](https://awesome-repositories.com/f/graphics-multimedia/audio-music/audio-playback.md) — Offers controls to start, pause, or stop the flow of audio data to hardware. ([source](https://docs.rs/cpal))
- [Audio Signal Processing Workflows](https://awesome-repositories.com/f/graphics-multimedia/audio-signal-processing-workflows.md) — Manages the workflow of converting audio sample formats and data streams to prepare sound for playback.
- [Sample Format Conversion](https://awesome-repositories.com/f/graphics-multimedia/sample-format-conversion.md) — Provides tools for changing sample width and channel counts of audio segments to ensure hardware compatibility.

### Operating Systems & Systems Programming

- [Audio Hardware Management](https://awesome-repositories.com/f/operating-systems-systems-programming/audio-hardware-management.md) — Provides a low-level abstraction layer for configuring and managing audio device settings across different operating systems. ([source](https://docs.rs/cpal/))
- [Hardware Abstraction Layers](https://awesome-repositories.com/f/operating-systems-systems-programming/hardware-interfacing-drivers/hardware-abstraction-layers.md) — Acts as a low-level hardware abstraction layer providing a consistent API for interacting with diverse audio drivers.
- [Audio Device Enumerators](https://awesome-repositories.com/f/operating-systems-systems-programming/hardware-interfacing-drivers/hardware-acceleration/device-selection/audio-device-enumerators.md) — Provides utilities for discovering and listing available audio hardware endpoints for system-wide routing. ([source](https://cdn.jsdelivr.net/gh/rustaudio/cpal@master/README.md))
- [Hardware Configurations](https://awesome-repositories.com/f/operating-systems-systems-programming/hardware-interfacing-drivers/hardware-acceleration/device-selection/audio-device-enumerators/hardware-configurations.md) — Implements tools to discover audio hosts and configure hardware sample rates and channel counts.

### Artificial Intelligence & ML

- [Audio Hardware Interfaces](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-optimization-and-inference/hardware-and-acceleration/hardware-abstraction-layers/audio-hardware-interfaces.md) — Provides a low-level framework for managing audio hardware, sound cards, and driver interfaces. ([source](https://cdn.jsdelivr.net/gh/rustaudio/cpal@master/README.md))

### Hardware & IoT

- [Hardware Device Discovery](https://awesome-repositories.com/f/hardware-iot/hardware-device-discovery.md) — Queries system APIs to enumerate available audio hardware devices and their supported configurations.

### Networking & Communication

- [Audio Stream Property Controls](https://awesome-repositories.com/f/networking-communication/audio-management-systems/audio-stream-property-controls.md) — Allows defining sample rates and channel counts to ensure compatibility with hardware before streaming. ([source](https://docs.rs/cpal/))

### Software Engineering & Architecture

- [Hardware Backend Abstractions](https://awesome-repositories.com/f/software-engineering-architecture/trait-based-service-abstractions/hardware-backend-abstractions.md) — Provides a unified trait-based interface to target different operating system sound servers.
- [Non-blocking IO Architectures](https://awesome-repositories.com/f/software-engineering-architecture/non-blocking-io-architectures.md) — Handles audio playback and capture in separate threads to prevent blocking the main application loop.

### Part of an Awesome List

- [Media & Communication](https://awesome-repositories.com/f/awesome-lists/media/media-communication.md) — Low-level cross-platform audio I/O library.
