this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

VQT fix

alice 3a0cbb3b 7a8f79de

+30 -5
+2 -2
tic80_rust/src/audio/vqt.rs
··· 32 32 pub vqt_sm: Vec<f32>, 33 33 pub vqt_norm: Vec<f32>, 34 34 // Peak normalization for raw path 35 - vqt_peak: f32, 35 + pub vqt_peak: f32, 36 36 37 37 // Whitened copies 38 38 pub vqt_w_raw: Vec<f32>, 39 39 pub vqt_w_sm: Vec<f32>, 40 40 pub vqt_w_norm: Vec<f32>, 41 41 // Peak normalization for whitened path 42 - vqt_w_peak: f32, 42 + pub vqt_w_peak: f32, 43 43 } 44 44 45 45 const VQT_BINS: usize = 120;
+3 -3
tic80_rust/src/script/lua_runner.rs
··· 231 231 let vqt_fn = lua.create_function(move |_, bin: i32| { 232 232 let val = if let Some(arc) = get_global_vqt() { 233 233 let guard = arc.read(); 234 - // Return normalized instantaneous; align with TIC: vqt returns normalized 234 + // normalized instantaneous (may exceed 1.0) 235 235 if bin >= 0 && (bin as usize) < guard.bins_count() { 236 - guard.vqt_norm[bin as usize] as f64 236 + (guard.vqt_raw[bin as usize] / guard.vqt_peak) as f64 237 237 } else { 238 238 0.0 239 239 } ··· 293 293 let val = if let Some(arc) = get_global_vqt() { 294 294 let guard = arc.read(); 295 295 if bin >= 0 && (bin as usize) < guard.bins_count() { 296 - guard.vqt_w_norm[bin as usize] as f64 296 + (guard.vqt_w_raw[bin as usize] / guard.vqt_w_peak) as f64 297 297 } else { 298 298 0.0 299 299 }
+25
tic80_rust/tests/vqt_tests.rs
··· 40 40 } 41 41 42 42 #[test] 43 + fn vqt_instantaneous_vs_smoothed_differs() { 44 + // Fresh state so smoothed = (1-a)*raw; normalized instantaneous should exceed smoothed normalized 45 + let cap = 8192; 46 + let sr = 44_100; 47 + let mut vqt = VQTState::new(sr, cap); 48 + let bin = 24usize; 49 + let f0 = vqt_center_freq(bin); 50 + let samples = gen_sine(f0, sr, 9000); 51 + for s in samples { 52 + vqt.ingest(s); 53 + } 54 + vqt.update(); 55 + let inst = vqt.vqt_raw[bin] / vqt.vqt_peak; 56 + let sm = vqt.vqt_norm[bin]; 57 + assert!( 58 + inst > 1.05, 59 + "instantaneous normalized should exceed 1.0 on first update" 60 + ); 61 + assert!( 62 + sm <= 1.0 + 1e-6, 63 + "smoothed normalized should be clamped to <= 1.0" 64 + ); 65 + } 66 + 67 + #[test] 43 68 fn lua_vqt_reads_bin() { 44 69 let cap = 8192; 45 70 let sr = 44_100;