Skip to main content

Module signal_processing

Module signal_processing 

Source
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 f64 real 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§

WindowType
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 x with y (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 n sampled at fs Hz.
fft_inplace
In-place Cooley-Tukey FFT. n must 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 n with shape parameter beta.
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_in to fs_out using 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.