Search code examples
javascriptaudiomicrophoneweb-audio-apidecibel

WebAudio API microphone Decibel Threshold/Gating ( Microphone input too sensitive )


sorry I can't find any information on this. Doing a personal project using WebAudio API, getting microphone input, but the sensitivity is way too high. A friend told me to research the keywords Decibel Threshold/Gating but I can't seem to find any relevent information.. Anyone have any resources? I've referenced a lot of open sourced code so keep the terminology to the minimum please, THANKS!


Solution

  • There's no way to turn down the hardware microphone gain from Web Audio API, so if it's actually clipping, the user needs to turn down the gain. You could potentially detect that it's clipping (by looking for sample values close to plus or minus 1), and ask the user to turn it down.

    If it's not clipping, but is still too loud for your purposes, you can just run it through a gain node. Or if you want to turn it down only if it's over a certain level, you can run it through a compressor node.