drop velocity as yagni

This commit is contained in:
2026-03-11 09:29:19 -06:00
parent ff3911fee9
commit 0e4cfa8b30
2 changed files with 12 additions and 11 deletions

View File

@@ -31,16 +31,18 @@ impl Syn {
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 {
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, ..} => {
eprintln!("tone_on({:?}, {:?}, {:?})", a, b.i32(), c);
eprintln!("tone_on({:?}, {:?}, {:?})", a, b.i32(), 127);
match m.get_mut(&a) {
Some(m2) => { m2.insert(b.i32(), c); },
Some(m2) => { m2.insert(b.i32(), 127); },
None => {
let mut m2 = std::collections::HashMap::new();
m2.insert(b.i32(), c);
m2.insert(b.i32(), 127);
m.insert(a, m2);
},
};
@@ -81,8 +83,8 @@ mod test {
fn test_new_real() {
let mut syn = Syn::new(false, "super_small_font.sf2".to_string(), 44100);
syn.tone_on(1, tone::new("c"), 3);
syn.tone_on(2, tone::new("d"), 4);
syn.tone_on(1, tone::new("c"));
syn.tone_on(2, tone::new("d"));
syn.tone_off(2, tone::new("d"));
@@ -95,8 +97,8 @@ mod test {
fn test_text() {
let mut syn = Syn::new(true, ".sf2".to_string(), 1);
syn.tone_on(1, tone::new("c"), 3);
syn.tone_on(2, tone::new("d"), 4);
syn.tone_on(1, tone::new("c"));
syn.tone_on(2, tone::new("d"));
syn.tone_off(2, tone::new("d"));