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. |
|
Randomly shift polynomial matrices in time. |
|
Shift a polynomial matrix in time-domain by |
|
Randomly distribute time shifts for a polynomial matrix. |
|
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 |
|
Build the degree-one lossless polynomial matrix |
|
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. |
|
Wrapper for |
|
Generate orthogonal matrix with small eigenvalue angles. |
|
Generate orthogonal matrix with prescribed eigenvalue angles. |
|
Return a feedback matrix of the requested type, or list all type names. |
|
Return a full FDN system (A, B, C, D) of the requested type, or list all type names. |
|
Return an FIR (filter) feedback matrix of the requested type, or list all type names. |
|
Build a complete FDN and optionally return its non-inferable design. |
|
Generate |
|
Full FDN system matrices returned by |
|
Complete, renderable parameters of a vanilla FDN. |
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 a MIMO impulse response is paraunitary (lossless). |
Scattering Delay Network#
Minimal SDN: from room and source/receiver, compute only network parameters (delay lengths, routing, scattering matrices, wall filters) for use in an FDN. |
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", or "one_pole" used by those
modules. The target-to-EQ functions accept return_design=True when their
JSON-compatible design record is also needed for an FDNPreset.
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 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. |
|
Return the constant map from ten band targets to eleven command gains. |
|
Return |
|
Return |
|
Return |
|
Return a normalized one-section SOS from two linear amplitudes. |
|
Return a normalized one-pole section from two linear amplitudes. |
|
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). 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, |
|
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. |
|
Stateful sinusoidally modulated orthogonal mixing matrix (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. |
|
Return a FLAMO model's time response as a NumPy array. |
|
Return a FLAMO model's (complex) frequency response as a NumPy array. |
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.process_fdn() 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 seconds. |
|
Build a FLAMO |
|
Build a FLAMO Filter module from a matrix FIR coefficient array. |
|
Build a FLAMO parallelSOSFilter from an SOS coefficient array. |
|
One FLAMO module for a filter hook, from an SOS bank, a module, or several. |
|
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. |
|
Derivative of rational filter matrices in the z^{-1} convention. |
|
Evaluate a matrix polynomial |
|
Matrix square root via eigenvalue decomposition. |
|
Derivative of rational polynomial with negative exponents. |
|
Rank-1 approximation minimizing |
|
Return the polynomial degree in the z^{-1} convention. |
|
Derivative of rational polynomial using quotient rule. |
|
Construct a diagonal polynomial matrix from an array of polynomials. |
General Utilities#
Convert decibel values to linear magnitude. |
|
Convert decibel values to squared magnitude (power). |
|
Convert linear magnitude to decibels with numerical guard. |
|
Convert squared magnitude (power) to decibels with numerical guard. |
|
Ensure the matrix has a trailing polynomial dimension. |
|
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. |
|
Return 1-based indices of the last non-zero element along axis 2. |
|
Pairwise maximum normalized cross-correlation of a MIMO signal matrix. |
|
Mu-law companding (decode): companded to linear amplitude. |
|
Mu-law companding (encode): linear amplitude to companded. |
|
Scale array so the maximum absolute value equals target_peak. |
|
Find upper and lower pole boundaries for FDN loop. |
|
Return skew-symmetric matrix from upper triangle. |
Build Files, Packaged Examples & References#
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 |
|
A baked vanilla FDN plus metadata and optional design information. |
|
Convert an |
|
Construct an |
|
Write a preset as indented, human-readable JSON. |
|
Load an |
|
Convert an |
|
Construct an |
|
Write an |
|
Load an |
|
Return a copy of the bibliography fields for |
|
Return a Markdown citation link for a packaged bibliography entry. |
State-Space Translators#
Convert delay state-space (DSS) FDN to standard state-space. |
|
Compute MIMO impulse response from delay state-space (DSS) representation. |
|
Render an |
|
From delay state-space to transfer function matrix (numerator and denominator). |
|
Modal decomposition of an FDN from raw DSS matrices. |
|
Build a FLAMO model from delay state-space (A, B, C, D, m). |
|
Build a FLAMO model from a complete |
|
Poles/residues from a FLAMO transfer |
|
Decompose a FLAMO model into the subgraphs needed for poles/residues. |
|
Extract the H(z)=C P(z)^{-1}B+D probes from a FLAMO model. |
|
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. |
FDN Processing#
Simulate the feedback delay network using block processing. |
|
Run a 1-D signal through a FLAMO |
Training#
Build a trainable flamo |
|
Build a trainable flamo |
|
Build a FLAMO model while recovering designed filter parameters. |
|
Return a copy of |
|
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. |
|
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. |
|
Mean squared error of \(|H|\) against a reference impulse response. |
|
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. |
|
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. |
Plotting#
Plot a single matrix as a Plotly heatmap (RdBu, square pixels). |
|
Plot several matrices as a grid of Plotly heatmaps sharing one color scale. |
|
Plot system matrix [A b; c d] as 2x2 Plotly heatmaps, shared RdBu color scale. |
|
Plot all FDN parameters in one figure. |
|
Plot the parameters stored in an |
|
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 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. |
|
Create a Plotly |
|
Downsample a line while preserving local minima and maxima. |
|
Return a copy of a Plotly trace with downsampled |
Notebook Display#
Stack a text |
FLAMO Graph#
Draw the FLAMO model signal flow with matplotlib. |
|
Traverse a FLAMO model and build a tree of nodes (nested dicts). |
|
Flatten the node tree into a list of nodes, each with a 'path' key. |
|
Extract a complete |