pyFDN.SDN#
- class pyFDN.SDN(room_size, source_pos, receiver_pos, Fs=44100, c=None, wall_filters=None)[source]#
Minimal SDN: from room and source/receiver, compute only network parameters (delay lengths, routing, scattering matrices, wall filters) for use in an FDN.
- __init__(room_size, source_pos, receiver_pos, Fs=44100, c=None, wall_filters=None)[source]#
- Parameters:
room_size (tuple (Lx, Ly, Lz)) – Cuboid room dimensions in metres.
source_pos (tuple (x, y, z)) – Source position in metres.
receiver_pos (tuple (x, y, z)) – Receiver (microphone) position in metres.
c (float, optional) – Speed of sound in m/s (default 343).
wall_filters (list of 6 lists of 5 SOS arrays, optional) – Per-wall, per-port filters. Each filter must be an SOS array of shape (n_sections, 6) as returned by
scipy.signaldesign functions such asbutter(..., output='sos')orcheby1(..., output='sos'). Must have exactly 6 walls, each with exactly 5 port filters. If None (default), identity (pass-through) filters are used for all walls and ports.
Methods
__init__(room_size, source_pos, receiver_pos)compute()Compute all SDN parameters.
sdn_to_flamo([nfft, device])Build a runnable FLAMO model from this SDN's parameters.
visualize([show, room_alpha, room_edge_color])Plot the 3D room with source, receiver, and wall node positions (Plotly).
Attributes
- DEFAULT_C = 343.0#
- N_WALLS = 6#
- compute()[source]#
Compute all SDN parameters. Call once after construction.
- Returns:
result –
- delay_lengthsnp.ndarray shape (6,6), float, seconds
delay_lengths[i,j] = delay from node i to node j. Diagonal is NaN; only i != j valid.
- delay_lengths_flatnp.ndarray shape (30,), seconds
Wall-to-wall delays in order (0,1),(0,2),…,(5,4).
- routinglist of (from_node, to_node)
routing[k] = (i, j) means delay line k goes from node i to node j.
- permutation_matrixnp.ndarray shape (30,30)
Connectivity: permutation_matrix[k_in, k_out]=1 if output of delay k_out feeds delay k_in.
- scattering_matriceslist of 6 arrays shape (5,5)
Isotropic scattering matrix for each wall node.
wall_filters_sos : np.ndarray shape (n_sections, 6, 30), SOS coefficients in delay order for FLAMO.
source_to_wall_delays : np.ndarray shape (6,), seconds
source_to_wall_gains : np.ndarray shape (6,), 1/r gain
wall_to_receiver_delays : np.ndarray shape (6,), seconds
wall_to_receiver_gains : np.ndarray shape (6,), 1/(1 + d_node_mic/d_source_node)
direct_path_delay : float, seconds
direct_path_gain : float
node_positions : list of 6 (x, y, z) tuples, wall node positions in metres.
Fs : float, sampling frequency in Hz.
c : float, speed of sound in m/s.
Input routing (FDN): 6 gains -> 6 delays -> 6-to-30 matrix (0.5 in matrix).
input_delays : np.ndarray shape (6,), seconds
input_gains : np.ndarray shape (6,), gain per node (source_to_wall_gains, 1/r).
input_matrix : np.ndarray shape (30, 6), input_matrix[k, j] = 0.5 if delay k leaves node j else 0. Use: x = input_gains * input; x = delay(x, input_delays); injection = input_matrix @ x.
Output routing (FDN): 30-to-6 matrix -> 6 delays -> 6 gains -> sum.
output_matrix : np.ndarray shape (6, 30), output_matrix[j, k] = (2/5) if delay k leaves node j else 0.
output_gains : np.ndarray shape (6,), wall_to_receiver_gains.
output_delays : np.ndarray shape (6,), seconds Use: y = output_matrix @ state_30; y = delay(y, output_delays); output_reflected = sum(output_gains * y).
output_node_to_delay_indices : list of 6 lists; output_node_to_delay_indices[j] = delay indices leaving node j.
- Return type:
- property result#
Return last result from compute(); None if compute() not called yet.
- sdn_to_flamo(nfft=131072, device=None)[source]#
Build a runnable FLAMO model from this SDN’s parameters.
Calls compute() if not already done.
- Parameters:
nfft (int) – FFT size for FLAMO.
device (torch device or None) – Device for FLAMO modules.
- Returns:
model (flamo.processor.system.Shell)
result (dict) – The SDN compute result.