Skip to content

SpectrogramConfig

type SpectrogramConfig = object;
PropertyTypeDescription
autoRender?booleanWhether to automatically re-render when viewport or configuration changes. Default true
autoResize?booleanWhether to automatically resize canvas pixel resolution when container dimensions change. Default true
backend?BackendModeSTFT compute execution backend: - “auto”: Prefers WebAssembly workers, falling back to main thread. - “wasm”: Fast WebAssembly computation. - “worker”: Web Worker background thread computation. - “main-thread”: Synchronous main thread computation. Default "auto"
channel?numberAudio channel index to analyze (0 for left/mono, 1 for right). Default 0
clampValues?booleanWhether to clamp intensity values strictly within [minDb, maxDb]. Default true
colorMap?ColorMapConfigColormap palette name (such as “inferno”, “viridis”, “magma”, “turbo”) or custom palette object. Default "viridis"
devicePixelRatio?boolean | numberDevice pixel ratio scaling factor for HiDPI/Retina displays. Default window.devicePixelRatio
fftSize?numberFFT length in samples. Must be a power of two >= windowSize. Spectral magnitudes contain the first fftSize / 2 bins, normalized by fftSize, without one-sided or window coherent-gain compensation. Default 1024
frequencyScale?FrequencyScaleFrequency scale mapping: “linear”, “mel”, or “log”. Default "linear"
hopSize?numberHop size (step length) in samples between consecutive FFT frames. Default 256
maxCachedBytes?numberMaximum estimated bytes retained by the computed tile cache.
maxCachedTiles?numberMaximum number of computed STFT tiles retained in memory cache. Default 64
maxDb?numberUpper intensity limit mapped to the end of the colormap (in dB when valueMode is “db”). Default 0
minDb?numberLower intensity limit mapped to the start of the colormap (always specified in dB; converted internally for non-dB value modes). Default -100
prefetchTiles?numberNumber of tiles to prefetch and compute ahead of the visible viewport. Default 8
renderer?RendererModeRendering engine: - “auto”: Uses WebGL2 if supported, falling back to Canvas 2D. - “webgl” / “webgl2”: Hardware-accelerated GPU shader renderer. - “canvas2d”: CPU Canvas 2D fallback renderer. - Custom object with shader program (`{ type: “webgl”, program: “normal”
showLoadingPlaceholders?booleanWhether to draw loading placeholders over tiles that are still computing.
tileMaxCells?numberMaximum 2D STFT matrix cells (frameCount * binCount) budgeted per computation tile. Default 131_072
transforms?SpectrogramTransform[]Array of custom matrix transforms applied to STFT data before rendering. Default undefined
valueGamma?numberPower-law gamma exponent for dynamic range contrast adjustment. Default 1.0
valueMode?ValueModeIntensity scale representation: “db” (decibels), “magnitude”, or “power”. dB values use 20 * log10(max(magnitude, 1e-12)). Default "db"
window?WindowNameWindow function applied before FFT: “hann”, “hamming”, “blackman”, or “rectangular”. Default "hann"
windowSize?numberSTFT analysis window length in audio samples. Default 1024