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#

pyFDN.random_orthogonal

Generate a random orthogonal matrix distributed according to the Haar measure.

pyFDN.householder_matrix

Create a Householder reflection matrix from a vector.

pyFDN.anderson_matrix

Build an N×N block-circulant orthogonal matrix.

pyFDN.complete_orthogonal

Solve the orthogonal completion problem for feedback matrix A.

pyFDN.nearest_orthogonal

Return the nearest orthogonal matrix to A in the Frobenius norm.

pyFDN.nearest_sign_agnostic_orthogonal

Find the orthogonal matrix U minimising ‖A − |U|‖_F.

pyFDN.schroeder_reverberator

Create combs and allpass filters as a single FDN.

pyFDN.allpass_in_fdn

Create an allpass structure embedded in an FDN of size [2N, 2N].

pyFDN.cascaded_paraunitary_matrix

Construct a paraunitary matrix and its reverse response.

pyFDN.paraunitary_from_elementals

Construct a random paraunitary matrix as a cascade of elemental factors.

pyFDN.tiny_rotation_matrix

Dense orthogonal matrix with small eigenvalue angles.

pyFDN.rotation_matrix_from_angles

Orthogonal matrix with prescribed eigenvalue angles.

pyFDN.rotation_kernel

2x2 rotation by theta: [[cos, -sin], [sin, cos]].

pyFDN.reflection_kernel

2x2 reflection at half-angle theta: [[cos, sin], [sin, -cos]].

pyFDN.kronecker_angles

Angle vector [theta_1, ..., theta_M] for a network of size N.

pyFDN.kronecker_matrix

Build the explicit Kronecker feedback matrix Psi_M.

pyFDN.kronecker_transform

Apply the Kronecker feedback matrix to x in O(N log2 N) per row.

pyFDN.fdn_matrix_gallery

Return a feedback matrix of the requested type.

pyFDN.fdn_system_gallery

Return a full FDN system (A, B, C, D) of the requested type.

pyFDN.FEEDBACK_MATRIX_TYPES

Built-in immutable sequence.

pyFDN.FILTER_MATRIX_TYPES

Built-in immutable sequence.

pyFDN.SYSTEM_TYPES

Built-in immutable sequence.

pyFDN.filter_matrix_gallery

Return an FIR (filter) feedback matrix of the requested type.

pyFDN.fdn_dss_gallery

Generate a random FDN: (dss, filters).

pyFDN.sample_delay_lengths

Generate N delay-line lengths in samples.

pyFDN.DSS

Delay state-space system: the standard matrices of an FDN, nothing else.

Allpass FDN#

pyFDN.homogeneous_allpass_fdn

Generate allpass FDN with homogeneous decay: V = [A,B;C,D] uniallpass, A = U @ G.

pyFDN.random_admissible_homogeneous_allpass

Generate a random admissible diagonal matrix P for homogeneous uniallpass FDN.

pyFDN.complete_fdn

Compute a completion (B,C,D) for given A.

pyFDN.complete_full_mimo_halmos

Full MIMO (k=N) Halmos/Julia dilation.

pyFDN.complete_general_mimo_svd

General MIMO completion via defect subspace (CS/SVD-based).

pyFDN.nested_allpass

Create Gardner's nested allpass FDN (SISO).

pyFDN.poletti_allpass

Create Poletti's MIMO unitary reverberator (allpass FDN).

pyFDN.series_allpass

Create Schroeder's series allpass FDN (SISO).

pyFDN.is_allpass

Test whether the delay state-space system is allpass.

pyFDN.is_uniallpass

Test whether the FDN is uniallpass (lossless with a diagonal Lyapunov matrix).

pyFDN.is_paraunitary

Test whether an FIR matrix is paraunitary (lossless).

Scattering Delay Network#

pyFDN.SDN

Scattering delay network of a shoebox room.

pyFDN.sdn_to_flamo

Build a FLAMO Shell that renders sdn; see SDN for the flow.

pyFDN.plot_sdn

Draw the room, the source, the receiver and the six scattering nodes.

Acoustics & Absorption#

pyFDN.sos_gain_per_sample_curves

Magnitude response (gain per sample vs angle) for a per-channel SOS bank.

pyFDN.echo_density

Echo density and mixing time (Abel & Huang 2006).

pyFDN.edc

Energy decay curve: backward cumulative sum of squared signal along an axis.

pyFDN.estimate_initial_level_bands

Estimate the initial level of the exponential decay per octave band.

pyFDN.estimate_rt_bands

Estimate RT in octave bands via Butterworth bandpass filtering.

pyFDN.octave_bands

Octave band edges and centre frequencies.

pyFDN.octave_band_filterbank

Butterworth bandpass filters (SOS) for the given band edges.

pyFDN.rt_to_gain_per_sample

Convert reverb time (seconds) to gain coefficient per sample.

pyFDN.rt_to_slope

Convert reverb time (RT, seconds) to energy decay slope (dB per sample).

pyFDN.slope_amplitude_to_level

Initial amplitude of an exponential decay from its energy (EDC amplitude).

pyFDN.slope_to_rt

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.

pyFDN.EQDesign

pyFDN.decay_to_graphic_eq

Design attenuation GEQs from ten reverberation times in seconds.

pyFDN.decay_to_first_order_shelf

Design first-order attenuation shelves from endpoint RTs in seconds.

pyFDN.decay_to_one_pole

Design one-pole attenuation filters from endpoint RTs in seconds.

pyFDN.decay_to_two_stage

Design two-stage attenuation filters from ten reverberation times.

pyFDN.gain_to_graphic_eq

Design a ten-band graphic EQ from amplitudes in dB.

pyFDN.gain_to_bounded_graphic_eq

Design a graphic EQ with bounded internal section gains.

pyFDN.gain_to_first_order_shelf

Design a first-order shelf from its endpoint amplitudes in dB.

pyFDN.gain_to_one_pole

Design a one-pole filter from its endpoint amplitudes in dB.

pyFDN.gain_to_two_stage

Design a two-stage EQ from ten amplitudes in dB.

pyFDN.graphic_eq_design_matrix

Return the constant map from ten band targets to eleven command gains.

pyFDN.probe_sos

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.

pyFDN.td.TimeOperator

Abstract class.

pyFDN.td.Identity

Stateless pass-through.

pyFDN.td.Gain

Stateless static gain matrix y = x @ M.T with M of shape (out, in).

pyFDN.td.Delay

Stateful per-channel integer feed-forward delay line, y[n, c] = x[n - m_c, c].

pyFDN.td.AbsoluteValue

Stateless memoryless nonlinearity y[n, c] = |x[n, c]|.

pyFDN.td.DCBlocker

Stateful per-channel first-order DC blocker with optional slow energy compensation, y[n, c] = x[n, c] - x[n-1, c] + pole * y[n-1, c].

pyFDN.td.ControllableFullWaveRectifier

Stateful, controllable, memoryless nonlinearity, y[n, c] = g_cfwr * ((1 - alpha) * x[n, c] + alpha * abs(x[n, c])), applied to active_channels (default all); the rest pass through unchanged.

pyFDN.td.SignalDependentFractionalDelay

Stateful, controllable signal-dependent fractional delay (SDFD), y[n, c] = (1 - d) n[n-1, c] + d n[n, c] + d p[n-2, c] + (1 - d) p[n-1, c] with d = fraction, applied to active_channels (default all); the rest pass through unchanged.

pyFDN.td.RingModulator

Stateful, controllable ring modulator, y[n, c] = depth * x[n, c] * sin(2 * pi * rate * n / fs), applied to active_channels (default all); the rest pass through unchanged.

pyFDN.td.PitchShift

Stateful, controllable dual-read-head pitch shifter.

pyFDN.td.GranularPitchShift

Stateful, controllable granular pitch shifter.

pyFDN.td.SOSBank

Stateful per-channel SOS filter cascade (e.g. in-loop absorption).

pyFDN.td.MatrixFIR

Stateful matrix of FIR filters (e.g. a paraunitary scattering feedback matrix).

pyFDN.td.MatrixConvolver

Stateful matrix of FIR filters via streaming overlap-save FFT convolution.

pyFDN.td.KroneckerMatrix

Stateless Kronecker feedback matrix applied with the fast O(N log2 N) butterfly.

pyFDN.td.TimeVaryingMatrix

Stateful sinusoidally modulated orthogonal mixing matrix (time-varying feedback).

pyFDN.td.TimeVaryingKroneckerMatrix

Kronecker feedback matrix with per-kernel angle modulation (time-varying feedback).

pyFDN.td.RecursionState

Vectorised bank of block-addressable delay lines.

pyFDN.td.Series

Chain operators left to right.

pyFDN.td.Parallel

Feed the same input to every branch and combine the outputs (optional).

pyFDN.td.Recursion

Closed feedback loop, y[n] = fF(x[n] + fB(y[n - block_size])).

Delay Utilities#

pyFDN.matrix_delay_approximation

Rank-1 approximation of matrix group delay.

pyFDN.matrix_group_delay

Group delay for each entry of an FIR matrix.

pyFDN.ms_to_samples

Convert milliseconds to samples.

pyFDN.flamo_to_impz

Impulse response of a FLAMO model, shape (nfft, out, in).

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.

pyFDN.assemble_fdn_core

Wire pre-built FLAMO modules into an FDN core (no FFT/iFFT wrapping).

pyFDN.wrap_fdn_shell

Wrap an FDN core in a FLAMO Shell that returns the impulse response.

pyFDN.gain_module

Build a FLAMO Gain module from a numpy array.

pyFDN.delay_module

Build a FLAMO parallelDelay module from delay lengths in samples.

pyFDN.matrix_module

Build a FLAMO Matrix initialized to values under a parametrization.

pyFDN.fir_matrix_module

Build a FLAMO Filter module from a matrix FIR coefficient array.

pyFDN.sos_filter_module

Build a FLAMO parallelSOSFilter from an SOS coefficient array.

pyFDN.AttenuationFilter

Parallel in-loop SOS bank parametrized by reverberation time.

pyFDN.OutputEQ

Parallel SOS bank parametrized by gain in dB.

Polynomial & Matrix Maths#

pyFDN.adjugate_polynomial

Adjugate of a polynomial matrix via FFT evaluation.

pyFDN.adjugate

Adjugate matrix, valid also for singular and complex matrices.

pyFDN.det_polynomial

Determinant of a polynomial matrix in the z^{-1} convention.

pyFDN.general_char_poly

Generalized characteristic polynomial (GCP) for delay state-space.

pyFDN.interpolate_orthogonal

Geodesic interpolation between two orthogonal matrices.

pyFDN.is_orthogonal

Check if Q is orthogonal (Q.T @ Q ≈ I).

pyFDN.is_unilossless

Test whether A is diagonally similar to an orthogonal matrix.

pyFDN.loop_transfer_function

Loop transfer function P(z) = diag(z^m) - A as a polynomial matrix.

pyFDN.matrix_convolution

Matrix polynomial multiplication by convolution.

pyFDN.outer_sum_approximation

Rank-1 approximation minimizing ||u + v^T - matrix||_F.

General Utilities#

pyFDN.lin_to_db

Convert linear magnitude to decibels with numerical guard.

pyFDN.sq_to_db

Convert squared magnitude (power) to decibels with numerical guard.

pyFDN.fade_out

Apply a linear fade-out over the last fade_samples samples.

pyFDN.hertz_to_unit

Convert frequency (Hz) to normalised frequency (0-1).

pyFDN.hertz_to_rad

Convert frequency (Hz) to angular frequency (rad/sample).

pyFDN.rad_to_hertz

Convert angular frequency (rad/sample) to frequency (Hz).

pyFDN.is_bounding_curve

Check if all value points are bounded by the curve.

pyFDN.max_corr

Pairwise maximum normalized cross-correlation of a MIMO signal matrix.

pyFDN.mulaw_encode

Mu-law companding (encode): linear amplitude to companded.

pyFDN.peak_normalize

Scale array so the maximum absolute value equals target_peak.

pyFDN.pole_boundaries

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.

pyFDN.available_audio

Return the names accepted by load_audio().

pyFDN.audio_metadata

Return attribution and license metadata for a packaged audio sample.

pyFDN.load_audio

Load an audio sample distributed with pyFDN.

pyFDN.available_fdn_presets

Return the names accepted by load_fdn_preset().

pyFDN.load_fdn_preset

Return a packaged FDN as a DSS.

pyFDN.save_fdn

Save obj together with the version of pyFDN that wrote it.

pyFDN.load_fdn

Load an object written by save_fdn().

pyFDN.resave_fdn

Rewrite a saved file with the installed pyFDN, applying RENAMED.

pyFDN.paper_reference

Return a copy of the bibliography fields for paper_id.

pyFDN.paper_link

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).

pyFDN.dss_to_ss

Convert a delay state-space (DSS) system to standard state-space.

pyFDN.dss_to_impz

Compute MIMO impulse response from delay state-space (DSS) representation.

pyFDN.dss_to_td

Assemble a delay state-space (DSS) system as a stateful td graph.

pyFDN.dss_to_tf

From a delay state-space (DSS) system to a transfer function matrix.

pyFDN.dss_to_pr

Modal decomposition of a delay state-space (DSS) system.

pyFDN.dss_to_flamo

Build a FLAMO model from a delay state-space (DSS) system (delays, A, B, C, D).

pyFDN.flamo_to_dss

Extract the DSS and baked filters from a named FLAMO model.

pyFDN.flamo_to_pr

Poles/residues from a FLAMO transfer H(z) = C(z)P(z)^{-1}B(z) + D(z).

pyFDN.flamo_decompose_for_pr

Decompose a FLAMO model into the subgraphs needed for poles/residues.

pyFDN.FlamoDecompositionForPR

Decomposition of a FLAMO model into small subgraphs for poles/residues.

pyFDN.impz_to_res

Estimate residues from impulse response and known poles via least squares.

pyFDN.tf_to_impz

Compute MIMO impulse response from matrix transfer function (numerator/denominator).

pyFDN.pr_to_impz

Synthesize impulse response from poles and residues.

pyFDN.PoleResidue

Pole-residue (modal) form of a system: H(z) = sum_k R_k / (1 - p_k z^-1) + D.

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.

pyFDN.seed_poles

Find the num_poles largest-magnitude poles of a FLAMO loop.

pyFDN.track_poles

Follow poles of a FLAMO loop while its parameters move along a path.

pyFDN.PoleTracks

Poles followed along a parameter path, as returned by track_poles().

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#

pyFDN.process_dss

Process a signal through a delay state-space system.

pyFDN.flamo_process

Run a 1-D signal through a FLAMO Shell model offline.

Training#

pyFDN.trainable_fdn

Build a trainable flamo Shell from a config.

pyFDN.trainable_from_dss

Build a trainable flamo Shell initialized from a DSS.

pyFDN.Trainable

Which of the FDN's gain groups are trained.

pyFDN.train_fdn

Train model on loss in place and return a TrainLog.

pyFDN.TrainLog

Per-step loss history and stopping info from a training run.

pyFDN.LOSSLESS_ALIAS_DECAY_DB

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().

pyFDN.Response

The impulse response of an FDN, as a loss sees it.

pyFDN.model_response

Run model on an impulse and wrap the result in a Response.

pyFDN.param

Reference the parameter called name in model.

pyFDN.params

Every parameter of model, in graph order.

pyFDN.ParamRef

A reference to one parameter of one model.

pyFDN.Loss

Base class for training losses.

pyFDN.Match

Compares a model's impulse response to a target using three steps:

pyFDN.FlatMagnitude

Mean squared error of \(|H|\) against a flat target -- colorless.

pyFDN.AsymmetricFlatMagnitude

Flatness that punishes peaks far harder than dips -- colorless.

pyFDN.FlatSpectrogram

Flatness measured on multi-resolution smoothed spectra -- colorless.

pyFDN.SpectralFlatness

Spectral flatness measure of \(|H|\) fit to flat -- colorless.

pyFDN.MatchMagnitude

Mean squared error of \(|H|\) against a reference impulse response.

pyFDN.MatchPhase

Circular distance of \(\angle H\) against a reference impulse response.

pyFDN.MatchPhaseSpectrogram

Circular distance of the STFT phase against a reference, multi-resolution.

pyFDN.MatchMelMagnitude

Mel-scaled mean squared error of \(|H|\) against a reference.

pyFDN.MatchSpectrogram

Multi-resolution STFT distance to a reference impulse response.

pyFDN.MatchMelSpectrogram

Mel-scaled multi-resolution STFT distance (FLAMO's mel_mss_loss).

pyFDN.MatchImpulseResponse

Mean squared error against a reference impulse response, sample by sample.

pyFDN.MatchEnergyDecay

RMS dB error of the octave-band energy decay curves against a reference.

pyFDN.MatchCumulativeEnergy

Doubly-cumulated energy against a reference -- decay and colour, no bands.

pyFDN.MatchMelEnergyDecayRelief

Multi-resolution mel energy decay relief (EDR) distance to a reference.

pyFDN.MatchEchoDensity

Mean squared error of the differentiable echo density profile.

pyFDN.MatchEnvelope

Normalized \(L^p\) error of the smoothed peak envelope.

pyFDN.Energy

Squared deviation of the response's total energy from target.

pyFDN.Sparsity

Density penalty on a square mixing matrix, after Optimizing Tiny Colorless FDNs (Dal Santo et al.).

pyFDN.L1

Mean absolute value of a parameter -- pushes it toward sparse.

pyFDN.L2

Mean squared value of a parameter -- plain weight decay.

pyFDN.mimo_rir_eigenvalues_per_frequency

Compute eigenvalues of a MIMO transfer matrix at each frequency bin.

Plotting#

pyFDN.plot_matrix

Plot a single matrix as a heatmap (RdBu, square pixels).

pyFDN.plot_matrix_grid

Plot several matrices as a grid of heatmaps sharing one color scale.

pyFDN.plot_system_matrix

Plot system matrix [A B; C D] as 2x2 heatmaps, shared RdBu color scale.

pyFDN.plot_fdn_parameter

Plot all FDN parameters in one figure.

pyFDN.plot_db_per_sample

Plot SOS magnitude responses normalized by delay length (dB per sample).

pyFDN.plot_impulse_response

Plot one or more impulse responses over time, mu-law compressed by default.

pyFDN.plot_impulse_response_matrix

Plot a matrix of impulse responses in a subplot grid (out x in).

pyFDN.plot_edc

Plot the energy decay curve (EDC) of one or more impulse responses.

pyFDN.plot_spectrogram

Plot spectrogram of a 1-D signal as a Matplotlib image.

pyFDN.animate

Animate a sequence of frames built by any per-frame plotting function.

Notebook Display#

pyFDN.labeled_audio

Stack a text label above an audio player (a marimo element).

FLAMO Graph#

pyFDN.plot_flamo_graph

Draw the FLAMO model signal flow with matplotlib.