summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2025-06-24 10:01:40 +0200
committerYuval Adam <_@yuv.al>2025-06-24 10:01:40 +0200
commit0c1867e1e682f1eca164c6676cc0eb0ef4c2e695 (patch)
tree2b0deb7ad4c7d349c4eddd52dfc63ba6e4abafe2
parent4e091086d6eb934f66cc8e4610f899e1806c1bac (diff)
First run of claude fixes
-rw-r--r--Cargo.lock19
-rw-r--r--Cargo.toml2
-rw-r--r--src/decoder.rs21
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]]
@@ -95,6 +96,18 @@ dependencies = [
]
[[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"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -143,6 +156,12 @@ dependencies = [
]
[[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"
source = "registry+https://github.com/rust-lang/crates.io-index"
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<Self> {
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,