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

Add noise objects to create different type of noise #296

Open fakufaku opened 1 year ago

fakufaku commented 1 year ago

The idea is to have a simple interface to define background noise. We follow the API of SoundSource and MicrophoneArray where objects are added to the room via the add method.

We add an abastrct object type Noise with a unified interface for all types of noise onto the microphone signals after the propagation has been simulated.

Here is an example of the type of code we want to have

room = ShoeBox(...)
room.add_source(...)
room.add_microphone(...)
room.add(WhiteNoise(snr=10.0))

noisy_mix, premix, noise = room.simulate(full_output=True)

# noisy_mix == premix.sum(axis=0) + noise with SNR = 10 dB
assert np.allclose(noisy_mix, premix.sum(axis=0) + noise)

The current implementation (for white noise only) is an snr parameter to the simulate method. The implementation is also not very good and has unrequested scaling of the source signals. Better to have some modular implementation that is extensible by sub-classing the Noise class. For that, we will need to change slightly the interface

TODO

Checks

I am still working on this and will update the status

Happy PR :smiley: