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.33k stars 417 forks source link

For the simulation of complex models #300

Closed otanii closed 1 year ago

otanii commented 1 year ago

Hi, I am a student in Japan. I am using a translator, so I am sorry if some parts are not clear. I would like to obtain the impulse response from stl data of the ear canal, but is it tough to simulate with a complex and small model like the ear? I could not simulate it well when I tried.

otanii commented 1 year ago

Also, is it possible to place the sound source and the microphone in the same position?

fakufaku commented 1 year ago

Hi @otanii , I am not sure this is the right tool for your application. The pyroomacoustics simulator is built around two methods:

  1. The image source model, that simplifies propagation by assuming all reflections are specular (similar to a mirror in optics), is used for early reflections
  2. Ray tracing that only computes the energy envelope, can be used for the tail

Both of these methods do not approximate well the impulse response for low frequencies. I would expect that due to the size of the ear canal, most frequencies in natural sounds would behave like low frequencies and that the simulation would not be very accurate. For your application, using a finite element simulation method might be more appropriate.

In case you still want to go ahead:

otanii commented 1 year ago

Thanks for the reply. I am thinking of multiplying the model by 1000 to get a sampling frequency of 1/1000 because the actual size of the ear canal did not simulate it well. However, if I set the sampling frequency less than 500, I get an error. (I'm trying to set it to 44Hz, which is 1/1000th of 44100Hz). I would also like to know how to change the absorptivity of only certain surfaces in the stl data.

fakufaku commented 1 year ago

The approximation of the simulator may be suitable only when the frequency of the signal being simulated is much larger than the surfaces in the model. When scaling the model, you should equally scale the signal frequency, so that the relative difference is still the same, and I still think this may not be the right tool to simulate an ear canal.

If you'd like me to help with the error you get, please post a minimum code example along with the error message you get.

fakufaku commented 1 year ago

I would also like to know how to change the absorptivity of only certain surfaces in the stl data.

There is not yet a good interface for STL files, so you are pretty much on your own there. You will need to have a list of absorption coefficients corresponding to each surface in the STL file. I believe something should be possible using a 3D program outputting STL files, but I have never done it myself. If you find a good solution, please let me know.

otanii commented 1 year ago

Thanks so much for all the replies. I will try various trial and error.

fakufaku commented 1 year ago

This sounds good. I will then close this issue for now. Feel free to re-open, or open another issue if you have other questions. If the questions are unrelated, a new issue is preferable. 🙇