Nodes/MKRShift_Nodes/Audio Clipping Detector
ComfyUI Node

Audio Clipping Detector

QC your exports for clipping before anyone hears it

By criskb·Created 7 months ago·Updated 5 months ago· 0
Audio Clipping Detector
  • audio
  • clip_ranges_json
  • clipped_samples
  • clip_ratio
  • summary
clip_threshold_db-0.30
min_clip_ms1.0

Clipping is the number one amateur tell in generated-audio workflows: the voice comes back over-processed, peaks flatten against 0 dB, and the result sounds harsh and broken on speakers. You usually only notice after the file is out in the world. MKRAudioClippingDetector is a QC node - it doesn't touch your audio at all, it just tells you how badly it's clipping, and where. Think of it as the audio equivalent of a gamut-warning scope: it exists so you catch the problem inside the graph instead of in a client email.

It's part of the analysis branch of MKRShift_Nodes (the same area that ships loudness and black-frame detectors), so it slots into a finishing chain as a check before export - right after a limiter or normalization step, where clipping usually gets introduced.

How it works

The node decodes the input to a float waveform, computes the peak level of the loudest channel per sample, and flags every sample at or above your clip_threshold_db - by default −0.3 dB, i.e. anything touching digital full scale. It then groups flagged samples into contiguous runs (with a min_clip_ms floor so a single click doesn't count as a "clipping event"), and reports:

  • clip_ranges_json - a JSON array of every clipping region, with start/end sample, length, and start/end seconds. This is the useful one: wire it somewhere or read it to find where the clipping happens.
  • clipped_samples - total count of samples over threshold.
  • clip_ratio - clipped samples / total samples. A tiny ratio (0.001) is often fine; anything over a few percent is a real problem.
  • summary - JSON with sample rate, channels, threshold, and any warnings.

No output files, no MKR_AUDIO - this is a pure analysis node, so wire its outputs into string/int/float logic, a Show Text node, or use the numbers to gate a fallback in your graph.

Inputs

  • audio - the pack's MKR_AUDIO, a waveform tensor, or a file path (the * type).
  • clip_threshold_db - −24 to −0.01, default −0.3. Lower it if you want to catch "near clipping" (some people QC at −1 dB to leave headroom).
  • min_clip_ms - 0 to 1000 ms, default 1 ms. Events shorter than this are ignored; raise it to filter out transient clicks if they're not what you care about.

Install

ComfyUI Manager (search "MKRShift Nodes"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/criskb/MKRShift_Nodes

Restart. Pure numpy analysis - no ffmpeg needed at all for WAV inputs, no model downloads.

Common issues

The threshold is linear amplitude converted from dB, so "clipping" here is digital clipping - it will not catch analog-style distortion, inter-sample peaks, or loudness problems that stay under 0 dBFS. If you're hunting loudness issues instead, grab MKRLoudnessMeter from the same pack. And remember clip_ratio counts samples, not time - a sustained clipped section and a hundred short bursts can give similar ratios, which is exactly why the ranges JSON matters more than the ratio.

CategoryMKRShift Nodes/Media/Analysis

Inputs (3)

NameTypeDefaultDescription
audio*
clip_threshold_dbFLOAT-0.30-24–-0.01
min_clip_msFLOAT1.00–1000

Outputs (4)

NameTypeDescription
clip_ranges_jsonSTRING
clipped_samplesINT
clip_ratioFLOAT
summarySTRING