Crate rs_audio

Source
Expand description
  • rs-audio is a Rust library for making retro music programmatically.
    Currently, it has support for:
    Sine waves,
    Squares,
    Sawtooths,
    and Triangles.

§Usage:

To create a default song (to make sure everything is working):

use rs_audio::*;

let mut song = Song::default();
song.play().unwrap();


To create custom notes:

use rs_audio::*;

let mut song = Song::new(vec![
Note { freq: 880.0, dur: 1.0, vol: 0.20, wave: WaveForm::Sine },
Note { freq: 220.0, dur: 1.0, vol: 0.20, wave: WaveForm::Square },
Note { freq: 880.0, dur: 1.0, vol: 0.20, wave: WaveForm::Sine },
Note { freq: 220.0, dur: 1.0, vol: 0.20, wave: WaveForm::Triangle },
], BPMChoice::Default);

song.play().unwrap();

§Multithreading

To use a separate thread for playing songs, you need to use the following function.
Multithreading means that you can perform other tasks while playing music.

§Usage

use rs_audio::*;

let mut song = Song::default();
song.play_from_thread().unwrap();

Re-exports§

pub use note::Note;
pub use player::BPMChoice;
pub use player::Song;
pub use waveform::WaveForm;

Modules§

note
player
wav
waveform