If you are building a web app that records or processes sound, one concept you should know is Signal to Noise Ratio (SNR). It might sound like an audio engineering term, but in practice it is simple.
SNR tells you how much useful sound you are getting compared to the unwanted noise around it. Think of someone talking in a quiet room versus someone trying to talk in a busy café. In the first case, the voice stands out clearly. In the second, the background competes with the speech. That difference is SNR.
Why SNR Matters for Web Developers
If your app relies on microphones, SNR directly impacts:
- Voice calls or meetings: Poor SNR makes conversations hard to follow.
- Recording apps: Background hum and chatter reduce clarity and accuracy, especially if you use speech to text services.
- Music or podcasts: High SNR means recordings sound professional with minimal cleanup.
In other words, the higher the SNR, the clearer the audio experience for your users.
Improving SNR in the Browser
You cannot always control the user’s environment, but you can help improve SNR with a few tools available in web APIs.
1. Use getUserMedia()
with audio constraints
Modern browsers let you request noise reduction features when you access the microphone.
const constraints = {
audio: {
noiseSuppression: true,
echoCancellation: true,
autoGainControl: true
}
};
navigator.mediaDevices.getUserMedia(constraints)
.then(stream => {
const audio = document.querySelector("audio");
audio.srcObject = stream;
})
.catch(err => console.error("Could not access microphone", err));
Here, the browser automatically reduces background sounds and adjusts levels to make the voice clearer.
2. Use the Web Audio API to filter sound
Once you have the audio stream, you can apply filters. For example, a simple high-pass filter removes low rumbles like air conditioners or traffic:
const audioContext = new AudioContext();
const source = audioContext.createMediaStreamSource(stream);
const filter = audioContext.createBiquadFilter();
filter.type = "highpass";
filter.frequency.value = 100;
source.connect(filter).connect(audioContext.destination);
This gives your app more control over the audio quality without requiring users to install special software.
3. Guide the user
Sometimes, the best way to improve SNR is not technical. If you detect low input levels or heavy background noise, show a simple message asking the user to move to a quieter place or use headphones with a microphone.
What Counts as Good SNR?
You do not need to worry about numbers when explaining this to users. Think of it like this:
- If the voice is much clearer than the noise, the SNR is good.
- If the noise and the voice are competing, the SNR is poor.
For calls, “good enough” usually means the conversation is easy to follow. For music and podcast recording, the standard is much stricter, and you want the cleanest possible capture.
Wrapping Up
Signal to Noise Ratio is simply a measure of how clean an audio signal is compared to the background. For web developers, the important takeaway is that you can influence SNR by using audio constraints in getUserMedia
, applying filters with the Web Audio API, and helping users set up their environment.
With these techniques, your app can deliver clearer calls, better recordings, and a smoother experience for anyone relying on the browser to capture audio.
If you're a software developer who enjoys exploring different technologies and techniques like this one, check out LiveReview.
LiveReview delivers high-quality feedback on your PRs/MRs within minutes.
It saves hours per review by providing fast, automated first-pass insights. This helps both junior and senior engineers move faster.
If you're tired of waiting on peer reviews or unsure about the quality of feedback you'll receive, LiveReview is here to help.
Top comments (0)