API Reference#
All functions and classes are accessible from the top-level pyFDN namespace:
import pyFDN
feedback = pyFDN.random_orthogonal(4)
The reference is organised by functional area, mirroring the package’s module
structure. It covers the headline public API; a small number of low-level
helpers are exported for advanced/composability use but intentionally omitted
here (see tests/test_api_reference.py).
Matrix Generators#
Generate a random orthogonal matrix distributed according to the Haar measure. |
|
Create a Householder reflection matrix from a vector. |
|
Build an N×N block-circulant orthogonal matrix. |
|
Solve the orthogonal completion problem for feedback matrix A. |
|
Return the nearest orthogonal matrix to A in the Frobenius norm. |
|
Find the orthogonal matrix U minimising |
|
Create combs and allpass filters as a single FDN. |
|
Create an allpass structure embedded in an FDN of size [2N, 2N]. |
|
Construct a paraunitary matrix and its reverse response. |
|
Construct a random paraunitary matrix as a cascade of elemental factors. |
|
Dense orthogonal matrix with small eigenvalue angles. |
|
Orthogonal matrix with prescribed eigenvalue angles. |
|
2x2 rotation by |
|
2x2 reflection at half-angle |
|
Angle vector |
|
Build the explicit Kronecker feedback matrix |
|
Apply the Kronecker feedback matrix to |
|
Return a feedback matrix of the requested type. |
|
Return a full FDN system |
|
Built-in immutable sequence. |
|
Built-in immutable sequence. |
|
Built-in immutable sequence. |
|
Return an FIR (filter) feedback matrix of the requested type. |
|
Generate a random FDN: |
|
Generate |
|
Delay state-space system: the standard matrices of an FDN, nothing else. |
Allpass FDN#
Generate allpass FDN with homogeneous decay: V = [A,B;C,D] uniallpass, A = U @ G. |
|
Generate a random admissible diagonal matrix P for homogeneous uniallpass FDN. |
|
Compute a completion (B,C,D) for given A. |
|
Full MIMO (k=N) Halmos/Julia dilation. |
|
General MIMO completion via defect subspace (CS/SVD-based). |
|
Create Gardner's nested allpass FDN (SISO). |
|
Create Poletti's MIMO unitary reverberator (allpass FDN). |
|
Create Schroeder's series allpass FDN (SISO). |
|
Test whether the delay state-space system is allpass. |
|
Test whether the FDN is uniallpass (lossless with a diagonal Lyapunov matrix). |
|
Test whether an FIR matrix is paraunitary (lossless). |
Scattering Delay Network#
Scattering delay network of a shoebox room. |
|
Build a FLAMO |
|
Draw the room, the source, the receiver and the six scattering nodes. |
Acoustics & Absorption#
Magnitude response (gain per sample vs angle) for a per-channel SOS bank. |
|
Echo density and mixing time (Abel & Huang 2006). |
|
Energy decay curve: backward cumulative sum of squared signal along an axis. |
|
Estimate the initial level of the exponential decay per octave band. |
|
Estimate RT in octave bands via Butterworth bandpass filtering. |
|
Octave band edges and centre frequencies. |
|
Butterworth bandpass filters (SOS) for the given band edges. |
|
Convert reverb time (seconds) to gain coefficient per sample. |
|
Convert reverb time (RT, seconds) to energy decay slope (dB per sample). |
|
Initial amplitude of an exponential decay from its energy (EDC amplitude). |
|
Convert slope (dB/sample) to reverb time in seconds. |
EQ Design (pyFDN.eq)#
Explicit functions map either decay targets or gain targets onto a named
filter design. The same functions run in NumPy or Torch; the trainable
pyFDN.AttenuationFilter and pyFDN.OutputEQ modules use these
mappings inside a training loop. EQDesign is the literal choice of
"graphic_eq", "first_order_shelf", "one_pole", or "two_stage"
used by those modules.
Design attenuation GEQs from ten reverberation times in seconds. |
|
Design first-order attenuation shelves from endpoint RTs in seconds. |
|
Design one-pole attenuation filters from endpoint RTs in seconds. |
|
Design two-stage attenuation filters from ten reverberation times. |
|
Design a ten-band graphic EQ from amplitudes in dB. |
|
Design a graphic EQ with bounded internal section gains. |
|
Design a first-order shelf from its endpoint amplitudes in dB. |
|
Design a one-pole filter from its endpoint amplitudes in dB. |
|
Design a two-stage EQ from ten amplitudes in dB. |
|
Return the constant map from ten band targets to eleven command gains. |
|
Evaluate the magnitude response of each biquad at control frequencies. |
Time-Domain Graph (pyFDN.td)#
Stateful block-processing operators, wired into a graph by the connectors and
rendered with .process_signal(signal). See pyFDN.td.
Abstract class. |
|
Stateless pass-through. |
|
Stateless static gain matrix |
|
Stateful per-channel integer feed-forward delay line, |
|
Stateless memoryless nonlinearity |
|
Stateful per-channel first-order DC blocker with optional slow energy compensation, |
|
Stateful, controllable, memoryless nonlinearity, |
|
Stateful, controllable signal-dependent fractional delay (SDFD), |
|
Stateful, controllable ring modulator, |
|
Stateful, controllable dual-read-head pitch shifter. |
|
Stateful, controllable granular pitch shifter. |
|
Stateful per-channel SOS filter cascade (e.g. in-loop absorption). |
|
Stateful matrix of FIR filters (e.g. a paraunitary scattering feedback matrix). |
|
Stateful matrix of FIR filters via streaming overlap-save FFT convolution. |
|
Stateless Kronecker feedback matrix applied with the fast |
|
Stateful sinusoidally modulated orthogonal mixing matrix (time-varying feedback). |
|
Kronecker feedback matrix with per-kernel angle modulation (time-varying feedback). |
|
Vectorised bank of block-addressable delay lines. |
|
Chain operators left to right. |
|
Feed the same input to every branch and combine the outputs (optional). |
|
Closed feedback loop, |
Delay Utilities#
Rank-1 approximation of matrix group delay. |
|
Group delay for each entry of an FIR matrix. |
|
Convert milliseconds to samples. |
|
Impulse response of a FLAMO model, shape |
Building a FLAMO Graph#
An FDN as FLAMO modules, assembled from numpy values. The three filter hooks –
post_delay inside the loop, post_matrix on the feedback path,
post_output on the wet signal – are the same three
pyFDN.dss_to_td() takes, in the same positions and under the same
names.
Wire pre-built FLAMO modules into an FDN core (no FFT/iFFT wrapping). |
|
Wrap an FDN core in a FLAMO |
|
Build a FLAMO Gain module from a numpy array. |
|
Build a FLAMO parallelDelay module from delay lengths in samples. |
|
Build a FLAMO |
|
Build a FLAMO Filter module from a matrix FIR coefficient array. |
|
Build a FLAMO parallelSOSFilter from an SOS coefficient array. |
|
Parallel in-loop SOS bank parametrized by reverberation time. |
|
Parallel SOS bank parametrized by gain in dB. |
Polynomial & Matrix Maths#
Adjugate of a polynomial matrix via FFT evaluation. |
|
Adjugate matrix, valid also for singular and complex matrices. |
|
Determinant of a polynomial matrix in the z^{-1} convention. |
|
Generalized characteristic polynomial (GCP) for delay state-space. |
|
Geodesic interpolation between two orthogonal matrices. |
|
Check if Q is orthogonal (Q.T @ Q ≈ I). |
|
Test whether A is diagonally similar to an orthogonal matrix. |
|
Loop transfer function |
|
Matrix polynomial multiplication by convolution. |
|
Rank-1 approximation minimizing |
General Utilities#
Convert linear magnitude to decibels with numerical guard. |
|
Convert squared magnitude (power) to decibels with numerical guard. |
|
Apply a linear fade-out over the last |
|
Convert frequency (Hz) to normalised frequency (0-1). |
|
Convert frequency (Hz) to angular frequency (rad/sample). |
|
Convert angular frequency (rad/sample) to frequency (Hz). |
|
Check if all value points are bounded by the curve. |
|
Pairwise maximum normalized cross-correlation of a MIMO signal matrix. |
|
Mu-law companding (encode): linear amplitude to companded. |
|
Scale array so the maximum absolute value equals target_peak. |
|
Upper and lower bounds of the pole magnitudes of an FDN loop. |
Saving, Packaged Examples & References#
pyFDN.save_fdn() writes a DSS as readable JSON and
pickles anything else – a td graph, a FLAMO model – with the pyFDN and
Python versions that wrote it. Loading a pickle runs code from the file, so
only load pickles you trust. The packaged presets are DSS JSON files.
Return the names accepted by |
|
Return attribution and license metadata for a packaged audio sample. |
|
Load an audio sample distributed with pyFDN. |
|
Return the names accepted by |
|
Return a packaged FDN as a |
|
Save |
|
Load an object written by |
|
Rewrite a saved file with the installed pyFDN, applying |
|
Return a copy of the bibliography fields for |
|
Return a Markdown citation link for a packaged bibliography entry. |
State-Space Translators#
Convert a delay state-space (DSS) system – A, B, C, D,
delays – to another representation. A DSS unpacks
straight into each of them, with its filters alongside:
pyFDN.dss_to_td(*dss, **filters).
Convert a delay state-space (DSS) system to standard state-space. |
|
Compute MIMO impulse response from delay state-space (DSS) representation. |
|
Assemble a delay state-space (DSS) system as a stateful |
|
From a delay state-space (DSS) system to a transfer function matrix. |
|
Modal decomposition of a delay state-space (DSS) system. |
|
Build a FLAMO model from a delay state-space (DSS) system (delays, A, B, C, D). |
|
Extract the |
|
Poles/residues from a FLAMO transfer |
|
Decompose a FLAMO model into the subgraphs needed for poles/residues. |
|
Decomposition of a FLAMO model into small subgraphs for poles/residues. |
|
Estimate residues from impulse response and known poles via least squares. |
|
Compute MIMO impulse response from matrix transfer function (numerator/denominator). |
|
Synthesize impulse response from poles and residues. |
|
Pole-residue (modal) form of a system: |
Tracking poles along a parameter path#
pyFDN.track_poles() follows a few poles of a FLAMO loop while any of its
parameters change – a loop gain, the feedback matrix, filter coefficients –
by continuation (Bai and Schlecht, ICASSP 2026). pyFDN.seed_poles() finds
the dominant poles to start from, without a full modal decomposition.
Find the |
|
Follow poles of a FLAMO loop while its parameters move along a path. |
|
Poles followed along a parameter path, as returned by |
Experimental Lindsey–Fox modal decomposition#
Pass mode="lindsey_fox" to pyFDN.dss_to_pr() or
pyFDN.flamo_to_pr() for FFT grid search with Laguerre refinement.
The existing defaults remain "eig" for static DSS and "eai" for FLAMO.
The opt-in route checks completeness and the all-port response. Failed search,
completion, or response validation raises without switching to EAI. Direct EAI
calls may accept incomplete results with explicit allow_approximate=True
and successful response checks; this option does not relax LF acceptance.
pyFDN.general_char_poly() recovers the static characteristic
coefficients once from determinant samples and reuses them on every search
circle. The static "roots" backend uses these FFT coefficients too.
All modal backends report solver and pole-count metadata. Complete eig, roots,
and direct EAI results have responseValidation=None; LF always checks the
response. Unsupported multiple poles raise instead of producing zero residues.
Residues follow H(z) = D + sum_k R_k / (z - p_k); a simple pole at zero
contributes a unit delay.
Usage, supported models, numerical acceptance criteria, and a reproducible benchmark on the modal examples:
FDN Processing#
Process a signal through a delay state-space system. |
|
Run a 1-D signal through a FLAMO |
Training#
Build a trainable flamo |
|
Build a trainable flamo |
|
Which of the FDN's gain groups are trained. |
|
Train |
|
Per-step loss history and stopping info from a training run. |
|
Convert a string or number to a floating-point number, if possible. |
Training Objectives#
An objective is a weighted sum of losses, composed with + and *. Losses
on the impulse response read a pyFDN.Response; losses on a model
parameter take a pyFDN.ParamRef from pyFDN.param().
The impulse response of an FDN, as a loss sees it. |
|
Run |
|
Reference the parameter called |
|
Every parameter of |
|
A reference to one parameter of one model. |
|
Base class for training losses. |
|
Compares a model's impulse response to a target using three steps: |
|
Mean squared error of \(|H|\) against a flat target -- colorless. |
|
Flatness that punishes peaks far harder than dips -- colorless. |
|
Flatness measured on multi-resolution smoothed spectra -- colorless. |
|
Spectral flatness measure of \(|H|\) fit to flat -- colorless. |
|
Mean squared error of \(|H|\) against a reference impulse response. |
|
Circular distance of \(\angle H\) against a reference impulse response. |
|
Circular distance of the STFT phase against a reference, multi-resolution. |
|
Mel-scaled mean squared error of \(|H|\) against a reference. |
|
Multi-resolution STFT distance to a reference impulse response. |
|
Mel-scaled multi-resolution STFT distance (FLAMO's |
|
Mean squared error against a reference impulse response, sample by sample. |
|
RMS dB error of the octave-band energy decay curves against a reference. |
|
Doubly-cumulated energy against a reference -- decay and colour, no bands. |
|
Multi-resolution mel energy decay relief (EDR) distance to a reference. |
|
Mean squared error of the differentiable echo density profile. |
|
Normalized \(L^p\) error of the smoothed peak envelope. |
|
Squared deviation of the response's total energy from |
|
Density penalty on a square mixing matrix, after Optimizing Tiny Colorless FDNs (Dal Santo et al.). |
|
Mean absolute value of a parameter -- pushes it toward sparse. |
|
Mean squared value of a parameter -- plain weight decay. |
|
Compute eigenvalues of a MIMO transfer matrix at each frequency bin. |
Plotting#
Plot a single matrix as a heatmap (RdBu, square pixels). |
|
Plot several matrices as a grid of heatmaps sharing one color scale. |
|
Plot system matrix [A B; C D] as 2x2 heatmaps, shared RdBu color scale. |
|
Plot all FDN parameters in one figure. |
|
Plot SOS magnitude responses normalized by delay length (dB per sample). |
|
Plot one or more impulse responses over time, mu-law compressed by default. |
|
Plot a matrix of impulse responses in a subplot grid (out x in). |
|
Plot the energy decay curve (EDC) of one or more impulse responses. |
|
Plot spectrogram of a 1-D signal as a Matplotlib image. |
|
Animate a sequence of frames built by any per-frame plotting function. |
Notebook Display#
Stack a text |
FLAMO Graph#
Draw the FLAMO model signal flow with matplotlib. |