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

IndexError on room.visibility when sources and microphones are not in sight #313

Closed
gdelazzari opened this issue May 10, 2023 · 5 comments
Closed

Comments

@gdelazzari
Copy link

I'm trying to simulate the following room:

pyroomaudio_room

where there is a sound source at the top and a microphone array at the bottom.

However, room.simulate() fails:

Traceback (most recent call last):
  File "/home/giacomo/Projects/Tesi magistrale/Python/SoundSearch/room_audio_test.py", line 49, in <module>
    room.simulate()
  File "/home/giacomo/.local/lib/python3.10/site-packages/pyroomacoustics/room.py", line 2418, in simulate
    self.compute_rir()
  File "/home/giacomo/.local/lib/python3.10/site-packages/pyroomacoustics/room.py", line 2290, in compute_rir
    vis = self.visibility[s][m, :].astype(np.int32)
IndexError: list index out of range

It seems there is an issue with the room.visibility array in this case where the source and the microphones are not visible.

If I instead place the source and the microphones such that they are in direct sight, everything works.

Am I doing something wrong?

Thanks!

@fakufaku
Copy link
Collaborator

Hello, could you please include the code that builds the room ?

@gdelazzari
Copy link
Author

gdelazzari commented May 11, 2023

Sure, sorry for not providing it before. The setup is as follows:

# Room
sigma2 = 5e-4
fs = 16000

corners = np.array([
    [ 0,  0],
    [10,  0],
    [10, 16],
    [ 0, 16],
    [ 0, 10],
    [ 8, 10],
    [ 8,  6],
    [ 0,  6],
]).T
room = pra.Room.from_corners(corners, fs=fs, max_order=1, sigma2_awgn=sigma2)

# Microphones
def mic_array_at(pos: np.ndarray) -> pra.MicrophoneArray:
    mic_locations = pra.circular_2D_array(center=pos, M=6, phi0=0, radius=37.5e-3)
    mic_locations = np.concatenate((mic_locations, np.array(pos, ndmin=2).T), axis=1)
    return pra.MicrophoneArray(mic_locations, room.fs)

mic = mic_array_at(np.array([3, 3]))
room.add_microphone_array(mic)

# Sources
rng = np.random.RandomState(23)
duration_samples = int(fs)
source_location = np.array([3, 13])
source_signal = rng.randn(duration_samples)
room.add_source(source_location, signal=source_signal)

I thought that max_order would play some important role in this case, but changing it had no effect on the issue I'm facing (I can instead see that, when the sources and microphones are in direct sight, the room.visibility matrix shape changes as a function of max_order).

@Borknab
Copy link

Borknab commented Sep 2, 2023

@gdelazzari Hi! I am facing a similar issue now. Did you find a way to fix it? Or an explanation on why is it failing? Thanks a lot in advance!

@fakufaku
Copy link
Collaborator

@gdelazzari Thanks for reporting this.
Sorry for getting onto this so late. I could reproduce the problem with the code above.
I will now look into the problem.

fakufaku added a commit that referenced this issue May 26, 2024
fakufaku added a commit that referenced this issue May 26, 2024
@fakufaku
Copy link
Collaborator

Fixed in PR #351

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

3 participants