πŸ“Š SNR Tutorial
Step 1 of 10

Signal-to-Noise Ratio

Learn to measure audio quality in 10 minutes.

What you'll learn

β†’ What SNR actually measures

β†’ The math behind decibels

β†’ A critical bug in common implementations

β†’ How to estimate SNR from real audio

What is a Signal?

A signal is what you want to hear. Let's create a 440 Hz tone (musical note A).

Time β†’ Pure Signal (440 Hz)
πŸ’‘ Notice the clean, regular wave pattern. This is a pure tone with no interference.

What is Noise?

Noise is what you don't want to hear. It's randomβ€”no pattern, unpredictable.

Time β†’ Random Noise
πŸ’‘ Noise has no repeating pattern. It sounds like static or hiss.

The Reality: Mixed Audio

In the real world, you hear signal + noise combined. Use the slider to see how noise affects the signal.

Noise Level 30%
⚑ Key insight: You only observe the mixed signal. The challenge is figuring out how much is signal vs noise!

The Math: Power & Decibels

SNR measures the ratio of signal power to noise power.

SNR = 10 Γ— log₁₀(Psignal / Pnoise) dB
What is Power?

Power = average of squared values

P = mean(xΒ²)
Why Decibels?

Ratios can be huge (10x, 100x, 1000x). dB compresses the scale.

Quick Reference
30 dB 1000Γ— Excellent
20 dB 100Γ— Good
10 dB 10Γ— Poor
0 dB 1Γ— Signal = Noise

Interactive SNR Calculator

Adjust the signal and noise levels to see how SNR changes.

Signal Amplitude 1.0
Noise Amplitude 0.3
Psignal = 0.500 Β· Pnoise = 0.045 Β· Ratio = 11.1Γ—
10.5 dB
Signal-to-Noise Ratio
POOR

πŸ› The Critical Bug

Here's code found in production systems. Can you spot the bug?

def calculate_snr(audio, noise):
    signal_power = mean(audio ** 2)  # ← THE BUG
    noise_power = mean(noise ** 2)
    return 10 * log10(signal_power / noise_power)

Real-World Estimation

In practice, you only have the mixed audio. How do you estimate SNR?

πŸ’‘ The Key Insight

Speech has pauses. Music has quiet moments. During silence, you only hear noise!

β–  Red = noise only β–  Blue = signal + noise
The Percentile Method
  1. Split audio into short frames (25ms each)
  2. Calculate energy of each frame
  3. Find frames with lowest energy (bottom 10%)
  4. These are your "noise frames"
  5. Estimate noise power from these frames
⚠️ Limitation: This fails for continuous signals with no pauses!

Quick Quiz

Test your understanding with 3 questions.

Q1 OF 3

Signal power = 0.5, Noise power = 0.005. What is the SNR?

πŸ“‹ Quick Reference

THE FORMULA
SNR = 10 Γ— log₁₀( (Ptotal - Pnoise) / Pnoise )
⚠️ Use (total - noise), not just total
Quality Thresholds
β‰₯ 30 dB EXCELLENT Studio recording
β‰₯ 20 dB GOOD Clear phone call
β‰₯ 15 dB ACCEPTABLE Office background
β‰₯ 10 dB POOR Noisy environment
< 10 dB VERY POOR Hard to understand
Key Takeaways

β†’ SNR = ratio of signal power to noise power (in dB)

β†’ Every +10 dB = 10Γ— more signal power

β†’ Common bug: using (S+N)/N instead of S/N

β†’ Estimate noise from quiet frames (percentile method)

πŸŽ‰

Tutorial Complete!

You've mastered the fundamentals of SNR.

3/3
Quiz Score
You now understand:

βœ“ What SNR measures and why it matters

βœ“ The math behind power and decibels

βœ“ The critical bug in common implementations

βœ“ How to estimate SNR without ground truth

Done