Another round of optimization

This commit is contained in:
2026-02-02 22:16:00 +01:00
parent 74fe999496
commit 4235862d86
7 changed files with 122 additions and 70 deletions

View File

@@ -281,6 +281,8 @@ pub fn build_stream(
let (mut fft_producer, analysis_handle) = spawn_analysis_thread(sample_rate, spectrum_buffer);
let mut cmd_buffer = String::with_capacity(256);
let stream = device
.build_output_stream(
&stream_config,
@@ -291,11 +293,16 @@ pub fn build_stream(
while let Ok(cmd) = audio_rx.try_recv() {
match cmd {
AudioCommand::Evaluate { cmd, time } => {
let cmd_with_time = match time {
Some(t) => format!("{cmd}/time/{t:.6}"),
None => cmd,
let cmd_ref = match time {
Some(t) => {
cmd_buffer.clear();
use std::fmt::Write;
let _ = write!(&mut cmd_buffer, "{cmd}/time/{t:.6}");
cmd_buffer.as_str()
}
None => &cmd,
};
engine.evaluate(&cmd_with_time);
engine.evaluate(cmd_ref);
}
AudioCommand::Hush => {
engine.hush();