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

Merged
merged 1 commit into from
Jan 20, 2025

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?

@tamland
Copy link
Owner

tamland commented Jan 17, 2025

It's interesting. I'm not sure how much work that will be as it still has to support buffering, playback speed and more

@tamland
Copy link
Owner

tamland commented Jan 20, 2025

Merging this in the meantime.

Started to implement the web audio solution here: https://github.com/tamland/airsonic-refix/tree/web-audio Still have some minor fade bugs i haven't figured out yet, but other than that it works.

@tamland tamland merged commit 231396e into tamland:master Jan 20, 2025
1 check passed
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