Skip to content

Commit

Permalink
fs option
Browse files Browse the repository at this point in the history
  • Loading branch information
jordens committed Sep 21, 2023
1 parent 80ea5a6 commit 2782ec1
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ pub struct Opts {

#[arg(short, long, default_value = "mid")]
detrend: Detrend,

#[arg(short, long, default_value_t = 1.0f32)]
fs: f32,
}

fn main() -> Result<()> {
Expand All @@ -41,8 +44,11 @@ fn main() -> Result<()> {
source,
min_avg,
detrend,
fs,
} = Opts::parse();

let logfs = fs.log10();

let (cmd_send, cmd_recv) = mpsc::channel();
let (trace_send, trace_recv) = mpsc::sync_channel(1);
let receiver = std::thread::spawn(move || {
Expand Down Expand Up @@ -77,6 +83,7 @@ fn main() -> Result<()> {
}
i += 1;

// TODO sync with app update
if i > 200 {
i = 0;
let trace = dec
Expand All @@ -92,7 +99,12 @@ fn main() -> Result<()> {
psd: f[..f.len() - 1] // DC
.iter()
.zip(p.iter())
.map(|(f, p)| [f.log10() as f64, 10.0 * p.log10() as f64])
.map(|(f, p)| {
[
(f.log10() + logfs) as f64,
10.0 * (p.log10() - logfs) as f64,
]
})
.collect(),
})
}
Expand Down Expand Up @@ -204,8 +216,8 @@ impl eframe::App for FLS {
.and_then(|t| t.breaks.get(0))
.map(|bi| {
ui.label(format!(
"{:.2e} samples", // includes overlap
(bi.count * bi.effective_fft_size) as f32
"{:.2e} samples", // assume N/2 overlap
(bi.count * bi.effective_fft_size / 2) as f32
))
});
});
Expand Down

0 comments on commit 2782ec1

Please sign in to comment.