Skip to main content

numra_signal/
lib.rs

1//! # Numra Signal Processing
2//!
3//! Digital signal processing tools for Numra: IIR/FIR filter design and
4//! application, resampling, Hilbert transform, and peak detection.
5//!
6//! ## Modules
7//!
8//! - [`filter_design`] — Butterworth and Chebyshev Type I IIR filter design
9//! - [`filter_apply`] — SOS filter application (`sosfilt`, `filtfilt`)
10//! - [`fir`] — FIR filter design via windowed sinc
11//! - [`mod@resample`] — FFT-based signal resampling
12//! - [`mod@hilbert`] — Hilbert transform, envelope, instantaneous frequency
13//! - [`peak`] — Peak detection with height/distance/prominence constraints
14//!
15//! ## Example
16//!
17//! ```rust
18//! use numra_signal::{butter, filtfilt, find_peaks, PeakOptions};
19//!
20//! // Design a 4th-order Butterworth lowpass at 10 Hz, sampled at 100 Hz
21//! let sos = butter(4, 10.0, 100.0).unwrap();
22//!
23//! // Generate a noisy signal
24//! let pi2 = 2.0 * std::f64::consts::PI;
25//! let x: Vec<f64> = (0..200).map(|i| {
26//!     let t = i as f64 / 100.0;
27//!     (pi2 * 3.0 * t).sin() + 0.3 * (pi2 * 40.0 * t).sin()
28//! }).collect();
29//!
30//! // Filter the signal (zero-phase)
31//! let y = filtfilt(&sos, &x);
32//!
33//! // Find peaks in the filtered signal
34//! let peaks = find_peaks(&y, &PeakOptions::default().height(0.5));
35//! assert!(!peaks.is_empty());
36//! ```
37//!
38//! Author: Moussa Leblouba
39//! Date: 9 February 2026
40//! Modified: 2 May 2026
41
42#![allow(clippy::needless_range_loop)]
43#![allow(clippy::excessive_precision)]
44
45pub mod error;
46pub mod filter_apply;
47pub mod filter_design;
48pub mod fir;
49pub mod hilbert;
50pub mod peak;
51pub mod resample;
52
53pub use error::SignalError;
54pub use filter_apply::{filtfilt, sosfilt, SosFilter};
55pub use filter_design::{butter, cheby1};
56pub use fir::{fir_filter, firwin};
57pub use hilbert::{envelope, hilbert, instantaneous_frequency};
58pub use peak::{find_peaks, PeakOptions};
59pub use resample::resample;