Differences With Other Libraries
mishalydev opened this issue · comments
I'm trying to decide what library should we use to simulate a room acoustics based on ISM method.
My main focus is on the generated RIR
While doing a few experiments I noticed that pra
RIR has a really different scale than other libraries I checked like gpuRIR
and rir_generator
.
Here's an exmaple of such a different based on David's (=gpuRIR
creator) response in another thread I opened at gpuRIR
repo (last comment in Differences with pyroomacoustics):
import numpy as np
import matplotlib.pyplot as plt
import gpuRIR
import pyroomacoustics as pra
sr = 16000
t60=0.2
room_dim = np.array([3, 4, 2])
pos_src= np.array([[1.5, 1, 1]])
pos_rcv= np.array([[1.5, 3, 1]])
e_absorption, max_order = pra.inverse_sabine(t60, room_dim)
room = pra.ShoeBox(room_dim, fs=sr, materials=pra.Material(e_absorption), max_order=max_order)
room.add_source(pos_src.T)
mic = pra.MicrophoneArray(pos_rcv.T, sr)
room.add_microphone_array(mic)
room.compute_rir()
rir_length = t60 # length of the RIR in seconds
nb_img = gpuRIR.t2n(T=rir_length, rooms_sz=room_dim)
beta = gpuRIR.beta_SabineEstimation(room_dim, t60)
rir = gpuRIR.simulateRIR(room_dim, beta, pos_src, pos_rcv, nb_img, Tmax=rir_length, fs=sr)
After David fixed the lag and scale, they become much more similar:
lag = np.argmax(np.abs(room.rir[0][0])) - np.argmax(np.abs(rir[0,0,:]))
scale = np.max(np.abs(rir[0,0,:])) / np.max(np.abs(room.rir[0][0]))
plt.plot(scale * room.rir[0][0][lag:512+lag])
plt.plot(rir[0,0,:512])
plt.legend(['pra', 'gpuRIR'])
plt.show()
He also explained the math behind that, and as a result, we ended up with the question:
Where these differences came from?
I'd really appreciate any response
Thanks
Hi @mishalydev , I'll jump in the other thread if that's ok.