npm API reference
Function signatures, processing options, reports, and errors for the sidespread npm package.
init(input?)
TypeScriptfunction init(input?: unknown): Promise<void>;
Initializes the browser WASM module. The Node entry accepts the same call as a resolved no-op. Call
and await it once before using analyze, process, or version.
version()
TypeScriptfunction version(): string;
Returns the Rust crate and npm package version embedded in the WASM module.
analyze(audio, sampleRate, options?)
TypeScriptfunction analyze( audio: Float32Array, sampleRate: number, options?: ProcessOptions): EngineReport;
Runs missing-band and shared-bandwidth detection without changing the samples. Artifact stages are not counted as analysis findings.
process(audio, sampleRate, options?, onProgress?)
TypeScriptfunction process( audio: Float32Array, sampleRate: number, options?: ProcessOptions, onProgress?: (event: ProcessProgress) => void): { audio: Float32Array; report: EngineReport };
Runs the complete non-neural chain: missing-band DSP, shared bandwidth extension, harmonic debleed, high-frequency smearing repair, phase stabilization, fidelity gates, and headroom control.
The optional callback runs synchronously on the processing thread and receives events emitted at real Rust pipeline boundaries:
TypeScriptinterface ProcessProgress { stage: | 'prepare' | 'analyze' | 'missingBand' | 'bandwidth' | 'artifacts' | 'finalize' | 'complete'; progress: number; // 0 to 1}
Use the callback inside a Web Worker for long files, then forward each event to the main thread.
Channel helpers
TypeScriptfunction interleave(left: Float32Array, right: Float32Array): Float32Array;function deinterleave(audio: Float32Array): { left: Float32Array; right: Float32Array;};
interleave() requires equally sized channels. deinterleave() requires an even sample count.
ProcessOptions
All properties are optional. Unknown properties throw instead of being ignored.
| Property | Default | Range or meaning |
|---|---|---|
fc | 8000 | Historical high-frequency metric cutoff in Hz |
scanStartHz | 5000 | Lowest dynamically inspected frequency |
rhfThreshold | 0.3 | Absolute Side/Mid deficiency ceiling |
rhfRelativeThreshold | 0.18 | Threshold relative to the intact Side band |
corrHigh | 0.35 | Intact-band correlation threshold |
corrLow | 0.40 | Transition-band correlation threshold |
transitionRhfMin | 0.001 | Minimum transition Side/Mid energy |
dspStrength | 2.0 | Missing-band synthesis strength, 0-3 |
dspPhaseDegrees | 60 | Maximum phase diffusion, 0-180 |
bandwidthExtension | true | Detect and extend a shared hard cutoff |
bandwidthDropDb | -30 | Hard-cutoff threshold, -80 to -12 dB |
bandwidthStrength | 0.85 | Shared extension strength, 0-2 |
bandwidthRolloffDbPerOctave | 3 | Synthesized high-band rolloff, 0-24 |
repairSmearing | true | Enable high-frequency transient repair |
smearingStrength | 0.35 | Smearing repair amount, 0-1 |
repairBleeding | true | Enable harmonic debleed |
bleedingStrength | 0.65 | Debleed amount, 0-1 |
stabilizePhase | true | Enable Side phase stabilization |
phaseStrength | 0.50 | Phase stabilization amount, 0-1 |
segmentMs | 80 | Detection segment length in milliseconds |
overlap | 0.5 | Segment overlap, 0 inclusive to 1 exclusive |
nFft | 4096 | STFT FFT size |
hop | 1024 | STFT hop size, no greater than nFft |
EngineReport
TypeScriptinterface EngineReport { sampleRate: number; inputFrames: number; needsProcessing: boolean; processed: boolean; missingBand: MissingBandReport; bandwidth: BandwidthReport; artifacts: ArtifactReport; outputGainDb: number; synthesisMix: number; segments: SegmentReport[];}
needsProcessing records detected deficiencies and requested artifact work. processed is stricter:
it is true only when the output includes an applied stage.
Missing band
missingBand contains detectedSegments, routedSegments, multiBandSegments,
lowestDefectHz, scanStartHz, and the fixed bandWidthHz of 500 Hz.
Shared bandwidth
bandwidth contains detectedCutoffHz, tailToEdgeDb, confidence, and needsExtension.
Artifact stages
Each artifact entry exposes enabled, requested strength, safety-gate retainedMix, and final
appliedStrength. The entries are smearing, harmonicBleeding, and phaseIncoherence.
Errors
Calls throw for empty or odd-length audio, non-finite samples, unsupported sample rates, invalid option ranges, unknown options, invalid progress callbacks, and calls made before browser initialization.