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

Fixes bugs in circular_microphone_array_xyplane and Room.plot_rir #350

Merged
merged 2 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ Changed
The energy tail beyond this threshold is discarded which is useful for noisy RIR
measurements. The default value is 0.95.

Bugfix
~~~~~~

- Fixes a bug in ``beamforming.circular_microphone_array_xyplane`` (#348)
- Fixes a bug in ``room.Room.plot_rir`` where the x-axis would have the wrong
ticks when called with ``kind="tf"``

`0.7.4`_ - 2024-04-25
---------------------

Expand Down
2 changes: 1 addition & 1 deletion pyroomacoustics/beamforming.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def circular_microphone_array_xyplane(
MicrophoneArray object
"""

R = circular_2D_array(center=center[:1], M=M, phi0=phi0, radius=radius)
R = circular_2D_array(center=center[:2], M=M, phi0=phi0, radius=radius)
if len(center) == 3:
colatitude = 90
R = np.concatenate((R, np.ones((1, M)) * center[2]))
Expand Down
2 changes: 1 addition & 1 deletion pyroomacoustics/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -1887,7 +1887,7 @@ def plot_func(ax, h):
ax.plot(np.arange(len(h)) / float(self.fs / 1000), h)
elif kind == "tf":
H = 20.0 * np.log10(abs(np.fft.rfft(h)) + 1e-15)
freq = np.arange(H.shape[0]) / h.shape[0] * (self.fs * 1000)
freq = np.arange(H.shape[0]) / h.shape[0] * (self.fs / 1000)
ax.plot(freq, H)
elif kind == "spec":
h = h + np.random.randn(*h.shape) * 1e-15
Expand Down
19 changes: 19 additions & 0 deletions pyroomacoustics/tests/test_issue_348.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import numpy as np

import pyroomacoustics as pra


def test_circular_microphone_array_xyplane():
# Create a circular microphone array
R = 1.0 # radius
M = 2 # number of microphones
center = np.array([1.0, 0.0, 0.0]) # center of the array

mic_array = pra.circular_microphone_array_xyplane(
center=center, M=M, phi0=0.0, radius=R, fs=16000
)

# what it should be
R_ref = np.array([[2.0, 0.0], [0.0, 0.0], [0.0, 0.0]])

assert np.allclose(mic_array.R, R_ref)
Loading