Audio Declip / Overload Repair
Un-chopping clipped peaks before FlashSR makes them worse
- audio
- audio
- declip_json
- info
Sometimes MiniMax Music 3 hands you a track that looks like a tablesaw blade: the peaks hit near zero and sit there, flat on top. That's hard clipping, and it's the worst possible thing to feed into a super-resolution stage, because FlashSR will happily sharpen those chopped corners into buzzing, grating distortion. Audio Declip / Overload Repair is the safety net you put between the generator and the enhancer. It finds short near-ceiling flat-topped regions and rebuilds plausible peak curvature before FlashSR can exaggerate them.
The name overpromises slightly. Digital clipping destroys information - the node can't recover what's gone, only reconstruct a plausible curve. That's the whole design philosophy of this pack: conservative, batch-safe, and honest about limits. It's not a compressor, not a limiter, and it won't add "vibe." It quietly makes the source a better starting point.
Where it sits
This is the first audio stage in the pack's production chain: generated audio → declip repair → PRE low-pass → FlashSR → hybrid crossover → HF repair → POST low-pass → release prep. The README calls it a "conservative reconstruction" stage. Run it before any filtering or resampling, right after the MiniMax output node.
How it works
The node scans each channel for near-ceiling plateaus: regions where the sample-to-sample change stays below plateau_tolerance_percent of the channel peak, at or above detection_threshold_percent of it. Short enough plateaus get the missing curvature rebuilt with cubic-Hermite interpolation, using the slope_context_samples of clean audio around each region to estimate entry and exit slopes. Then one optional whole-track safety gain brings the result under output_ceiling_dbfs - a single constant gain, never a limiter and never time-varying. That's a deliberate choice; this pack refuses to secretly pump your level.
Inputs that matter
The default Auto / conservative mode is what you want for unattended batches. It only repairs strong, short plateau evidence and leaves ordinary rounded peaks alone. The other modes exist for when you've actually listened and diagnosed something:
- Analyze only - the underrated one. It runs detection and reports what it found without changing a sample. Use this first if you're not sure your source is even clipped.
- Standard / Strong - wider detection, longer repairs, more aggressive. Strong will reshape merely limited peaks, which is why the tooltip warns you off it.
- max_repair_ms (default 8 ms) - the ceiling on how long a clipped region it's willing to rebuild. Longer flat tops carry too little information, so they're skipped and counted. Don't raise it unless you can actually hear long hard-clipped crests.
- mix - wet/dry blend, useful when a repair sounds too "reconstructed." Going below 1.0 also blends clipping distortion back in, so it's a compromise, not a free lunch.
Outputs are audio, plus two STRINGs: declip_json (a JSON report of detection, repaired/skipped regions, effective parameters) and info. Wire the JSON into MiniMax Song Metadata later if you want it in the reproducibility sidecar.
Installing it
This is one node in Johannes Plenio's MiniMax Music Production Toolkit. ComfyUI Manager (search "MiniMax Music Production Toolkit") is the easy path; manually:
cd ComfyUI/custom_nodes
git clone https://github.com/jplenio/ComfyUI-MiniMax-Music-Production-Toolkit.git
cd ComfyUI-MiniMax-Music-Production-Toolkit
python -m pip install -r requirements.txt
Use the same Python that runs ComfyUI. The package needs scipy, soundfile, imageio-ffmpeg, mutagen and Pillow - no model weights are bundled. Restart ComfyUI and hard-refresh the browser once.
Gotchas
If nothing seems to change, you're probably feeding it audio that isn't hard-clipped - check Analyze only first. Long flat tops get skipped by design, so a track that's clipped in big blocks won't fully "unclip." And remember the honest caveat from the docs: reconstruction is plausible, not exact. If your source is genuinely mangled, nothing this pack ships will fully fix it - but this node keeps FlashSR from turning the damage into something worse.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| audio | AUDIO | Original MiniMax/source audio before FlashSR processing. The node searches this signal for near-ceiling flat-topped regions and reconstructs plausible peak curvature before later enhancement stages can exaggerate clipping distortion. | |
| mode | COMBO | Auto / conservative | De-clipping preset. Auto / conservative repairs only strong near-peak plateau evidence and is recommended for unattended batches. Standard widens detection and allows longer repairs. Strong is intentionally aggressive and may alter merely limited peaks. Custom uses the visible values exactly. Analyze only reports clipping without changing audio. Bypass performs no analysis or repair. |
| detection_threshold_percent | FLOAT | 98.085–99.99 | Lower edge of the region considered for peak reconstruction, expressed as a percentage of each channel's own maximum absolute sample peak. Lower values replace a wider portion around each clipped crest and can smooth harsher clipping, but values that are too low may reshape legitimate loud transients. Used exactly in Custom/Analyze only; presets show their effective value. |
| plateau_tolerance_percent | FLOAT | 0.0010.0001–1 | Maximum allowed sample-to-sample change inside a supposed flat top, expressed as a percentage of the channel peak. Very small values detect genuinely flat hard-clipping plateaus and avoid mistaking naturally rounded sine/bass peaks for clipping. Larger values also catch slightly processed/rounded clipping but raise false-positive risk. |
| min_flat_samples | INT | 31–32 | Minimum length of a sufficiently flat near-ceiling plateau before the region is treated as clipping. Auto uses 3 samples to avoid reshaping ordinary smooth peaks; Standard can detect shorter two-sample flat tops. A value of 1 is extremely aggressive because any above-threshold peak can qualify. |
| slope_context_samples | INT | 32–64 | Number of clean samples outside each clipped region used to estimate entry and exit slopes for the cubic-Hermite reconstruction. More context smooths the estimate and helps low-frequency peaks; too much context can ignore a very fast transient's local shape. |
| max_repair_ms | FLOAT | 8.00.1–50 | Maximum duration of one clipped region that the node is willing to reconstruct. Very long flat tops contain too much missing information for reliable interpolation; those regions are left unchanged and counted as skipped. Increase only when the source has clearly audible long hard-clipped crests. |
| max_peak_extension_db | FLOAT | 4.00.5–12 | Safety cap on how far a reconstructed peak may rise above the detected clipping ceiling before final whole-track safety scaling. Higher values allow more natural recovery of strongly chopped peaks but also permit larger speculative overshoot. This is not a loudness boost; the output is subsequently capped with one constant gain when required. |
| output_ceiling_dbfs | FLOAT | -1.0-12–-0.1 | Sample-peak safety ceiling applied only when actual repairs create peaks above this level. The node then applies ONE constant gain to the entire track, never a limiter or time-varying gain. -1 dBFS is a safe default before FlashSR and later release processing. |
| mix | FLOAT | 1.000–1 | Wet/dry blend between the original clipped waveform and reconstructed waveform. 1.0 uses the full repair, 0.0 leaves the original unchanged. Intermediate values can soften a repair that sounds too reconstructed, but also blend some clipping distortion back in. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| audio | AUDIO | — |
| declip_json | STRING | — |
| info | STRING | — |