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

Support for recorded source/mic directivities from DIRPAT database (#259) #302

Open
wants to merge 60 commits into
base: master
Choose a base branch
from

Conversation

fakufaku
Copy link
Collaborator

@fakufaku fakufaku commented Feb 2, 2023

This PR is to integrate the work done by @prerak23 into the master branch:

Generalize for other SOFA files

The goal is to generalize what has been done for DIRPAT by @prerak23 to all SOFA files.
The target syntax is as follows.

# the file reader object reads the file and optionally performs interpolation
# if the file contains multiple directivities, they are all read
hrtf = MeasuredDirectivityFile(
    path="hrtf_file.sofa",
    fs=fs,
    interp_order=12,
    interp_n_points=1000,
)

# orientations can be provided as rotation matrices
orientation = Rotation3D([colatitude_deg, azimuth_deg], "yz", degrees=True)

# we can then choose which directivities we want from the file
dir_left = hrtf.get_mic_directivity("left", orientation=orientation)
dir_right = hrtf.get_mic_directivity("right", orientation=orientation)

TODO

  • documentation
  • changelog
  • Read multiple objects from a single file to be able to simulate mic arrays more smoothly, e.g. eigenmike. This could be implemented by detecting the multiple channels after the call to get_response that would return a (n_image_sources, n_channels, n_taps) array.
  • Implement 3D rotations with Euler angles

Co-authored-by: prerak23 prerak23@github.com

Thanks for sending a pull request (PR), we really appreciate that! Before hitting the submit button, we'd be really glad if you could make sure all the following points have been cleared.

Please also refer to the doc on contributing for more details. Even if you can't check all the boxes below, do not hesitate to go ahead with the PR and ask for help there.

  • Are there docstrings ? Do they follow the numpydoc style ?
  • Have you run the tests by doing nosetests or py.test at the root of the repo ?
  • Have you checked that the doc builds properly and that any new file has been added to the repo ? How to do that is covered in the documentation.
  • Is there a unit test for the proposed code modification ? If the PR addresses an issue, the test should make sure the issue is fixed.
  • Last but not least, did you document the proposed change in the CHANGELOG file ? It should go under "Unreleased".

Happy PR 😃

prerak23 and others added 5 commits February 2, 2023 11:53
)

* This is a pretty big commit that includes loading recorded directivity files and using them in the simulation
* Supports source/receiver for shoebox rooms
* Interpolation in spherical harmonic domain
* Adds option for using minimum phase filters
---------

Co-authored-by: prerak23 <prerak23@github.com>
…r the SOFA directivities. Adds samples some pre-generated samples for the tests. Removes some print statements from room.py.
…rical/cartesian conversion functions from doa sub-package. Adds a generalized pinv computation function. Adds a new plotting function. Moves doa sub-package fibonacci mapping to a dedicated function to make it available everywhere.
…ation. Adds also a generalized version of the method for the case where the measurement points are not on a grid. Adds tests for all this. Changes the regression test data files for sofa interpolation.
…s. Modifies slightly doa.GridSphere object so that it can be used to hold simple spherical grids without overhead.
…ore SOFA files. Fixes a bug with using cardioid/sofa responses where the cardioid would expect degrees, but got radians. Re-generates the test files for SOFA measured respones. Fixes a bug in DirectionVector where the degrees argument for the getter methods of azimuth and colatitude was ignored.
@fakufaku fakufaku mentioned this pull request Jun 14, 2023
5 tasks
…file. also modifies download function to avoid a fail when internet is not available
… test for correctness based on the energy integral on the sphere.
…arate classes wrapper instead (Cardioid, Sub-cardioid, etc). Adds Rotation3D class to apply arbitrary rotations to measured directivities.
… to cartesian coordinates. Re-generates the test file after visual inspection.
@fakufaku
Copy link
Collaborator Author

@prerak23
How are you doing?
I have made good progress, and I am feeling good about releasing things soon.
Would you mind taking a look at the current code?
I have also created some documentation here
(I don't have your new email address, so please send me an email)

@fakufaku fakufaku self-assigned this May 28, 2024
@fakufaku fakufaku requested a review from prerak23 May 28, 2024 07:14
orientation = DirectionVector(azimuth=0, colatitude=45, degrees=True)

# create cardioid object
dir_obj = CardioidFamily(orientation=orientation, pattern_enum=pattern)
dir_obj = HyperCardioid(orientation=orientation)

# plot
azimuth = np.linspace(start=0, stop=360, num=361, endpoint=True)
Copy link
Collaborator

@prerak23 prerak23 Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For colatitude, shouldn't the "num" be equal to 181?

interp_n_points = 1000

fs, speech = wavfile.read(args.source)
speech = speech * (0.95 / abs(speech).max())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we normalizing speech signals here? Curious to know why?

dir_obj_Dmic = akg.get_mic_directivity("AKG_c414K", orientation=rot_54_73)
dir_obj_Emic = eigenmike.get_mic_directivity("EM_32_9", orientation=rot_54_73)

dir_obj_Cmic = FigureEight(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it is good to comment here that the mic response is analytic for this case ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a new addition, with the past code I haven't experimented with HRTF's.

from scipy.fftpack import dct
from scipy.interpolate import interp1d
from scipy.signal import butter, fftconvolve, sosfiltfilt
from scipy.signal import butter, fftconvolve, hilbert, sosfiltfilt
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't found the usage of Hilbert transform in this file.

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

Successfully merging this pull request may close these issues.

None yet

2 participants