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.44k stars 429 forks source link

circular or spherical microphone array in 3D room #137

Closed anandhupvr closed 4 years ago

anandhupvr commented 4 years ago

how can i use this lib to generate circular or spherical microphone array for 3D RIR. eg. room_dim = [10, 10, 5] sound source location = [2, 3, 2] microhpne array_location (spherical or circular)= [5, 5, 2]

question is about how to generate 3D microphone array

fakufaku commented 4 years ago

Hi, what kind of array are you interested in ? At the moment, pyroomacoustics support free field arrays, but not rigid sphere array.

A free field 3D spherical array can be created by combining MicrophoneArray with the doa.GridSphere object.

import numpy as np
import pyroomacoustics as pra

# center of array as column vector
mic_center = np.c_[[5, 5, 2]]

# microphone array radius
mic_radius = 0.05

# number of elements
mic_n = 8

# The GridSphere objects creates a number of points
# pseudo-uniformly spread on the unit sphere
grid = pra.doa.GridSphere(mic_n)

# The locations of the microphones can then be computed
R = mic_center + mic_radius * grid.cartesian

# Finally, we make the microphone array object as usual
# second argument is the sampling frequency
mics = pra.MicrophoneArray(R, 16000)

The points on the 3D sphere are chosen using the Spherical Fibonacci Mapping. See the documentation for details and links.

anandhupvr commented 4 years ago

I'm just exploring different microphone arrays. So when i check circular microphone array from your example code it works only in 2D room. Do i need to add one more dimension to result from this function 'circular_2D_array' or is there any other ways to create circular array in 3D room. And curious to know if i can generate Ambisonics format signals from any of the microphone arrays

fakufaku commented 4 years ago

You can create circular arrays with the circular_2D_array method. The method only creates 2D array so to lift it in 3D you need to manually add the z coordinate.

import numpy as np
import pyroomacoustics as pra

# center of array as column vector
mic_center = np.array([5, 5, 2])

# microphone array radius
mic_radius = 0.05

# number of elements
mic_n = 8

# Create the 2D circular points
R = pra.circular_2D_array(mic_center[:2], mic_n, 0, mic_radius)
R = np.concatenate((R, np.ones((1, mic_n)) * mic_center[2]), axis=0)

# Finally, we make the microphone array object as usual
# second argument is the sampling frequency
mics = pra.MicrophoneArray(R, 16000)

For ambisonics, there is nothing in pyroomacoustics itself, but there should be several methods that exist to convert the signals from a circular mic array.

anandhupvr commented 4 years ago

thanks @fakufaku

Tanumay2023 commented 1 year ago

Hi, I am exploring DOA estimation of a 3D room environment. pyroomacoustics model is working fine for azimuth estimation of the single source. Now, I want to estimate the azimuth and colatitude (elevation ) of the source signal and also visualize the plot of the elevation estimation.