Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
vyalovvldmr committed Jan 9, 2025
1 parent 2002f3d commit 38f532e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use tracing::{debug, error, info, level_filters::LevelFilter};
use tracing_subscriber::EnvFilter;

const INITIAL_LATENCY: std::time::Duration = std::time::Duration::from_millis(1000);
const BUFFER_SIZE: usize = 550;

#[derive(Parser, Debug)]
#[command(version, about = "sidetone", long_about = None)]
Expand Down Expand Up @@ -80,10 +81,9 @@ fn main() -> anyhow::Result<()> {
if input_config.sample_rate.0 != output_config.sample_rate.0 {
anyhow::bail!("The sampling frequency of the input device must be the same as the sampling frequency of the output device");
}
let latency_frames =
(INITIAL_LATENCY.as_millis() as f32 / 1_000.0) * input_config.sample_rate.0 as f32;
let latency_frames = (INITIAL_LATENCY.as_secs() as f32) * input_config.sample_rate.0 as f32;
let latency_samples = latency_frames as usize * input_config.channels as usize;
let (sender, receiver) = sync_channel(550);
let (sender, receiver) = sync_channel(BUFFER_SIZE);

for _ in 0..latency_samples {
sender.try_send(0.0).ok();
Expand Down

0 comments on commit 38f532e

Please sign in to comment.