1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*!
# RS-AUDIO
rs-audio is a Rust library for making retro music programmatically.<br>
Currently, it has support for:
* Sine waves,
* Squares,
* Sawtooths,
* and Triangles.<br>
This library is MIT licensed. <br>Learn more in our repository: <https://github.com/xshotss/rs-audio/blob/main/LICENSE><br><br>
## Usage:<br>
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.
```
<br>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.<br>
So some documentation may not be precise enough or just bad. Please report bad documentation to the GitHub repository.
*/
pub use Note;
pub use ;
pub use cpal;
pub use WaveForm;
pub use *;
/**
The BPMChoice is an enum for picking the <b>beats per minute</b> for making songs.<br>
Usage:
```
use rs_audio::*;
let 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);
```
*/