Expand description
Signal processing: FFT, windowing, filtering, spectral analysis, wavelets.
Provides Cooley-Tukey FFT/IFFT, windowing functions (Hann/Hamming/Blackman/Kaiser), PSD estimation (Welch/Bartlett), FIR/IIR filter design (Butterworth/Chebyshev/elliptic), convolution, correlation, Hilbert transform, spectrogram, and wavelet transforms.
Structs§
- Biquad
- A single biquad (second-order) IIR section.
- Complex64
- A complex number with
f64real and imaginary parts. - FirFilter
- FIR filter coefficients computed via the window method.
- IirFilter
- A cascade of biquad sections forming an IIR filter.
- PsdResult
- PSD estimation result containing frequency bins and power values.
- Spectrogram
- Spectrogram result: time bins, frequency bins, and STFT magnitude matrix.
Enums§
- Window
Type - The type of window function to apply.
Functions§
- analytic_
signal - Compute the analytic signal (x + j*H{x}) using FFT.
- apply_
window - Apply a window to a signal in-place.
- auto_
correlate - Auto-correlation of
x. - bartlett_
psd - Bartlett’s method for PSD estimation (non-overlapping segments).
- bartlett_
window - Compute the Bartlett (triangular) window of length
n. - bessel_
i0 - Modified Bessel function of the first kind, order zero (I₀). Used for Kaiser window computation.
- blackman_
harris_ window - Compute the Blackman-Harris window of length
n. - blackman_
window - Compute the Blackman window of length
n. - butterworth_
lowpass - Butterworth low-pass filter design (bilinear transform, biquad cascade).
- chebyshev1_
lowpass - Chebyshev Type I low-pass filter (biquad cascade).
- complex_
cepstrum - Compute the complex cepstrum of a signal.
- convolve
- Linear convolution of two real signals via FFT (overlap-add style).
- cross_
correlate - Cross-correlation of
xwithy(i.e. sum_t x[t] * y[t+lag]). - db2_
decompose - Daubechies-4 (db2) single-level forward DWT.
- db2_
reconstruct - Daubechies-4 (db2) single-level inverse DWT.
- downsample
- Downsample a signal by integer factor
down(decimate, no anti-aliasing). - fft
- Compute FFT of a real-valued signal. Pads to the next power of two if needed.
- fft_
frequencies - Return the frequency bins (in Hz) for an FFT of length
nsampled atfsHz. - fft_
inplace - In-place Cooley-Tukey FFT.
nmust be a power of two. - find_
peaks - Detect local maxima in a signal.
- find_
peaks_ above - Detect peaks above a threshold.
- flat_
top_ window - Compute the flat-top window of length
n. - generate_
chirp - Generate a test chirp (frequency sweep) signal.
- generate_
sine - Generate a test sinusoidal signal.
- generate_
white_ noise - Generate white Gaussian noise (Box-Muller transform).
- group_
delay - Compute group delay from the phase response.
- haar_
decompose - Haar wavelet decomposition (one level).
- haar_
dwt - Multi-level Haar DWT.
- haar_
idwt - Multi-level Haar inverse DWT.
- haar_
reconstruct - Haar wavelet reconstruction (one level).
- hamming_
window - Compute the Hamming window of length
n. - hann_
window - Compute the Hann window of length
n. - hilbert_
transform - Compute the Hilbert transform of a real signal.
- ifft_
inplace - In-place inverse FFT (IFFT).
- ifft_
real - Compute IFFT and return the real part of each element.
- iir_
magnitude_ response - Compute the magnitude response of a cascade of biquads at frequency
f(normalised 0..1). - instantaneous_
amplitude - Compute the instantaneous amplitude (envelope) of a signal.
- instantaneous_
frequency - Compute the instantaneous frequency (Hz) given sample rate
fs. - instantaneous_
phase - Compute the instantaneous phase of a signal (radians).
- istft
- Inverse STFT using overlap-add.
- kaiser_
window - Compute the Kaiser window of length
nwith shape parameterbeta. - magnitude_
spectrum - Compute the magnitude spectrum (|X[k]|) from a real signal.
- moving_
average - Compute the moving average of a signal.
- moving_
rms - Compute the moving RMS of a signal.
- normalize_
energy - Normalize a signal to unit energy.
- normalize_
peak - Normalize a signal to unit peak amplitude.
- normalized_
cross_ correlation - Normalized cross-correlation coefficient at each lag.
- nuttall_
window - Compute the Nuttall window of length
n. - periodogram_
psd - Simple periodogram PSD estimate.
- phase_
spectrum - Compute the phase spectrum (arg(X[k])) from a real signal.
- power_
spectrum - Compute the power spectrum (|X[k]|^2) from a real signal.
- real_
cepstrum - Compute the real cepstrum of a signal.
- resample
- Resample a signal from sample rate
fs_intofs_outusing rational resampling. - resample_
linear - Linear interpolation resampling.
- rfft_
frequencies - Return only the positive-frequency bins (0 to fs/2).
- rms
- Compute the RMS value of a signal.
- signal_
energy - Compute the energy of a signal.
- signal_
mean - Compute the mean of a signal.
- signal_
variance - Compute the variance of a signal.
- snr_db
- Compute the SNR (signal-to-noise ratio) in dB given signal and noise power.
- spectrogram
- Compute a short-time Fourier transform (STFT) spectrogram.
- stft
- Short-time Fourier transform: returns complex coefficients [frame][freq_bin].
- total_
harmonic_ distortion - Compute the THD (total harmonic distortion) from a power spectrum.
- unwrap_
phase - Unwrap phase (correct for 2π discontinuities).
- upsample
- Upsample a signal by integer factor
up(insert zeros between samples). - welch_
psd - Welch’s method for PSD estimation.
- window_
coherent_ gain - Compute the coherent gain of a window (mean).
- window_
power_ gain - Compute the power gain of a window (mean of squares).
- windowed
- Apply a window and return the windowed signal.
- zero_
pad - Zero-pad a signal to length
n.