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

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

Open fakufaku opened 1 year ago

fakufaku commented 1 year ago

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 factory object reads the file and optionally performs interpolation
dir_factory = SOFADirectivityFactory(
    path=Path(DEFAULT_SOFA_PATH) / sofa_file_name,
    DIRPAT_pattern_enum=pattern_id,
    source=sofa_info[sofa_file_name]["type"] == "sources",
    fs=room.fs,
    interp_order=interp_order,
    interp_n_points=1000,
)

# we use the factory object to create directivities. This allows to reuse the pattern for
# multiple objects without having to redo the interpolation
directivity = dir_factory.create(
    orientation=DirectionVector(azimuth=0, colatitude=0, degrees=False)
)

# TODO: make a short cut object that would fuse the two above in case we
# only need one source

TODO

[ ] documentation [ ] changelog [ ] maybe a shortcut function that would fuse the factory/creation workflow [ ] 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.

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.

Happy PR :smiley: