Skip to content

Topographic Shader

@sonoscope/topographic-spectrogram draws contour lines over your audio, making the spectrogram look like a topographic elevation map.



Terminal window
npm install @sonoscope/topographic-spectrogram @sonoscope/core

Importing the /auto path automatically registers the "topographic" renderer keyword:

import "@sonoscope/topographic-spectrogram/auto";
import { Sonoscope } from "@sonoscope/core";
const scope = await Sonoscope.fromUrl("/audio/sample.wav");
scope.createSpectrogram(canvas, {
renderer: "topographic",
minDb: -90,
maxDb: 0,
});
scope.attachNavigation(canvas);

OptionTypeDefaultWhat it does
contourIntervalnumber0.15Distance between contour rings
contourLineWidthnumber1.0Thickness of contour lines in pixels
contourLineOpacitynumber0.9Opacity of the contour lines (0 to 1)
minEnergyThresholdnumber0.14Noise floor cutoff threshold
smoothingRadiusnumber1.0Blur radius to smooth out noise before drawing lines
noiseFadeWidthnumber0.15Fade-in width above the noise floor
lineFeathernumber0.75Line edge feathering (lower is sharper, higher is softer)
speckleFilternumber1.8Threshold for suppressing subpixel noise dots
majorIntervalMultipliernumber0Make every Nth line thicker (0 to disable)
majorLineWidthnumber2.0Thickness of major index lines in pixels

Test different contour line widths, intervals, feathering, and major index lines live: