Skip to content

Commit

Permalink
Fixes bugs in circular_microphone_array_xyplane and Room.plot_rir (#350)
Browse files Browse the repository at this point in the history
* Fixes bug in circular_microphone_array_xyplane (#348). 

* Fixes frequency unit of room.plot_rir with kind=tf.
  • Loading branch information
fakufaku authored May 26, 2024
1 parent 2d00433 commit d66cf05
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
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)

0 comments on commit d66cf05

Please sign in to comment.