Correct audio volume decibels using HTML5 / javascript, disable preprocessing

We have noticed that using javascript audio from the browser, the output level is not correctly linearly proportional to the input level on many systems. For example, if you β€œplay” two sin waves with an amplitude varying by 20 dB, the resulting difference from different devices / settings can be markedly different from 20 dB, for example. up to 10 dB or less. We need to release simple sound signals (like sin waves) at calibrated decibel levels relative to each other, for example, release one comb on one tom, then release another comb that is 20dB lower than the first, and they do come out that way. ... We would like to do this from a browser using HTML5 / javascript.
We tried to do this in several ways, for example. using pre-created, calibrated .mp3 files, using the Web Audio API directly to generate a generator with calibrated dB levels. We got (to us) very surprising and mostly wrong results. When we measured the resulting sounds coming out of the device with a calibrated microphone, all sorts of strange things were observed, suggesting that the sound is not just "played" in a linear fashion, but complex preprocessing is done on it before it actually exits. It seems to depend on all sorts of variables that are currently out of our control. This does not work the way a "normal" audio amplifier does, i.e. A louder 20dB input creates a 20dB output,no matter what level the absolute level is set. We found that using the same javascript code gives very different results depending on all sorts of variables, including hardware (like viewing on a Mac versus an iPhone), the volume settings chosen (even the relative values ​​don't differ by 20 dB for a difference in 20dB input when volume is 1/2) when using headphones, etc.if headphones are used, etc.if headphones are used, etc.

Further testing reveals that the main problem is related to the use of external speakers. The results look much better when using headphones.

The main problem is that if you create two different signals with known differences in volume, for example 20 dB, and place them both in any of several ways, the measured difference will often not be 20 dB, and in some cases will be as bad as 10 dB.

Is there a way to programmatically do this?

Is there a way to override any preprocessing or compression of the audio volume that seems to adjust the volume (causing an output that is not proportional to the input)?

We need a way to do this that will work on different platforms (desktop, iOS, Android, different browsers, different headphones / speakers) hence using HTML5.

If this cannot be done using HTML5, how can we do it using native iOS / Android code? It looks like it is more of a hardware than a software issue, but there may be ways to override it.

thank

+3


source to share


1 answer


We have answered this question through significant further research. After detailed testing, it became clear: 1) On all systems tested, the audio amplitude output is almost ideally 1: 1 linear to the input when headphones are used, regardless of other settings. This is true for multiple browsers, multiple devices, iOS, Android, OSX, multiple powered and non-powered earbuds and earbud headphones. 2) In many systems / settings / volume levels, the audio amplitude output is not 1: 1 linear to the input when using an external speaker. Instead, the sound is often linear with a slope of less than 1, often significantly less (eg 1/2). In addition to this slope, many systems also saturate at higher volume levels. This is due to the factthat compensation mechanisms are used with external speakers.



So the correct answer is: the audio output amplitude created using HTML5 / javascript audio is almost 1: 1 linear compared to the input as long as headphones are used. This is not nearly 1: 1 compared to the input when external speakers are used on many public devices.

+2


source







All Articles