LCAV / pyroomacoustics

Pyroomacoustics is a package for audio signal processing for indoor applications. It was developed as a fast prototyping platform for beamforming algorithms in indoor scenarios.
https://pyroomacoustics.readthedocs.io
MIT License
1.45k stars 432 forks source link

reverberation time with low degrees of absorption #280

Open Atriplex82 opened 2 years ago

Atriplex82 commented 2 years ago

Hello, while trying to simulate a room, I noticed the measured reverberation time differs from the one calculated with Sabine. When setting the coeffs of the walls to 0.5 the reverberation time seems plausible. Why is that?

Here's the code:

import numpy as np
from scipy.io import wavfile
import IPython
import pyroomacoustics as pra

# Define the materials array
ceiling_mat = {
    "coeffs": [0.45, 0.50, 0.5, 0.4, 0.35, 0.35],
    "center_freqs": [125, 250, 500, 1000, 2000, 4000],
}
floor_mat = {
    "coeffs": [0.16, 0.24, 0.56, 0.69, 0.81 , 0.78 ],
    "center_freqs": [125, 250, 500, 1000, 2000, 4000],
}
wall_mat = {
    "coeffs": [0.02, 0.02, 0.03, 0.03, 0.04, 0.06],
    #"coeffs": [0.5, 0.5, 0.5, 0.5, 0.5, 0.5],
    "center_freqs": [125, 250, 500, 1000, 2000, 4000],
}

height = 3.75

corners = np.array([[0,0], [0,8], [7,8], [7,0],]).T  # [x,y]

mat = pra.make_materials(*[(wall_mat,) for i in range(corners.shape[1])])

room = pra.Room.from_corners(
    corners,
    materials=mat,
    max_order=-1,
    ray_tracing=True,
    air_absorption=True,)

me = pra.make_materials(floor=floor_mat, ceiling=ceiling_mat)
room.extrude(height, materials=me)

# Set the ray tracing parameters
room.set_ray_tracing(time_thres=10,)

# specify signal source
fs, signal = wavfile.read("german_speech_8000.wav")

# add source and set the signal to WAV file content
room.add_source([1., 1., 0.5], signal=signal)

# add microphone 
room.add_microphone([6.0, 6.0, 0.5])

room.simulate()

rt60_tgt = room.rt60_theory()
room_dim = [8, 7, 3.75]
e_absorption, max_order = pra.inverse_sabine(rt60_tgt, room_dim)
print("absorption_mean:",np.mean([ceiling_mat["coeffs"],floor_mat["coeffs"],wall_mat["coeffs"]]))
print("absorption_theory:",e_absorption)
print("max_order_ism:",max_order)
print("RT60_theory:",rt60_tgt)
print("RT60_measure:",room.measure_rt60()[0, 0] )

,thanks

fakufaku commented 1 year ago

Hi @Atriplex82 , sorry for the late reply! Yes, I have also noticed discrepancy between Sabine's formula and measured RT60. I think this may come from deviation between the hypothesis used to derive Sabine's formula and actual simulation.

Atriplex82 commented 1 year ago

Could it be that, it's beacause Sabine's formula needs a diffuse sound field? By setting medium sized scattering coefficients (I hope I did that correctly) the reverberation time decreases significantly.