Skip to main content

Crate secs_dsp

Crate secs_dsp 

Source
Expand description

f64 DSP primitives and optimizers with SciPy/NumPy semantics.

Shared by secs-engine, secs-mdat (response caches), secs-camilla (FIR resampling) and secs-audio (sweep deconvolution). Functions match the NumPy/SciPy calls SECS 2 makes, including the details a port must keep (docs/ARCHITECTURE.md, “Numerics”):

  • FFT through cached realfft plans; pairwise summation where NumPy sums.
  • RBJ biquads, analog LR/BW prototypes, all-pass, minimum phase (cepstrum), fractional-octave smoothing, group delay, butter/sosfilt/firwin, find_peaks with the plateau-midpoint rule.
  • least_squares (bounded TRF, exact trust-region solver, two-point Jacobians; max_nfev counts residual calls only), ported from SciPy 1.18.1 by way of Impulcifer’s optimize.rs (MIT).
  • Differential evolution uses legacy RandomState (MT19937) with SciPy’s immediate best1bin draw order and Latin-hypercube initialization.
  • Rounding is half-to-even (f64::round_ties_even) wherever NumPy rounds.

There is no handwritten std::arch; faer SIMD dispatch is provided by pulp.

New primitive APIs return Result for data-dependent upstream failures. Allocation failure or unrepresentable array/order sizes are programmer errors. FFT APIs retain their documented panic contract. TRF parity is partial; see tests/golden.rs and the feature registry before using it in an engine.

Modules§

convolution
Streaming matrix FIR convolution with shared input transforms.
fft
NumPy-compatible FFTs over cached realfft/rustfft plans, at most 16 of each kind per thread.
fir
Adapted from Impulcifer-py313 crates/impulcifer-dsp/src/stages/room_tuning2/primitives.rs (MIT, Copyright (c) 2024- 115dkk), corrected against SECS 2/SciPy. See docs/THIRD_PARTY.md and ../THIRD_PARTY_LICENSES.txt. SciPy firwin subset used by mimo.lowpass_fir: Hamming low-pass, DC scale.
grid
Adapted from Impulcifer-py313 crates/impulcifer-dsp/src/stages/room_tuning2/primitives.rs (MIT, Copyright (c) 2024- 115dkk), corrected against SECS 2/SciPy. See docs/THIRD_PARTY.md and ../THIRD_PARTY_LICENSES.txt. Upstream design frequency grids and fractional-octave resolution.
iir
Adapted from Impulcifer-py313 crates/impulcifer-dsp/src/filters.rs (MIT, Copyright (c) 2024- 115dkk). See docs/THIRD_PARTY.md for attribution and licenses. Butterworth design and zero-state filtering with conventional denominator signs.
lowrate
Adapted from Impulcifer-py313 crates/impulcifer-dsp/src/stages/room_tuning2/primitives.rs (MIT, Copyright (c) 2024- 115dkk), corrected against SECS 2/SciPy. See docs/THIRD_PARTY.md and ../THIRD_PARTY_LICENSES.txt. Upstream MIMO low-rate projection. D3 interpolation/taper is preserved.
minphase
Adapted from Impulcifer-py313 crates/impulcifer-dsp/src/stages/room_tuning2/primitives.rs (MIT, Copyright (c) 2024- 115dkk), corrected against SECS 2/SciPy. See docs/THIRD_PARTY.md and ../THIRD_PARTY_LICENSES.txt. Cepstral minimum-phase response, using the implied even inverse length.
multirate
Experimental low-rate matrix convolution with shared rate converters.
optimize
Adapted from Impulcifer-py313 crates/impulcifer-dsp/src/optimize.rs (MIT, Copyright (c) 2024- 115dkk). See docs/THIRD_PARTY.md for attribution and licenses. Bounded TRF, exact SVD solver, linear loss and bounded two-point differences.
peaks
Adapted from Impulcifer-py313 crates/impulcifer-dsp/src/peaks.rs (MIT, Copyright (c) 2024- 115dkk). See docs/THIRD_PARTY.md for attribution and licenses. Height-only peak selection (scipy.signal.find_peaks as SECS 2’s mimo and mimo_iir call it).
random
NumPy 2.5.3 legacy RandomState draws used by SciPy differential evolution.
rate
Output-rate materialization of filters designed at 48 kHz (ADR 0017).
resample
Rate conversion for discrete impulse responses, preserving transfer gain.
response
SECS analog prototypes and unnormalized RBJ transfer functions. Arithmetic helpers adapted from Impulcifer-py313 crates/impulcifer-dsp/src/stages/room_tuning2/{primitives,peq}.rs (MIT, Copyright (c) 2024- 115dkk); see docs/THIRD_PARTY.md.
smooth
Adapted from Impulcifer-py313 crates/impulcifer-dsp/src/stages/room_tuning2/primitives.rs (MIT, Copyright (c) 2024- 115dkk), corrected against SECS 2/SciPy. See docs/THIRD_PARTY.md and ../THIRD_PARTY_LICENSES.txt. Fractional-octave smoothing, including upstream’s sequential cumsum.

Enums§

DspError
Data-dependent errors corresponding to upstream invalid inputs.

Functions§

complex_div
NumPy’s complex division (Smith’s scaled formula, including a division by zero), so quotients match NumPy to the last bit.
interp
NumPy linear interpolation with endpoint clamping (nonempty sorted grid).
pairwise_sum
NumPy’s contiguous float64 pairwise reduction (128-element blocks).

Type Aliases§

Complex64
Alias for a Complex<f64>