Skip to main content

bandcheck

Find audio files whose real frequency range is lower than their sample rate claims.

A file saved as "48 kHz WAV" may hold audio that was recorded at 16 kHz and upsampled, or that went through an MP3 or AAC encoder before being converted back. Everything above the source's limit is empty. A header never shows this. bandcheck measures where the sound really stops and tells you which files hold much less than they claim.

Status: alpha (0.1.0). Tested on generated audio, real speech recordings (LibriSpeech dev-clean), and 44.1 kHz studio music (MUSDB18-HQ). Run scripts/real_data_check.py (see docs/REAL_DATA_CHECK.md) on your own data.

Install

pip install --pre bandcheck      # after it is published; until then: pip install -e ".[dev]"

Needs Python 3.9+. Depends only on numpy, scipy, soundfile.

Use

bandcheck check my_dataset/                        # every audio file in the folder
bandcheck check clip.wav
bandcheck check my_dataset/ --need-hz 8000 --out verdicts.csv

Options: --need-hz N (fail files whose sound stops below N Hz, e.g. 8000 for a 16 kHz speech model), --show-pass, --jobs 4, --out file.csv. The report ends with a table by sample rate (files, how many are flagged, median cut-off), so you see at once that, for example, one rate holds most of the problem files.

What the verdicts mean

verdict meaning exit code
PASS no sharp cut-off, or the sound reaches at least 90% of the way to the Nyquist frequency (or 19.5 kHz) 0
WARN sound stops at 60-90% of the way to Nyquist. Typical of an MP3/AAC lowpass or a source one step lower in rate 0
FAIL sound stops below 60% of the way, or below the --need-hz you asked for. Typical of upsampled audio 1
REVIEW too short, silent, or too few loud parts to measure 0
ERROR file could not be read 0

For WARN and FAIL it lists the likely causes, for example upsampled from 16000 Hz or a lossy encoder's lowpass (MP3/AAC). One cut-off frequency cannot tell an upsampled file from a lossy encode, so every candidate is listed and you decide.

How it works (short)

  1. Reads the file at its own sample rate (no resampling) and averages the channels.
  2. Averages the power spectrum over the loud parts (frames within 30 dB of the loudest).
  3. Looks for the sharpest drop in that average: the level just below a frequency compared with the level just above it. A drop of 25 dB or more, with nothing coming back above it, counts as a cut-off. The cut-off is reported where the level has fallen 10 dB.
  4. Compares the cut-off with the Nyquist frequency of the file.

What has been measured

1. Real Speech Audio (LibriSpeech dev-clean, 200 files)

  • Original recordings:
    • 185 PASS, 11 WARN, 1 FAIL, 3 REVIEW, 0 ERROR.
    • Flagged files exhibited genuine hardware or codec lowpass cut-offs (e.g. 4.8 kHz cut-off on 7850-286674-0017.flac, 7.0–7.1 kHz on audiobook recordings).
  • Planted upsampling test (185 files evaluated):
    • From 8 kHz: 185 / 185 flagged as FAIL (median detected cut-off ratio: 1.03).
    • From 11.025 kHz: 185 / 185 flagged as WARN (median detected cut-off ratio: 1.05).
    • Detected cut-off sat within 3–5% of the source Nyquist frequency (consistent with resampling anti-aliasing filter transition).

Spectrogram Verification

2. Real 44.1 kHz Studio Music (MUSDB18-HQ, 200 files)

  • Original recordings:
    • 197 PASS (98.5%), 2 WARN, 0 FAIL, 1 REVIEW, 0 ERROR.
    • Flagged originals: 2 files (other.wav at 19.1 kHz, drums.wav at 19.3 kHz, both at 87% of 22.05 kHz Nyquist).
  • Planted upsampling test (197 files evaluated):
    • From 8 kHz: 191 / 197 flagged as FAIL (median ratio 1.02).
    • From 11.025 kHz: 185 / 197 flagged as FAIL (median ratio 1.05).
    • From 16 kHz: 162 / 197 flagged as FAIL (median ratio 1.10).
  • Planted MP3 encodes:
    • 64 kbps: 171 / 197 flagged, median cut-off 11.1 kHz.
    • 128 kbps: 157 / 197 flagged, median cut-off 16.5 kHz.

3. Synthetic Audio & Bug Injection

  • Full-band audio at 16, 22.05, 44.1 and 48 kHz: no cut-off found, PASS.
  • Audio lowpassed at 16, 19 and 20 kHz (44.1 and 48 kHz files) and 6-7 kHz (16 kHz files): cut-off found within 2% of where it was put.
  • Audio upsampled from 8, 11.025, 16, 22.05 and 24 kHz: flagged every time; the cut-off sits about 4-11% above the source's Nyquist frequency, because resampler filters roll off a little past it.
  • MP3 copies made with ffmpeg (mono): 64 kbps gave a cut-off near 16.6 kHz (WARN); 128, 192 and 256 kbps gave about 20.1 kHz (PASS).
  • 79 tests pass. 25 deliberately planted bugs in the code were each caught by the tests (5 needed a stronger test first).

Limits (read these)

  • Defaults and thresholds: The 25 dB drop, the 90% and 60% limits and the 19.5 kHz rule are judgement defaults set on generated audio; on 200 LibriSpeech dev-clean files, 12 were flagged (11 WARN, 1 FAIL), and caught 370 of 370 planted copies (from 8 and 11.025 kHz sources).
  • Cannot tell upsampled from lossy-encoded from one number, and cannot tell either from a recording that really was made with a limited microphone or filter. It reports where the sound stops, not why.
  • Gradual roll-offs are not detected. A gentle filter with no sharp edge, or dull-sounding music, passes.
  • Cut-offs below 2.5 kHz are not looked for. Speech and music change a lot there.
  • A quiet recording or one with long silences is judged on its louder parts only.
  • The channels are averaged, so a file with one full-band channel and one band-limited channel passes.
  • It tells you the bandwidth, not whether the audio is good.

Licence

MIT.

Metadata

Release files for bandcheck 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bandcheck 0.1.0
File Size Uploaded Provenance Actions
bandcheck-0.1.0.tar.gz 17.0 kB Without provenance Details for bandcheck-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bandcheck 0.1.0
File Interpreter ABI Platform Actions
bandcheck-0.1.0-py3-none-any.whl Python 3 none any Details for bandcheck-0.1.0-py3-none-any.whl

Total release size: 28.8 kB

Release files / bandcheck-0.1.0.tar.gz

Download URL bandcheck-0.1.0.tar.gz
Size 17.0 kB
Tags Source
SHA-256 checksum
How to use checksums
84731ba98700f449950ad88696758acfa3acfbea824673a97fcf370681731f8c
BLAKE2b-256 checksum
How to use checksums
3709bdc3bc8e65f85aa709088b97bc4df9dce88abfbe59412610090c524f2fe7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / bandcheck-0.1.0-py3-none-any.whl

Download URL bandcheck-0.1.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4dcd6c9609538ffac8b7ce8f6374a62811a4e4fda779653d4bdc2da1c4baba0f
BLAKE2b-256 checksum
How to use checksums
6424d19c1c4873e989be57aecfa8e1dfc44fcc19220cec3cc1262b7363de52e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Security for bandcheck 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page