简体   繁体   中英

Web audio oscillator extremely loud?

Is it just me or does the oscillator sound crazy loud even at 0.5 gain? I cant increase my computers volume more than 5%.

Now the volume seems "normalized" when I set the gain to 0.001 but that cant be right? I would appreciate some insight for controlling the volume of the oscillator.

var audioCtx = new AudioContext();

var oscillatorNode = audioCtx.createOscillator();
var gainNode = audioCtx.createGain();

oscillatorNode.connect(gainNode);
gainNode.connect(audioCtx.destination);

oscillatorNode.type = 'sine';
oscillatorNode.frequency.value = 500;
gainNode.gain.value = 0.5;

oscillatorNode.start();

I can't repro any extreme loudness. With gainNode.gain.value at 1.0, I get a clean sine which is not overly loud. Raising the gain over 1 makes the sine wave clip, as expected. Lowering the gain to 0.001 makes the wave practically inaudible.

There's probably something else going on with your machine, if it's "crazy loud".

I managed to reproduce it by having "Loudness Equalization" enabled on my speakers enhancements (I'm using Windows 10). You probably have an audio effect being applied to your speakers' out.

The solution: disable all audio enhancements/effects from your speakers (specially Loudness Equalization that mess up with the amplitudes hence the volume).

Audio enhancements can also be found on headset drivers trying to optimize users experience of the headset.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM