raplay

Crates.ioraplay
lib.rsraplay
version0.3.5
sourcesrc
created_at2023-07-30 18:11:30.407593
updated_at2024-09-02 14:16:42.906614
descriptionLibrary for playing audio
homepagehttps://github.com/BonnyAD9/raplay
repositoryhttps://github.com/BonnyAD9/raplay
max_upload_size
id930146
size107,196
Jakub Antonín Štigler (BonnyAD9)

documentation

README

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

Links

Commit count: 64

cargo fmt