15 releases

Uses new Rust 2024

0.4.2 May 6, 2025
0.4.1 Mar 18, 2025
0.3.5 Sep 2, 2024
0.3.4 Sep 22, 2023
0.1.2 Jul 30, 2023

#156 in Audio

Download history 15/week @ 2025-02-14 2/week @ 2025-02-21 6/week @ 2025-02-28 1/week @ 2025-03-07 202/week @ 2025-03-14 43/week @ 2025-03-21 1/week @ 2025-03-28 3/week @ 2025-04-04 5/week @ 2025-04-11 106/week @ 2025-05-02 61/week @ 2025-05-09 8/week @ 2025-05-16

78 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::Sine};

let mut sink = Sink::default(); // Get the default output
let src = Sine::new(1000.); // Create 1000Hz sine source
sink.load(Box::new(src), true)?; // Play the sine wave
# Ok::<(), raplay::Error>(())

Play a mp3 file

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

let mut sink = Sink::default(); // Get the default output
let file = File::open("music.mp3").unwrap(); // Open the mp3 file
let src = Symph::try_new(file, &Default::default())?; // Create a symphonia
                                                      // decoder source
sink.load(Box::new(src), true); // Play the mp3 file
# Ok::<(), raplay::Error>(())

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–37MB
~552K SLoC