Skip to content
Sidespread

No matching documentation.

npm API reference

Function signatures, processing options, reports, and errors for the sidespread npm package.

init(input?)

TypeScript
function 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()

TypeScript
function version(): string;

Returns the Rust crate and npm package version embedded in the WASM module.

analyze(audio, sampleRate, options?)

TypeScript
function 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?)

TypeScript
function 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:

TypeScript
interface 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

TypeScript
function 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.

PropertyDefaultRange or meaning
fc8000Historical high-frequency metric cutoff in Hz
scanStartHz5000Lowest dynamically inspected frequency
rhfThreshold0.3Absolute Side/Mid deficiency ceiling
rhfRelativeThreshold0.18Threshold relative to the intact Side band
corrHigh0.35Intact-band correlation threshold
corrLow0.40Transition-band correlation threshold
transitionRhfMin0.001Minimum transition Side/Mid energy
dspStrength2.0Missing-band synthesis strength, 0-3
dspPhaseDegrees60Maximum phase diffusion, 0-180
bandwidthExtensiontrueDetect and extend a shared hard cutoff
bandwidthDropDb-30Hard-cutoff threshold, -80 to -12 dB
bandwidthStrength0.85Shared extension strength, 0-2
bandwidthRolloffDbPerOctave3Synthesized high-band rolloff, 0-24
repairSmearingtrueEnable high-frequency transient repair
smearingStrength0.35Smearing repair amount, 0-1
repairBleedingtrueEnable harmonic debleed
bleedingStrength0.65Debleed amount, 0-1
stabilizePhasetrueEnable Side phase stabilization
phaseStrength0.50Phase stabilization amount, 0-1
segmentMs80Detection segment length in milliseconds
overlap0.5Segment overlap, 0 inclusive to 1 exclusive
nFft4096STFT FFT size
hop1024STFT hop size, no greater than nFft

EngineReport

TypeScript
interface 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.