Skip to content

Commit

Permalink
Merge pull request #361 from LCAV/fix/bugfixes
Browse files Browse the repository at this point in the history
- fixes a bug in the bounding box computation of AnechoicRoom
- fixes some inconsistensies in the build of rir_build
  • Loading branch information
fakufaku authored Aug 8, 2024
2 parents cd9fb84 + 7fb15a5 commit daa2833
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 18 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ jobs:
fail-fast: false
max-parallel: 12
matrix:
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
# switch temporarily to windows-2019 due to a breaking
# change making mutex constexpr
# a crash occurs if python and the extension are built
# with different versions
# over time, this should hopefully resolves itself
# ref: https://github.com/microsoft/STL/issues/4875
os: [ubuntu-latest, macos-13, macos-latest, windows-2019]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
exclude:
- os: macos-latest
Expand All @@ -33,13 +39,6 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with flake8
run: |
# pip install flake8
# stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Build package
run: |
python -m pip install -e .
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ adheres to `Semantic Versioning <http://semver.org/spec/v2.0.0.html>`_.
`Unreleased`_
-------------

Nothing yet
Bugfix
~~~~~~

- Fixes a bug when plotting an anechoic room
- Fixes a buggy assert from ``rir_build.cpp``
- Makes the build system consistent for all source files in ``pyroomacoustics/libroom_src``

`0.7.6`_ - 2024-08-05
---------------------
Expand Down
2 changes: 0 additions & 2 deletions pyroomacoustics/libroom_src/rir_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ void threaded_rir_builder_impl(
int max_sample = int(std::ceil(fs * t_max)) + fdl2;
int min_sample = int(std::floor(fs * t_min)) - fdl2;

assert(min_samples >= 0);

if (min_sample < 0)
throw std::runtime_error("minimum time recorded is less than 0");
if (max_sample >= int(rir_len))
Expand Down
2 changes: 2 additions & 0 deletions pyroomacoustics/libroom_src/rir_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ void delay_sum(const py::buffer irs, const py::buffer delays, py::buffer output,
void fractional_delay(py::buffer out, const py::buffer time, size_t lut_gran,
size_t num_threads);

#include "rir_builder.cpp"

#endif // __RIR_BUILDER_HPP__
8 changes: 4 additions & 4 deletions pyroomacoustics/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -3153,12 +3153,12 @@ def get_bbox(self):
upper = -np.inf * np.ones((self.dim,))

if self.mic_array is not None:
lower = np.min(np.r_[lower[None, :], self.mic_array.R], axis=0)
upper = np.max(np.r_[upper[None, :], self.mic_array.R], axis=0)
lower = np.min(np.column_stack((lower, self.mic_array.R)), axis=1)
upper = np.max(np.column_stack((upper, self.mic_array.R)), axis=1)

for i, source in enumerate(self.sources):
lower = np.min(np.r_[lower[None, :], source.position[None, :]], axis=0)
upper = np.max(np.c_[upper[None, :], source.position[None, :]], axis=0)
lower = np.min(np.row_stack((lower, source.position)), axis=0)
upper = np.max(np.row_stack((upper, source.position)), axis=0)

return np.c_[lower, upper]

Expand Down
2 changes: 1 addition & 1 deletion pyroomacoustics/tests/test_build_rir.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def measure_runtime(dtype=np.float32, num_threads=4):

test_fractional_delay(np.float32, 2e-2)
test_fractional_delay(np.float64, 2e-2)
test_delay_sum(np.float32, 1e-6)
test_delay_sum(np.float32, 1e-4)

for t, a, v in zip(times, alphas, visibilities):
ir_ref, ir_cython = build_rir_wrap(t, a, v, fs, fdl)
Expand Down
9 changes: 7 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __str__(self):
ext_modules = [
Extension(
"pyroomacoustics.libroom",
[os.path.join(libroom_src_dir, f) for f in ["libroom.cpp", "rir_builder.cpp"]],
[os.path.join(libroom_src_dir, f) for f in ["libroom.cpp"]],
depends=libroom_files,
include_dirs=[
".",
Expand All @@ -70,7 +70,12 @@ def __str__(self):
os.path.join(libroom_src_dir, "ext/eigen"),
],
language="c++",
extra_compile_args=["-DEIGEN_MPL2_ONLY", "-Wall", "-O3", "-DEIGEN_NO_DEBUG"],
extra_compile_args=[
"-DEIGEN_MPL2_ONLY",
"-Wall",
"-O3",
"-DEIGEN_NO_DEBUG",
],
),
Extension(
"pyroomacoustics.build_rir",
Expand Down

0 comments on commit daa2833

Please sign in to comment.