Another round of optimization
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user