Audio Clip Peak Detector (components/clipPeakRuns.ts)

WizardofTryout/hyperframes · packages/studio/src/player/components/clipPeakRuns.ts · typescript · Apache-2.0
automation, voice, tag:clipping, tag:peak, tag:detection, tag:utils

Identifies contiguous regions where audio exceeds export ceiling, merging adjacent hot bins and reporting peak levels.

// Source: https://github.com/WizardofTryout/hyperframes | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import { EXPORT_PEAK_CEILING } from "../../utils/exportPeakCeiling";

export interface PeakMap {
  binSeconds: number;
  bins: number[];
}

export interface ClipSourceWindow {
  mediaStart: number;
  sourceSpan: number;
}

export interface ClipPeakMarkRuns {
  runs: Array<{ from: number; to: number }>;
  peakDbfs: number | null;
}

/**
 * Where, as fractions of the clip, its source at the clip's own gain reaches the
 * export ceiling, and the loudest point when it does. Adjacent hot bins merge.
 */
export function clipPeakRuns(
  map: PeakMap,
  window: ClipSourceWindow,
  gain

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key