#audio #sound #effects #sfx #rusty

rusty_audio

Convenient sound library for small projects and educational purposes

9 stable releases

1.2.1 Mar 15, 2021
1.2.0 Mar 8, 2021
1.1.5 Feb 27, 2021
1.1.4 Mar 25, 2020
1.1.0 Oct 10, 2019

#59 in Audio

Download history 85/week @ 2021-07-06 67/week @ 2021-07-13 61/week @ 2021-07-20 98/week @ 2021-07-27 108/week @ 2021-08-03 81/week @ 2021-08-10 45/week @ 2021-08-17 72/week @ 2021-08-24 27/week @ 2021-08-31 57/week @ 2021-09-07 41/week @ 2021-09-14 46/week @ 2021-09-21 22/week @ 2021-09-28 39/week @ 2021-10-05 49/week @ 2021-10-12 173/week @ 2021-10-19

283 downloads per month
Used in 2 crates

MIT/Apache

46KB
88 lines

Crates.io Version Crates.io Downloads Build Status

Rusty Audio Playback Library

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.

  • Formats: MP3, WAV, Vorbis and Flac.
  • Platforms: Supports macOS, Windows, and iOS out of the box. Linux requires installation of extra dependencies.

This library uses the rodio audio playback library under the hood, which you should consider using directly if your needs are more complex.

Example

# Add this to your [dependencies] section in Cargo.toml
rusty_audio = "1.2.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
}

Built-in Example

You can run the built-in example by cloning this repository, and then running:

$ cargo run --example play

Dependencies on Linux

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

Contribution

All contributions are assumed to be dual-licensed under MIT/Apache-2.

License

Distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See license/APACHE and license/MIT.

Sponsor

If you like Rusty Audio, please consider sponsoring me on GitHub. 💖

Dependencies

~8–11MB
~87K SLoC