Crates.io | rodio |
lib.rs | rodio |
version | 0.21.1 |
created_at | 2015-09-11 12:08:05.255656+00 |
updated_at | 2025-07-14 12:31:07.026512+00 |
description | Audio playback library |
homepage | |
repository | https://github.com/RustAudio/rodio |
max_upload_size | |
id | 3031 |
size | 572,382 |
Rust playback library.
Playback is handled by cpal. Format decoding is handled by Symphonia by default, or by optional format-specific decoders:
See the feature flags for more details on formats, and other features.
The documentation contains an introduction to the library.
We have written an upgrade guide. It will help you upgrade to rodio 0.21.
We are always making changes to rodio. This can mean that the examples do not work with the current crates.io release. You will have to look at the examples from commit f7aa48d
. They are available on github.
Rodio playback works in environments supported by cpal library.
The CPU of the target system should have hardware support for 32-bit floating point (f32
), and atomic operations that are at least 32 bit wide. Without these the CPU may not be fast enough to keep up with real-time.
Rodio uses cpal
library to send audio to the OS for playback. ALSA development files are needed to build cpal
on Linux. These are provided as part of the libasound2-dev
package on Debian and Ubuntu distributions and alsa-lib-devel
on Fedora.
It is possible to build rodio
without support for audio playback. In this configuration cpal
dependency and its requirements are excluded. This configuration may be useful, for example, for decoding and processing audio in environments when the audio output is not available (e.g. in case of Linux, when ALSA is not available). See into_file
example that works with this build.
In order to use rodio
in this configuration disable default features and add the necessary ones. In this case the Cargo.toml
dependency would look like:
[dependencies]
rodio = { version = "0.21.0", default-features = false, features = ["symphonia-all"] }
Through cpal rodio depends on the alsa library (libasound & libasound-dev), this can make crosscompiling hard. Cpal has some guides on crosscompling in their Readme (https://github.com/RustAudio/cpal). They are missing instructions on aarch64 (arm linux) so we have some here:
sudo apt-get install crossbuild-essential-arm64 clang
rustup target add aarch64-unknown-linux-gnu
sudo dpkg --add-architecture arm64
sudo apt install libasound2-dev:arm64
PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc" cargo build --target aarch64-unknown-linux-gnu
This will work for other Linux targets too if you change the architecture in the command and if there are multi-arch packages available.
You might want to look at cross if you are running on a non debian system or want to make this more repeatable.
We love it when people join making rodio better. There are many ways to help not matter how experienced you are with audio or Rust. We would especially love help with:
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.