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

Division by zero in loudness calculation #3816

Open
DanTremonti opened this issue Jul 24, 2024 · 0 comments
Open

Division by zero in loudness calculation #3816

DanTremonti opened this issue Jul 24, 2024 · 0 comments

Comments

@DanTremonti
Copy link

DanTremonti commented Jul 24, 2024

🐛 Describe the bug

The following line in the functional method loudness results in nan value when the entire waveform is below the hardcoded loudness threshold value gamma_abs = -70.

# Apply relative gating of the blocks
gated_blocks = torch.logical_and(gated_blocks.squeeze(-2), loudness > gamma_rel.unsqueeze(-1))
gated_blocks = gated_blocks.unsqueeze(-2)
energy_filtered = torch.sum(gated_blocks * energy, dim=-1) / torch.count_nonzero(gated_blocks, dim=-1)

An example case is while trying to find loudness of an ambient sound signal.

The threshold can probably be made configurable with mention in documentation. However, I as the method returns a LUFS value, I am unsure if a configurable threshold should be allowed. I am not very familiar with the algorithm yet, any suggestions/corrections to what I've said is most welcome.

Versions

Latest code in main branch.

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

1 participant