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

Sensor noise renormalizes the signals #291

Closed egrinstein closed 1 year ago

egrinstein commented 1 year ago

Hi,

when calling room.simulate(..., snr=VALUE), the following code is called:

elif snr is not None:
            # Normalize all signals so that
            denom = np.std(premix_signals[:, reference_mic, :], axis=1)
            premix_signals /= denom[:, None, None]
            signals = np.sum(premix_signals, axis=0)

            # Compute the variance of the microphone noise
            self.sigma2_awgn = 10 ** (-snr / 10) * S

Which normalizes each source signal by its std. Is this the desired behaviour? If I wanted one source to have a lower volume than another, wouldn't this undo their different volumes? Why is this normalization necessary?

Thank you and sorry for bothering,

Kind regards,

Eric

fakufaku commented 1 year ago

Hi @egrinstein , I agree. In hindsight this may not be the most desirable behavior, but this is what I implemented. Maybe the adding the noise should be done in a different function. I don't want to change the behavior here to not break existing code. As an alternative, it is possible to pass your own mixing function as a callback to simulate.

egrinstein commented 1 year ago

Hi, sorry for the delay. Thank you for the answer! I'll do that.

fakufaku commented 1 year ago

@egrinstein Thanks for the feedback. I'm working on improving the experience with noise. This is in this pull request (#298) if you are interested.

egrinstein commented 1 year ago

Thanks for letting me know @fakufaku, it looks like a great addition to Pyroomacoustics. Please let me know if I can help.

fakufaku commented 1 year ago

@egrinstein This is very nice of you to ask! Any help is welcome! Let me know if there is any part you'd like to dig into! If you'd like to discuss this more you can join our discord.