note struct
This commit is contained in:
@@ -2,6 +2,7 @@ use itertools::Itertools;
|
||||
|
||||
mod flags;
|
||||
mod syn;
|
||||
mod note;
|
||||
|
||||
fn main() {
|
||||
let flags = flags::Flags::new();
|
||||
@@ -12,7 +13,7 @@ fn main() {
|
||||
flags.sample_rate,
|
||||
);
|
||||
// Play some notes (middle C, E, G). // 16 channels actually // 60=c 64=e 67=g //up to 128velocity though dont go below 50 tbh // 12 notes per octave
|
||||
syn.note_on(0, 64 + 12, 127);
|
||||
syn.note_on(0, note::new("any").i32(), 127);
|
||||
|
||||
play(syn, flags.sample_rate, flags.bpm, flags.smallest_note);
|
||||
}
|
||||
|
||||
14
src/note.rs
Normal file
14
src/note.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
pub struct Note(String);
|
||||
|
||||
pub fn new<S: ToString>(s: S) -> Note {
|
||||
Note(s.to_string())
|
||||
}
|
||||
|
||||
impl Note {
|
||||
pub fn i32(&self) -> i32 {
|
||||
// 60 = middle c
|
||||
// 64 = middle e
|
||||
// 67 = middle g
|
||||
64 + 12
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user