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

Digital silence results in NaNs #1

Open
FrancisRussell opened this issue Sep 19, 2022 · 3 comments
Open

Digital silence results in NaNs #1

FrancisRussell opened this issue Sep 19, 2022 · 3 comments

Comments

@FrancisRussell
Copy link

FrancisRussell commented Sep 19, 2022

When calculating the gated mean of audio that is pure silence, it appears the power result (and also the result of loudness_lkfs()) is NaN. In this case, I'd expect a result like -infinity.

It's unclear to me what the correct behaviour is in this case - a low power value might be sufficient, but as at this is likely going to be used to normalize audio, maybe the gated mean should return an enumeration which can encode that it failed to find any audio above its gating value (which I assume is what happens here).

@ruuda
Copy link
Owner

ruuda commented Sep 19, 2022

The loudness in LKFS is based on the logarithm of the power, so it should be -∞ for 0.0 power. I added a test to confirm this..

gated_mean takes the average power over all blocks that pass the absolute threshold, and then the dynamic threshold. The absolute threshold of -70 LKFS would already result in an empty set, so then the average causes a division by zero.

After thinking about it for a bit, I agree with you, it makes sense to change the return type to Option<Power>, so it can return None when no signal remains after gating.

@ruuda
Copy link
Owner

ruuda commented Sep 19, 2022

Implemented in d369360. What do you think @FrancisRussell, does it make sense this way?

@FrancisRussell
Copy link
Author

I was torn between this or returning Power(0.0) but the more I think about it, the more I think that it makes sense semantically for the gating operation to never be able to return a power of 0. So yes, I think this makes sense.

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