Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non-linear volume for HTMLMediaElement

I've written my own media player interface using javascript and html5. Currently my volume slider maps to the browser's volume attribute 1:1. I'd quite like to adjust this to account for perceived loudness.

The volume attribute section of the html5 specs say:

... 0.0 being silent, and 1.0 being the loudest setting, values in between increasing in loudness. The range need not be linear.

This seems to imply that there's no standard for what scale browsers should use. I'm worried that if I adjust for perceived loudness in one browser, another browser might already be doing this resulting in an overcorrection.

Does anyone know what volume scales browsers currently use and whether these are likely to change in future?

like image 587
lucas Avatar asked Mar 19 '11 23:03

lucas


1 Answers

Assuming you cannot acquire directly the information on each browser, I would suggest developing a set of empirical tests. Off-hand, I can't imagine the browser vendors using anything other than logarithmic or linear volume control, so that leaves only two outcomes to consider in your tests. Once your test flow is created, you can reuse it whenever a new browser version is released.

As for the tests themselves, they could be by your own perception (test the loudness at 100% vs. 50%, and guage whether 50% actually sounds half as loud, or only 75%-ish as loud); or they could be through recording the "what you hear" channel on your soundcard, and analyzing the waveform in a custom app or tool, this time looking for a .5 drop in (peak) amplititude if simple linear, or a greater than .5 drop if logarithmic. If building your own analysis tool, PCM waveform data is not too difficult to work with, assuming you are comfortable with C/C++/C#/et.al.

like image 103
DuckMaestro Avatar answered Oct 18 '22 23:10

DuckMaestro