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

Maybe found a bug of 3D microphone array center location #316

Open hhhuxy opened 11 months ago

hhhuxy commented 11 months ago

Hi there, first thank u for such helpful and also user-friendly software! I've probably noticed a bug when simulating a 3D microphone array.

Run the following simple simulation

import numpy as np
import matplotlib.pyplot as plt
import pyroomacoustics as pra
from scipy.io import wavfile

fs=16000
room_dim = [7, 5, 2.5]  # a room of 7*5*2.5
room = pra.ShoeBox(p=room_dim)
mic_xyz = np.array([3, 1, 2])  # mic center at 3,1,2
mic_array = pra.circular_microphone_array_xyplane(center=mic_xyz, M=6, phi0=0, radius=0.5, fs=fs)
fs, signal = wavfile.read('./arctic_a0010.wav')
room.add_microphone_array(mic_array)
room.add_source(position=[1,1.5,2], signal=signal)
fig, ax = room.plot(plot_directivity=False)
ax.set_xlim([0, 8])
ax.set_ylim([0, 6])
ax.set_zlim([0, 3])
print(mic_array.center)
plt.show()

and the output representing the center of microphone array is (3,3,2) thought i set it as (3,1,2). it might due to line 302 in beamforming.py: 'R = circular_2D_array(center=center[:1], M=M, phi0=phi0, radius=radius)' center=center[:1] here is only a one-dim vec, and I guess it neglected the second dim. after altering the line to 'R = circular_2D_array(center=center[:2], M=M, phi0=phi0, radius=radius)' , it gets a correct output of (3,1,2) as center of the microphone array.

fakufaku commented 11 months ago

Yes, this looks like a mistake, thanks for letting us know!