Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differences With Other Libraries #349

Open
mishalydev opened this issue May 24, 2024 · 1 comment
Open

Differences With Other Libraries #349

mishalydev opened this issue May 24, 2024 · 1 comment

Comments

@mishalydev
Copy link

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)

image

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

image

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

@fakufaku
Copy link
Collaborator

Hi @mishalydev , I'll jump in the other thread if that's ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants