audiocn

useClipHold

Clip detection with a hold time, a clip count and a reset.

useClipHold powers the clip indicator. Feed it every level reading; it tells you when the signal clipped and keeps that state for a while so people can see it.

$ pnpm dlx shadcn@latest add @audiocn/use-clip-hold

Usage

const clip = useClipHold({ holdMs: 2000 });

useFrameSource(analyser.meter, (frame) => {
  clip.report(frame.channels[0]?.peakDb ?? -Infinity);
});

return clip.clipping ? <span>Clipping ({clip.count})</span> : null;

Options

Prop

Type

Returns

Prop

Type