Crates.io | rusty_audio |
lib.rs | rusty_audio |
version | 1.4.1 |
source | src |
created_at | 2019-10-10 19:42:27.497704 |
updated_at | 2023-04-10 17:55:50.974489 |
description | Convenient sound library for small projects and educational purposes. |
homepage | https://github.com/cleancut/rusty_engine/tree/master/rusty_audio |
repository | https://github.com/cleancut/rusty_engine/tree/master/rusty_audio |
max_upload_size | |
id | 171512 |
size | 70,623 |
rusty_audio
is a fun and easy audio playback library that provides a 4-track audio system to
load/decode audio files and play them, perfect for small projects. It is also well-suited for
training purposes, and is featured in the Ultimate Rust Crash Course on Udemy.
This library uses the rodio audio playback library under the hood, which you should consider using directly if your needs are more complex.
# Add this to your [dependencies] section in Cargo.toml
rusty_audio = "1.4.1"
// main.rs
use rusty_audio::Audio;
fn main() {
let mut audio = Audio::new();
audio.add("startup", "my_sound_file.mp3"); // Load the sound, give it a name
audio.play("startup"); // Execution continues while playback occurs in another thread.
audio.wait(); // Block until sounds finish playing
}
You can run the built-in example by cloning this repository, and then running:
$ cargo run --example play
For Linux, the CPAL package that is used under the hood requires the alsa development libraries to be installed.
CentOS
sudo yum install -y alsa-lib-devel
Debian/Ubuntu
sudo apt install libasound2-dev
All contributions are assumed to be dual-licensed under MIT/Apache-2.
Distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See license/APACHE and license/MIT.
If you like Rusty Audio, please consider sponsoring me on GitHub. 💖