Skip to content

Instantly share code, notes, and snippets.

@DuaneNielsen
Created March 9, 2026 01:25
Show Gist options
  • Select an option

  • Save DuaneNielsen/8b8348cb2e960696db3ee998df1679e6 to your computer and use it in GitHub Desktop.

Select an option

Save DuaneNielsen/8b8348cb2e960696db3ee998df1679e6 to your computer and use it in GitHub Desktop.
Live audio metrics monitor for PipeWire/PulseAudio mic input
#!/bin/bash
# Live audio metrics from the Yeti Nano mic
# Usage: mic-monitor.sh [duration_seconds] (default: 10)
DURATION="${1:-10}"
SOURCE="alsa_input.usb-Blue_Microphones_Yeti_Nano_2538SQ903SB8_888-000476140506-00.analog-stereo"
echo "Recording $DURATION seconds from Yeti Nano..."
echo
ffmpeg -f pulse -i "$SOURCE" -t "$DURATION" -af "astats=metadata=1:reset=0.5,ametadata=print:key=lavfi.astats.Overall.RMS_level:file=-:direct=1,ametadata=print:key=lavfi.astats.Overall.Peak_level:file=-:direct=1,ametadata=print:key=lavfi.astats.Overall.Flat_factor:file=-:direct=1" -vn -f null /dev/null 2>/dev/null | \
awk -F= '
/RMS_level/ { rms=$2; rms_sum+=$2; rms_n++; if(rms_min=="" || $2<rms_min) rms_min=$2; if($2>rms_max) rms_max=$2 }
/Peak_level/ { peak=$2; if(peak_max=="" || $2>peak_max) peak_max=$2; if($2 >= -0.1) clips++ }
/Flat_factor/ {
printf "\r RMS: %7.1f dB | Peak: %7.1f dB | Max Peak: %7.1f dB | Clips: %d ", rms, peak, peak_max, clips+0
}
END {
printf "\n\n"
printf "=== Summary ===\n"
printf " Avg RMS: %7.1f dB\n", (rms_n>0 ? rms_sum/rms_n : -999)
printf " RMS range: %7.1f to %.1f dB\n", rms_min, rms_max
printf " Max Peak: %7.1f dB\n", peak_max
printf " Clips: %d\n", clips+0
if (peak_max > -1) printf " ⚠ CLIPPING DETECTED\n"
else if (peak_max > -6) printf " ⚠ Hot - consider reducing gain\n"
else if (peak_max > -20) printf " ✓ Good levels\n"
else printf " ⚠ Quiet - consider increasing gain\n"
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment