Compare commits

..

2 Commits

Author SHA1 Message Date
852648f5bc time for sequencer! MULTIPLE NOTES! 2026-03-11 09:30:01 -06:00
0e4cfa8b30 drop velocity as yagni 2026-03-11 09:29:19 -06:00
2 changed files with 12 additions and 11 deletions

View File

@@ -12,8 +12,7 @@ fn main() {
flags.sound_font, flags.sound_font,
flags.sample_rate, flags.sample_rate,
); );
// Play some tones (middle C, E, G). // 16 channels actually // 60=c 64=e 67=g //up to 128velocity though dont go below 50 tbh // 12 tones per octave syn.tone_on(0, tone::new("c+5"));
syn.tone_on(0, tone::new("c+5"), 127);
play(syn, flags.sample_rate, flags.bpm, flags.smallest_note); play(syn, flags.sample_rate, flags.bpm, flags.smallest_note);
} }

View File

@@ -31,16 +31,18 @@ impl Syn {
Syn::Real(synthesizer) Syn::Real(synthesizer)
} }
pub fn tone_on(&mut self, a: i32, b: tone::Tone, c: i32) { pub fn tone_on(&mut self, a: i32, b: tone::Tone) {
match self { match self {
Syn::Real(syn) => syn.note_on(a, b.i32(), c), // channel=[0..16)
// velocity=[0..128)
Syn::Real(syn) => syn.note_on(a, b.i32(), 127),
Syn::Text{m, ..} => { Syn::Text{m, ..} => {
eprintln!("tone_on({:?}, {:?}, {:?})", a, b.i32(), c); eprintln!("tone_on({:?}, {:?}, {:?})", a, b.i32(), 127);
match m.get_mut(&a) { match m.get_mut(&a) {
Some(m2) => { m2.insert(b.i32(), c); }, Some(m2) => { m2.insert(b.i32(), 127); },
None => { None => {
let mut m2 = std::collections::HashMap::new(); let mut m2 = std::collections::HashMap::new();
m2.insert(b.i32(), c); m2.insert(b.i32(), 127);
m.insert(a, m2); m.insert(a, m2);
}, },
}; };
@@ -81,8 +83,8 @@ mod test {
fn test_new_real() { fn test_new_real() {
let mut syn = Syn::new(false, "super_small_font.sf2".to_string(), 44100); let mut syn = Syn::new(false, "super_small_font.sf2".to_string(), 44100);
syn.tone_on(1, tone::new("c"), 3); syn.tone_on(1, tone::new("c"));
syn.tone_on(2, tone::new("d"), 4); syn.tone_on(2, tone::new("d"));
syn.tone_off(2, tone::new("d")); syn.tone_off(2, tone::new("d"));
@@ -95,8 +97,8 @@ mod test {
fn test_text() { fn test_text() {
let mut syn = Syn::new(true, ".sf2".to_string(), 1); let mut syn = Syn::new(true, ".sf2".to_string(), 1);
syn.tone_on(1, tone::new("c"), 3); syn.tone_on(1, tone::new("c"));
syn.tone_on(2, tone::new("d"), 4); syn.tone_on(2, tone::new("d"));
syn.tone_off(2, tone::new("d")); syn.tone_off(2, tone::new("d"));