debugger shows bpm beats k

This commit is contained in:
breel
2026-03-10 23:11:22 -06:00
parent e9cbb86735
commit c470f7ae40
3 changed files with 15 additions and 8 deletions

View File

@@ -5,14 +5,17 @@ use std::sync::Arc;
pub enum Syn {
Real(Synthesizer),
Text(std::collections::HashMap<i32, std::collections::HashMap<i32, i32>>),
Text{
m: std::collections::HashMap<i32, std::collections::HashMap<i32, i32>>,
i: u32,
},
}
impl Syn {
pub fn new(debug: bool, sound_font: String, sample_rate: usize) -> Syn {
match debug {
false => Syn::new_real(sound_font, sample_rate),
true => Syn::Text(std::collections::HashMap::new()),
true => Syn::Text{m: std::collections::HashMap::new(), i: 0},
}
}
@@ -29,7 +32,7 @@ impl Syn {
pub fn note_on(&mut self, a: i32, b: i32, c: i32) {
match self {
Syn::Real(syn) => syn.note_on(a, b, c),
Syn::Text(m) => {
Syn::Text{m, ..} => {
eprintln!("note_on({:?}, {:?}, {:?})", a, b, c);
match m.get_mut(&a) {
Some(m2) => { m2.insert(b, c); },
@@ -46,7 +49,7 @@ impl Syn {
pub fn note_off(&mut self, a: i32, b: i32) {
match self {
Syn::Real(syn) => syn.note_off(a, b),
Syn::Text(m) => {
Syn::Text{m, ..} => {
eprintln!("note_off({:?}, {:?})", a, b);
match m.get_mut(&a) {
Some(m) => { m.remove(&b); },
@@ -60,8 +63,9 @@ impl Syn {
pub fn render(&mut self, a: &mut [f32], b: &mut [f32]) {
match self {
Syn::Real(syn) => syn.render(a, b),
Syn::Text(m) => {
eprintln!("render({:?})", m)
Syn::Text{m, i} => {
eprintln!("render[{}]({:?})", i, m);
*i += 1;
},
};
}