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

Complex rooms made with polygons and from corners freezes at room.image_source_model() for microphones with directivity #383

Open
whojavumusic opened this issue Nov 28, 2024 · 7 comments

Comments

@whojavumusic
Copy link

I made an L shaped room and placed a Genelec_8020 source with HATS microphone given in the example. The code freezes when room.image_source_model() is called. Works fine with shoebox room.

@whojavumusic
Copy link
Author

The code freezes in room.image_source_model() at
n_visible_sources = self.room_engine.image_source_model(source.position)

@fakufaku
Copy link
Collaborator

Thanks for catching this. Is it possible to share a code snippets that reproduce the problem?

@whojavumusic
Copy link
Author

I realized that lower image orders (like 2) usually don't freeze, could it be a computation limitation? Anyway here's the snippet:

import numpy as np
import pyroomacoustics as pra
from pyroomacoustics.directivities import *

corners = np.array([[0,0], [0,5], [1,5], [1,2], [2,2], [2,5], [3,5], [3,0], [2,0], [2,1], [1,1], [1,0]]).T

room = pra.Room.from_corners(
corners,
fs=16000,
max_order=10,
)

room.extrude(3)

rot = Rotation3D([0, 0], "yz", degrees=True)
measurements = MeasuredDirectivityFile("LSPs_HATS_GuitarCabinets_Akustikmessplatz", fs=16000)

source_directivity = measurements.get_source_directivity('Genelec_8020',rot)
room.add_source([1.5,1.5,1.5], source_directivity)

hrtf = MeasuredDirectivityFile(path="mit_kemar_normal_pinna.sofa", fs=16000)
dir_left = hrtf.get_mic_directivity("left", orientation=rot)
dir_right = hrtf.get_mic_directivity("right", orientation=rot)
room.add_microphone([0.5,1.5,1.5], directivity=dir_left)
room.add_microphone([0.5,1.5,1.5], directivity=dir_right)

#freezes afterwards
room.image_source_model()
room.compute_rir()

@fakufaku
Copy link
Collaborator

fakufaku commented Nov 30, 2024

Thanks for providing the code.
I would imagine this is indeed a computational bottleneck. The complexity of the image source method for arbitrary rooms is exponential in the order, i.e., proportional num_walls ** max_order.
I would suggest to use the hybrid simulation method with max_order limited to 2 or 3 and the rest done by ray tracing.

@whojavumusic
Copy link
Author

True, but then the ray tracing does not support directivity so it wouldn’t make a realistic reverberation. Is there a plan to implement directivities to ray tracing anytime soon?

@fakufaku
Copy link
Collaborator

fakufaku commented Dec 1, 2024

I see.
I am currently implementing directivities for ray tracing but there is no clear timeline for when that will be ready.
One thing you could try to do is to combine an RIR with low order using ISM with directivities with one using ray tracing but without the directivity for the tail.

@whojavumusic
Copy link
Author

True, but that would defy the whole point of generating complex rooms if the later tail is isotropic. Anyway, Looking forward to the next update with RT with directivities included. Thanks :)

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