14 releases

Uses new Rust 2024

0.4.1 Mar 18, 2025
0.4.0 Mar 16, 2025
0.3.5 Sep 2, 2024
0.3.4 Sep 22, 2023
0.1.2 Jul 30, 2023

#185 in Audio

Download history 1/week @ 2025-01-07 1/week @ 2025-01-28 10/week @ 2025-02-04 16/week @ 2025-02-11 1/week @ 2025-02-18 5/week @ 2025-02-25 3/week @ 2025-03-04 110/week @ 2025-03-11 125/week @ 2025-03-18 11/week @ 2025-03-25 3/week @ 2025-04-01

249 downloads per month

GPL-3.0 license

83KB
2K SLoC

raplay

Library for playing audio.

The library is very new and not much tested.

Features

  • Play(Resume)/Pause
  • Callback when audio ends
  • Callback for errors
  • Volume
  • Seeking
  • Get audio position and length
  • Fade-in/fade-out on play/pause

Supported formats

All the decoding is done by symphonia, so the supported formats are the same as symphonia.

Examples

Play a sine wave

use raplay::{Sink, source::SineSource};

let sink = Sink::default(); // get the default output
let src = SineSource::new(1000.); // create 1000Hz sine source
sink.load(src, true)?; // play the sine wave

Play a mp3 file

use std::fs::File;
use raplay::{Sink, source::Symph};

let sink = Sink::default(); // get the default output
let file = File::open("music.mp3")?; // open the mp3 file
let src = Symph::try_new(file, &Default::default())?; // create a symphonia decoder source
sink.load(src, true)?; // play the mp3 file

Known issues

  • If the device doesn't support the required sample rate, aliasing may occur

How to get it

It is available on crates.io

Dependencies

~5–36MB
~545K SLoC