text useful

This commit is contained in:
breel
2026-03-10 20:53:44 -06:00
parent 845b05d36e
commit e907fd0ada

View File

@@ -50,28 +50,47 @@ fn main() {
enum Syn { enum Syn {
Real(Synthesizer), Real(Synthesizer),
Text(std::collections::HashMap<i32, (i32, i32)>), Text(std::collections::HashMap<i32, std::collections::HashMap<i32, i32>>),
} }
impl Syn { impl Syn {
fn note_on(&mut self, a: i32, b: i32, c: i32) { fn note_on(&mut self, a: i32, b: i32, c: i32) {
match self { match self {
Syn::Real(syn) => syn.note_on(a, b, c), Syn::Real(syn) => syn.note_on(a, b, c),
Syn::Text(m) => eprintln!("note_on({:?}, {:?}, {:?})", a, b, c), Syn::Text(m) => {
eprintln!("note_on({:?}, {:?}, {:?})", a, b, c);
match m.get_mut(&a) {
Some(m2) => { m2.insert(b, c); },
None => {
let mut m2 = std::collections::HashMap::new();
m2.insert(b, c);
m.insert(a, m2);
},
};
},
}; };
} }
fn note_off(&mut self, a: i32, b: i32) { fn note_off(&mut self, a: i32, b: i32) {
match self { match self {
Syn::Real(syn) => syn.note_off(a, b), Syn::Real(syn) => syn.note_off(a, b),
Syn::Text(m) => eprintln!("note_off({:?}, {:?})", a, b), Syn::Text(m) => {
eprintln!("note_off({:?}, {:?})", a, b);
match m.get_mut(&a) {
Some(m) => { m.remove(&b); },
None => {},
};
},
}; };
} }
fn render(&mut self, a: &mut [f32], b: &mut [f32]) { fn render(&mut self, a: &mut [f32], b: &mut [f32]) {
match self { match self {
Syn::Real(syn) => syn.render(a, b), Syn::Real(syn) => syn.render(a, b),
Syn::Text(m) => eprintln!("render({:?})", m), Syn::Text(m) => {
eprintln!("render({:?})", m)
},
}; };
} }
} }