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();