Hello,
Thanks for the amazing package!
I have been testing pyroomacoustics wall_factory on this simple geometry (see below).
And, by running the same code on one source to one receiver position, without changing anything at all, I get from time to time (~every 10 simulations) a completly out-of-scale RIR (RIR no. 1).
The remaining time, I get a coherent RIR (RIR no.2).
ACCORDING TO AI: the problem lies in pyroomacoustics/simulation/rt.py line 144
"The problem lies how the code normalizes the random carrier sequence (seq) to match the target energy histogram (hist). When your hist_bin_size is small, the smoothing window becomes very short. This allows "quiet gaps" in the random sequence to be detected as near-zero energy, causing a division by near-zero, which results in massive gain spikes."
# --- FIX START ---
# Instead of > 0.0, use a small threshold (e.g., 1e-10).
# This prevents dividing by tiny values in the "gaps" of the random sequence,
# which causes the amplitude explosion.
threshold = 1e-10
nonzero = seq_power > threshold
# We only normalize where the power is significant
seq_power_norm = np.where(nonzero, 1.0 / np.where(nonzero, seq_power, 1.0), 0.0)
# --- FIX END ---
What do you think ?
N.B: I am not interested in the Shoebox feature, I am trying this ShoeBox geometry to then scale it to complex mesh geometries.
Simulation setup:

RIR no.1:

RIR no.2:

Code used:
from pathlib import Path
import matplotlib.pyplot as plt
import pyroomacoustics as pra
try:
from stl import mesh
except ImportError as err:
print(
"The numpy-stl package is required for this example. "
"Install it with `pip install numpy-stl`"
)
raise err
stl_path = Path("./acoustic_mesh_no_furniture.stl")
the_mesh = mesh.Mesh.from_file(stl_path)
ntriang, nvec, npts = the_mesh.vectors.shape
freq_s = 16000
walls = []
for w in range(ntriang):
walls.append(
pra.wall_factory(
the_mesh.vectors[w].T,
# material.energy_absorption["coeffs"],
[0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],
# material.scattering["coeffs"],
[0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05]
)
)
room = pra.Room(
walls,
fs=freq_s,
max_order=1,
ray_tracing=True,
air_absorption=False,
use_rand_ism = False,
max_rand_disp = 0.05
)
source_pos = [2.0, 6.0, 1.0]
rec_pos = [2.0, 1.0, 1.5]
room.add_source(source_pos)
room.add_microphone(rec_pos)
room.set_ray_tracing(n_rays=10000, receiver_radius=0.5, hist_bin_size=0.004)
# room.image_source_model()
# room.ray_tracing()
room.compute_rir()
room.plot_rir()
plt.show()
Hello,
Thanks for the amazing package!
I have been testing pyroomacoustics wall_factory on this simple geometry (see below).
And, by running the same code on one source to one receiver position, without changing anything at all, I get from time to time (~every 10 simulations) a completly out-of-scale RIR (RIR no. 1).
The remaining time, I get a coherent RIR (RIR no.2).
ACCORDING TO AI: the problem lies in pyroomacoustics/simulation/rt.py line 144
"The problem lies how the code normalizes the random carrier sequence (seq) to match the target energy histogram (hist). When your hist_bin_size is small, the smoothing window becomes very short. This allows "quiet gaps" in the random sequence to be detected as near-zero energy, causing a division by near-zero, which results in massive gain spikes."
What do you think ?
N.B: I am not interested in the Shoebox feature, I am trying this ShoeBox geometry to then scale it to complex mesh geometries.
Simulation setup:

RIR no.1:

RIR no.2:

Code used: