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

Beamforming real signal data, setting up beamformer and setting speed of sound #272

Open
nnelshas opened this issue Jul 13, 2022 · 8 comments

Comments

@nnelshas
Copy link

Hi,

In the same vein as issue #132 I'm trying to extract a signal beamformed channel from a set 10 channels of real world data in the form of SoundSource objects in PRA. I know the mic and source locations, however, am having trouble getting the rake_delay_and_sum_weights function to work as issue #132 shows it done.

I'd really appreciate someone posting an example of how this should be written, currently I have this:

source1 = pra.SoundSource(mic_loc[0], signal = sig1)
source2 = pra.SoundSource(mic_loc[1], signal = sig2)
source3 = pra.SoundSource(mic_loc[2], signal = sig3)
. . .

mics = pra.Beamformer(mic_locs, fs, N = 256)
mics.rake_delay_and_sum_weights(source1, source2, source3, source4, . . .)

output = mics.process()

rake_delay_and_sum_weights does not seem to accept an array of sources and from issue #132 it seems like this is how you input multiple sources? Reading the source for the function though it seems like you can only feed it a single source, is there a way you can feed it multiple SoundSource objects?

Thank you!

@fakufaku
Copy link
Collaborator

Hi, the delay and sum (DS) beamformer only makes sense for a single source.
If you want to do DS beamforming towards multiple sources, you should do it one at a time.

bf_signals = []
for source in my_sources
    mics.rake_delay_and_sum_weights(signal)
    bf_signals.append(mics.process())

I see some other problems with your code

  1. Why place sources at the microphone locations ?
  2. The argument of R of Beamformer containing the microphones locations (mic_locs in your code) should be a dimension x number of mic array. This means that the location of the first mic is R[:, 0], second mic R[:, 1], etc. In your code you have both mic_loc and mic_locs, so it is a bit confusing.

@nnelshas
Copy link
Author

nnelshas commented Jul 14, 2022

Hi,

Thank you so much for the quick response! I seem to have been very confused when typing out this code and question yesterday, upon rereading what I wrote I see every problem you mentioned. Let me clarify my question and situation, I have one source of sound and 10 microphone pickups, and would like to beamform their measurements to a one channel output using pyroomacoustics. I'm having trouble applying the included examples to my situation.
How would one write a script beamforming 10 channels of real data knowing the actual source and microphone locations? Is that possible with this package?

Thanks again for the help.

@fakufaku
Copy link
Collaborator

I see, so you have some recorded data already ? Or do you want to do simulation too ?

Have you checked the beamforming example scripts ?

@nnelshas
Copy link
Author

I have 10 channels of recorded data and have taken a look at the examples. I understand how to output a single beamformed channel through the simulation workflow, but don't see an example for how to do it using one's own recorded data, for example with 10 wav files.

@fakufaku
Copy link
Collaborator

I see. It is true there is no good explanation on how to do that.
Let mics be your pra.Beamformer object.
Then, after the simulation, the multichannel signal is stored in mics.signals as a n_channels x n_samples array.
You can just set this attribute directly. Here is some pseudo-code to do it.

import pyroomacoustics as pra
from scipy.io import wavfile

fs, my_signals = wavfile.read("path/to/my_recording.wav")
# my_signals.shape == (n_samples, n_channels)

mics = pra.Beamformer(R, fs, ...)  # set the beamformer object as you like
mics.rake_delay_and_sum_weights(source)
mics.signals = my_signals.T
output = mics.process()

@nnelshas
Copy link
Author

Thank you so much for the help, that works! Where would one set the speed of sound in this example since no virtual "room" is being setup? My data is collected in an argon environment so the speed of sound is a bit slower.

Thanks again!

@fakufaku
Copy link
Collaborator

For air there are formula. I don't know about Argon. But it looks like you can find it online: https://www.betamachinery.com/knowledge-center/speed-of-sound-in-gases-list

@nnelshas
Copy link
Author

I know the speed of sound through argon is 323 m/s, however, the way you set it up in the beamformer is ambiguous to me.

When beamforming using simulated data you can use the room.set_sound_speed(323) function, however, there is no room when using real data so where would one set it in your example above?

Thank you for your time.
`

@nnelshas nnelshas reopened this Aug 1, 2022
@nnelshas nnelshas changed the title Beamforming real signal data, unable to get rake_delay_and_sum_weights to work Beamforming real signal data, setting up beamformer and setting speed of sound Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants