Euphorium
Painless audio playback for native and web platforms.
A small Rust audio player built on top of rodio and CPAL.
Installation
Usage
use ;
// Define your application's sound keys in one place...
sound_key!
Browsers require audio output to be opened in response to a user gesture. Start playback from a click, pointer, or keyboard event when possible.
Please find these examples for more guidance.
Feature flags
| Feature | Enables |
|---|---|
cli (default) |
euphorium <PATH> |
mp3 (default) |
MP3 decoding |
flac |
FLAC decoding |
mp4 |
MP4 decoding |
vorbis |
Vorbis decoding |
wav (default) |
WAV decoding |
asio |
ASIO backend |
jack |
JACK backend |
nightly |
AudioWorklet backend |
Motivation
rodio and CPAL are both great libraries, but they are not very ergonomic to use. Here are some issues that I have encountered while using them:
- There is no Null backend, so you must forever live with
Option<MixerDeviceSink>. rodio::Player::try_seekdeadlocks on WASM and some specific threading setups.- rodio seems to prioritize correctness, which is fine, but you end up needing to wrap a lot of code yourself to get predictable behavior e.g. setting time position or playback speed when no audio is playing.
- rodio does not officially support AudioWorklet while CPAL does.
- No convenience code in rodio for native and web audio resource handling, causing a ton of
#[cfg(target_arch = "wasm32")]. - Concurrent playback requires callers to own and synchronize a collection of players.
- No Rayon support.
- No waveform visualization.
License
Dual-licensed under the MIT License and the Apache License, Version 2.0. Choose whichever you prefer. This license only applies to Euphorium code.
By submitting a contribution, including code submitted through a pull request, you agree that your contribution will be dual-licensed under the MIT License and the Apache License, Version 2.0, without any additional terms or conditions.