feat: add sound notification #6

Merged
Stevan merged 8 commits from stevanfreeborn/feat/add-sound-notification into main 2026-07-28 22:39:01 +00:00
Showing only changes of commit b456397c30 - Show all commits
+16 -2
View File
@@ -248,14 +248,28 @@ impl AudioVisualizer {
thread::sleep(std::time::Duration::from_millis(16)); thread::sleep(std::time::Duration::from_millis(16));
let samples = { let samples = {
let buf = match audio_buffer.lock() { let mut buf = match audio_buffer.lock() {
Ok(b) => b, Ok(b) => b,
Err(_) => continue, Err(_) => continue,
}; };
// decay heights smoothly
if buf.len() < chunk_size { if buf.len() < chunk_size {
for val in prev_heights.iter_mut() {
*val = (*val - falloff).max(0.0);
}
if let Ok(mut bars) = bar_data.lock() {
for (i, val) in prev_heights.iter().enumerate() {
bars[i] = ((*val * 10.0).clamp(0.0, 100.0)) as u64;
}
}
continue; continue;
} }
buf[buf.len() - chunk_size..].to_vec()
// drain the consumed samples
buf.drain(0..chunk_size).collect::<Vec<f32>>()
}; };
Self::apply_hann_window(&samples, &mut windowed_buffer); Self::apply_hann_window(&samples, &mut windowed_buffer);