Expand description
§RS-AUDIO
rs-audio is a Rust library for making retro music programmatically.
Currently, it has support for:
- Sine waves,
- Squares,
- Sawtooths,
- and Triangles.
This library is MIT licensed.
Learn more in our repository: https://github.com/xshotss/rs-audio/blob/main/LICENSE
§Usage:
To create a default song (to make sure everything is working):
use rs_audio::*;
let mut audio_manager = AudioManager::new(); // This creates an audio thread which handles audio.
audio_manager.play(Song::default()); // Plays a default song.
To create custom notes:
use rs_audio::*;
let mut audio_manager = AudioManager::new();
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);
let _ = audio_manager.play(song);
/* The play function returns a track ID.
If you want to control the track later, store its ID by changing the _ to the variable name that you want. */§NOTE
This priject has recently moved to a new version. Due to drastic changes, I have started rewriting all documentation.
So some documentation may not be precise enough or just bad. Please report bad documentation to the GitHub repository.
Re-exports§
pub use note::Note;pub use player::AudioManager;pub use player::Song;pub use waveform::WaveForm;pub use rodio::cpal;pub use BPMChoice::*;
Modules§
Enums§
- BPMChoice
- The BPMChoice is an enum for picking the beats per minute for making songs.
Usage: