From 0c1867e1e682f1eca164c6676cc0eb0ef4c2e695 Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Tue, 24 Jun 2025 10:01:40 +0200 Subject: First run of claude fixes --- Cargo.lock | 19 +++++++++++++++++++ Cargo.toml | 2 +- src/decoder.rs | 21 ++++++++++++--------- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1d103ee..8403606 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,6 +80,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f" dependencies = [ "clap_builder", + "clap_derive", ] [[package]] @@ -94,6 +95,18 @@ dependencies = [ "strsim", ] +[[package]] +name = "clap_derive" +version = "4.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2c7947ae4cc3d851207c1adb5b5e260ff0cca11446b1d6d1423788e442257ce" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "clap_lex" version = "0.7.5" @@ -142,6 +155,12 @@ dependencies = [ "log", ] +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hound" version = "3.5.1" diff --git a/Cargo.toml b/Cargo.toml index eaaba43..afccce5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ edition = "2024" [dependencies] anyhow = "1.0.98" -clap = "4.5.40" +clap = { version = "4.5.40", features = ["derive"] } env_logger = "0.11.8" hound = "3.5.1" log = "0.4.27" diff --git a/src/decoder.rs b/src/decoder.rs index 657bff7..c98ae71 100644 --- a/src/decoder.rs +++ b/src/decoder.rs @@ -3,15 +3,15 @@ // a Goertzel filter for tone extraction, and the core decoding logic. use anyhow::{Result, bail}; -use collections::VecDeque; -use rubato::{InterpolationParameters, InterpolationType, Resampler, SincFixedIn, WindowFunction}; -use rustfft::{Fft, FftPlanner, num_complex::Complex}; -use std::sync::Arc; +use rubato::{ + Resampler, SincFixedIn, SincInterpolationParameters, SincInterpolationType, WindowFunction, +}; +use rustfft::{FftPlanner, num_complex::Complex}; +use std::collections::VecDeque; // --- DSP Constants (ported from ggmorse) --- const FREQ_MIN_HZ: f32 = 200.0; const FREQ_MAX_HZ: f32 = 1200.0; -const HISTORY_S: f32 = 3.0; // How many seconds of audio to keep for analysis // --- Biquad Filter (Corrected Implementation) --- #[derive(Debug, Clone, Copy)] @@ -156,10 +156,10 @@ pub struct MorseDecoder { impl MorseDecoder { pub fn new(source_sample_rate: u32, target_sample_rate: u32) -> Result { let resampler = if source_sample_rate != target_sample_rate { - let params = InterpolationParameters { + let params = SincInterpolationParameters { sinc_len: 256, f_cutoff: 0.95, - interpolation: InterpolationType::Linear, + interpolation: SincInterpolationType::Linear, oversampling_factor: 256, window: WindowFunction::BlackmanHarris, }; @@ -175,9 +175,12 @@ impl MorseDecoder { SincFixedIn::new( 1.0, 1.0, - InterpolationParameters { + SincInterpolationParameters { sinc_len: 2, - ..Default::default() + f_cutoff: 0.95, + interpolation: SincInterpolationType::Linear, + oversampling_factor: 256, + window: WindowFunction::BlackmanHarris, }, 1024, 1, -- cgit v1.3.1