export interface ClipDcStats { peak: number; rms: number; /** Mean sample value (full scale = 1). */ dc: number; /** Fraction of samples sitting in clipping flats (>= 3 identical consecutive samples with a knee) at full scale or at the file's own peak. */ clipFraction: number; /** Longest such run, in samples. */ clipRun: number; /** Total samples in those runs. */ clipSamples: number; /** `full-scale` = the converter's rails; `peak-flat` = flat at the file's own (attenuated) peak, i.e. clipped then turned down. */ clipKind: 'full-scale' | 'peak-flat' | 'none'; } export declare function clipDcStats(samples: Float64Array): ClipDcStats; export interface LadderRung { /** The rpm label the rung was authored at. */ rpm: number; /** The firing fundamental that label implies (Hz). */ f0: number; samples: Float64Array; sampleRate: number; } /** A centred slice of at most `seconds`, so a long file costs the same as a short one. */ export declare function centre(samples: Float64Array, sr: number, seconds: number): Float64Array; export declare function removeMean(samples: Float64Array): Float64Array; /** * The rung's spectral envelope as the dB of its own firing harmonics (k·f0, ±1.5 %), interpolated onto a log-frequency * grid over 300 Hz .. 6 kHz with the broad tilt removed. This is the shape the engine's resonators impose on whatever * pitch the rung happens to play. Null when the rung has too few harmonics in range to define one. */ export declare function harmonicEnvelope(samples: Float64Array, sr: number, f0: number): Float64Array | null; export interface FormantConstancy { /** Mean correlation of the harmonic envelopes of rungs at least 1.5x apart in rpm. ~0 for real recordings. */ meanFarCorrelation: number; rungs: number; pairs: number; } /** * Is one fixed resonator stack stamped on every rung? In a real engine the radiated spectrum changes with rpm and * load, so the detrended harmonic envelope of a 1,000 rpm rung and a 5,000 rpm rung do not line up: mean far-pair * correlation 0.05 (Porsche 993), -0.03 / 0.09 (BeamNG F355 engine / exhaust). A synthesised ladder built from fixed * formants has the SAME peaks and notches at the same absolute Hz on every rung: the round-8 F40 measured 0.64-0.73 * across its four ladders (and a synthetic 300 SL engine ladder 0.82). */ export declare function ladderFormantConstancy(rungs: readonly LadderRung[]): FormantConstancy | null; export interface FixedTone { hz: number; /** Rungs in which a prominent off-comb line sits at this absolute frequency. */ rungs: number; total: number; } /** * Narrowband lines at the SAME absolute frequency in most rungs while the firing fundamental moves: a fixed oscillator * or resonator ring mixed into every rung. Lines that are harmonics of a rung's own f0 are ignored (those move with * rpm). Real recordings top out at 5 of 15 rungs (F355 exhaust, ~1,070 Hz); clusters are ±1.2 % wide. */ export declare function ladderFixedTone(rungs: readonly LadderRung[]): FixedTone | null; /** Band-limit to 60-900 Hz with the FFT, then take every M-th sample (~2 kHz). The aperiodic content lives here. */ export declare function bandLimitDecimate(samples: Float64Array, sr: number): { x: Float64Array; fs: number; }; /** * The aperiodic part of a decimated signal: a central power-of-two segment, Hann windowed, with every spectral line * (a bin more than 3x the 100 Hz running mean power, plus two bins either side) removed. What is left is the flow * noise and cycle-to-cycle wander that identify one particular take; a resampled copy carries the same residual, * an independently recorded or synthesised rung carries a different one. */ export declare function residual(x: Float64Array, fs: number): Float64Array; /** Max normalised cross-correlation over lags with at least half of the shorter signal overlapping. */ export declare function maxNcc(a: Float64Array, b: Float64Array): number; /** B(t) = A(rho·t): `a` sampled at `fsa`, resampled onto a `fsb` time base. */ export declare function warp(a: Float64Array, fsa: number, fsb: number, rho: number): Float64Array; export interface RungCopy { lowRpm: number; highRpm: number; /** Peak normalised correlation of the aperiodic residuals after undoing the pitch change (1 = a pure resample). */ score: number; /** The playback ratio that best aligned them. */ ratio: number; } /** * Is one rung a time-stretched (resampled) copy of its neighbour? Compares the aperiodic residuals after warping the * lower rung by the rpm ratio (searched ±4 % around the label ratio, coarse then fine). A pure resample scores * 0.9-1.0; independent rungs, recorded or synthesised, score ≤ 0.52 on every real ladder measured (993, F355 engine * and exhaust) and on the F40 (≤ 0.35 outside the real-recording ceiling). Adjacent rungs only. */ export declare function ladderResampledCopies(rungs: readonly LadderRung[]): RungCopy[]; export interface HornVerdict { periodic: boolean; /** Max normalised autocorrelation of the steady middle; 1.0000 = a sample-exact loop of one cycle. */ autocorrMax: number; lines: number; why: string | null; } /** * A horn recorded from a real car has pitch jitter, amplitude shimmer and a noise floor, so its waveform never repeats * exactly: autocorrelation 0.97-0.98 on the platform's recorded horns and 0.85-0.99 on other horns that pass. A * synthesised two-tone horn built from sines repeats to the last sample: the F40 horn measured 1.0000. Judged on the * steady middle of the file, so the attack and release do not read as a noise floor. (A two-tone horn is nearly * periodic by nature, so the verdict is a warning, not a refusal.) */ export declare function judgeHorn(samples: Float64Array, sr: number): HornVerdict; /** * The runtime re-fires the `revLimiter` slot every `REV_LIMITER_INTERVAL_S` (0.06 s, `VehicleAudio#updateLimiter`) for * as long as the car sits on its limiter: the fuel-cut stutter IS that retrigger. So the sample has to be a short crack * (a platform limiter is 0.1-0.2 s). A long sustained clip is stacked into a held tone: a 1.6 s clip puts about 27 * copies in the air at once, and whatever stutter was authored inside it is smeared away. Judged on the length the * retrigger gives it: voices stacked = duration / interval. */ export declare const REV_LIMITER_INTERVAL_S = 0.06; export declare const REV_LIMITER_WARN_S = 0.2; export declare const REV_LIMITER_ERROR_S = 0.35; export interface LimiterVerdict { durationS: number; /** Copies of the sample playing at once while the car holds the limiter. */ stackedVoices: number; /** Strongest 8-30 Hz amplitude-modulation component inside the clip itself, Hz (0 when the clip is too short to hold a cycle). */ cutHz: number; /** Peak-to-trough depth of that cut in dB (0 when none). */ cutDepthDb: number; level: 'ok' | 'warn' | 'error'; } export declare function judgeRevLimiter(samples: Float64Array, sr: number): LimiterVerdict;