Skip to content
Open
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
6 changes: 5 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ adheres to `Semantic Versioning <http://semver.org/spec/v2.0.0.html>`_.
`Unreleased`_
-------------

Nothing yet
Bugfix
~~~~~~

- Fixes MicrophoneArray.append(MicrophoneArray)
AttributeError: 'MicrophoneArray' object has no attribute 'shape'.

`0.8.4`_ - 2025-05-19
---------------------
Expand Down
5 changes: 4 additions & 1 deletion pyroomacoustics/beamforming.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,20 +535,23 @@ def append(self, locs):
a `numpy.ndarray` with each column containing the coordinates of a
microphone.
"""
n_new_mics = 0
if isinstance(locs, MicrophoneArray):
self.R = np.concatenate((self.R, locs.R), axis=1)
self.directivity += locs.directivity
n_new_mics = locs.R.shape[1]
else:
self.R = np.concatenate((self.R, locs), axis=1)
self.directivity += [None] * locs.shape[1]
n_new_mics = locs.shape[1]

# in case there was already some signal recorded, just pad with zeros
if self.signals is not None:
self.signals = np.concatenate(
(
self.signals,
np.zeros(
(locs.shape[1], self.signals.shape[1]), dtype=self.signals.dtype
(n_new_mics, self.signals.shape[1]), dtype=self.signals.dtype
),
),
axis=0,
Expand Down
8 changes: 8 additions & 0 deletions pyroomacoustics/tests/test_microphone_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,11 @@ def test_microphone_array_append(shape1, shape2, with_dir, from_raw_locs):

assert mic_array.nmic == shape1[1] + shape2[1]
assert len(mic_array.directivity) == shape1[1] + shape2[1]


def test_microphone_array_append_with_existing_signals():
mic_array = pra.MicrophoneArray(np.ones((3, 2)), fs=_FS)
mic_array.signals = np.random.randn(2, 1000)
new_mic_array = pra.MicrophoneArray(np.ones((3, 1)), fs=_FS)
mic_array.append(new_mic_array)
assert mic_array.nmic == 3