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.35k stars 419 forks source link

rir mixing problem; adding point source noise or babble noise. #177

Closed LeeYongHyeok closed 2 years ago

LeeYongHyeok commented 3 years ago

Hi, i'm trying to make rir mixing simulation envirnment.

In my case, I want to position my target source and some noise source.

I checked rir mixing simulate function worked pretty well, but i can't find how i control the signal-to-noise ratio (SNR).

I want to control SNR on my target source and the others in the simulated microphone array.

I guess the SNR control available on the white gaussian noise, but is there any function for the external source?

Thanks for your help.

fakufaku commented 3 years ago

Hi @LeeYongHyeok

Controlling the SNR depends a lot on the goal of the simulation, so the functionality offered by default in the simulator is minimal. However, it is possible to get all the reverberant sources prior to mixing so that you can adjust the SNR as you like. We provide an example in the documentation.

There are two ways to do it:

  1. Provide a callback_mix function to Room.simulate
  2. Provide the argument return_premix=True to Room.simulate so that you get all the sources prior to mixing. Then you can mix them as you like. The returned premix array has shape (n_sources, n_microphones, n_samples).

As a side-note, be aware that you can't have the same SNR at all microphones. Due to the physical nature of the microphones, the power of the sources at a microphone depends on their distance. Thus, the power of the sources may be different at every microphone. Typically, I choose one microphone as the reference and do all my SNR computations with respect to this microphone.

LeeYongHyeok commented 3 years ago

Hi @fakufaku !

Thank you for your sincere and kind response.

Your comments helped me a lot.

There is one more question. Is it a common way to calculate SNR based on one reference microphone? I tried to calculate based on the center point of every microphone.

liziru commented 3 years ago

嗨@LeeYongHyeok

控制SNR很大程度上取决于仿真的目标,因此仿真器默认提供的功能很少。 但是,可以在混合之前获取所有混响源,以便您可以根据需要调整SNR。我们在文档中提供了一个示例

有两种方法可以做到这一点:

  1. 提供callback_mix功能Room.simulate
  2. 提供参数return_premix=Trueto,Room.simulate以便在混合之前获得所有源。然后,您可以根据需要混合它们。返回的premix数组具有shape (n_sources, n_microphones, n_samples)

附带说明一下,请注意,并非所有麦克风都具有相同的SNR。由于麦克风的物理性质,麦克风处源的功率取决于它们的距离。因此,每个麦克风的源功率可能不同。通常,我选择一个麦克风作为参考,并针对该麦克风进行所有SNR计算。

Hi, I found a problem after following the snr demo you provided, the generated audio is full of unknow noise like white when i change the snr into "room.simulate(reference_mic=0, snr=10)" . I am confused about this. I will appreciate it for any help.

fakufaku commented 3 years ago

@LeeYongHyeok , right. I don't know if this is standard, but you need to have a microphone at the reference point. If you want to use the center point, you need to add a microphone at that location and use the signal recorded there for your computation. You can discard that signal later if you didn't actually want to simulate a microphone there.

@liziru If you provide the parameter snr=10, the simulator will add white noise to the output signal to achieve 10 dB of signal-to-noise ratio (SNR). Is this what you are talking about, or is there something else that was unexpected ?

liziru commented 3 years ago

@LeeYongHyeok , right. I don't know if this is standard, but you need to have a microphone at the reference point. If you want to use the center point, you need to add a microphone at that location and use the signal recorded there for your computation. You can discard that signal later if you didn't actually want to simulate a microphone there.

@liziru If you provide the parameter snr=10, the simulator will add white noise to the output signal to achieve 10 dB of signal-to-noise ratio (SNR). Is this what you are talking about, or is there something else that was unexpected ?

Ok, I see. Thank you very much. I want to add more reverb to signal data so that i can test my dreverb algorithm. How can i achieve it? By increasing reverberation time?

fakufaku commented 3 years ago

Yes, this is correct, you should increase the reverberation time.

liziru commented 3 years ago

Yes, this is correct, you should increase the reverberation time.

OK, thank you very much.