summaryrefslogtreecommitdiff
path: root/src/retain.rs
diff options
context:
space:
mode:
authorozpv <39195175+ozpv@users.noreply.github.com>2026-05-17 21:12:15 -0500
committerGitHub <noreply@github.com>2026-05-17 21:12:15 -0500
commitbc9ad151dbf478cdb39040524a50c9d901ef018b (patch)
treedc201f1813d0c6bbe7894f2816973a60896ba5c9 /src/retain.rs
parent6686b6765992f86c208949925c1c3c09cbb31353 (diff)
Add Blackman-Harris window
Diffstat (limited to 'src/retain.rs')
-rw-r--r--src/retain.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/retain.rs b/src/retain.rs
index 49730e1..8c4c8eb 100644
--- a/src/retain.rs
+++ b/src/retain.rs
@@ -2,26 +2,26 @@ use num_complex::Complex;
use rustc_hash::FxHashSet;
#[inline(always)]
-pub fn retain_top_n_magnitudes(fft_real_signal: &mut [Complex<f32>], n: usize) {
+pub fn retain_top_n_magnitudes(spectrum: &mut [Complex<f32>], n: usize) {
// you'd be keeping the entire signal
// or keeping nothing at all
- if n >= fft_real_signal.len() {
+ if n >= spectrum.len() {
return;
} else if n == 0 {
- for phasor in fft_real_signal {
+ for phasor in spectrum {
*phasor = Complex::ZERO;
}
return;
}
- let mut indexed = fft_real_signal
+ let mut indexed = spectrum
.iter()
.copied()
.enumerate()
.collect::<Vec<(usize, Complex<f32>)>>();
- let target = fft_real_signal.len() - n;
+ let target = spectrum.len() - n;
indexed.select_nth_unstable_by(target, |(_, c0), (_, c1)| c0.norm().total_cmp(&c1.norm()));
let top_indices = indexed[target..]
@@ -29,7 +29,7 @@ pub fn retain_top_n_magnitudes(fft_real_signal: &mut [Complex<f32>], n: usize) {
.map(|&(i, _)| i)
.collect::<FxHashSet<usize>>();
- for (i, phasor) in fft_real_signal.iter_mut().enumerate() {
+ for (i, phasor) in spectrum.iter_mut().enumerate() {
if !top_indices.contains(&i) {
*phasor = Complex::ZERO;
}