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

ReplayGain: make sure volume doesn't exceed 1.0 #144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sentriz
Copy link
Contributor

@sentriz sentriz commented Jan 5, 2025

sometimes the clamp will result in this.audio.volume being slightly >1 which throws an exception since it must be in the range 0-1 https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/volume

i think this happens if the peak volume calcuation is slightly off in the tags. since most of the time when when this happens for me it's trying to set it to soemthing like 1.012323

@tamland
Copy link
Owner

tamland commented Jan 6, 2025

I think you should fix replayGainFactor() function to ensure it never returns a value greater than 1. The original from and to parameters will always be in the 0..1 range

@sentriz
Copy link
Contributor Author

sentriz commented Jan 8, 2025

I'm not sure we want to clamp the replaingain factor. sometimes it says that we want to boost the signal if it's too quiet. that's part of the spec

looking at another implementaion it looks like the browser has a GainNode which can be >1 while still only letting the user's volume property be max at one

looks like that would be a good usecase to seperate user volume and calculated gain. maybe the fading functionality could use that too. wdyt?

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

Successfully merging this pull request may close these issues.

2 participants