
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@e9g/spectral-display
Advanced tools
WebGPU-accelerated audio visualization for React. Renders spectrograms, waveforms, and BS.1770-4 loudness metrics from raw audio samples.
WebGPU-accelerated audio visualization for React. Renders spectrograms, waveforms, and BS.1770-4 loudness metrics from raw audio samples.

npm install @e9g/spectral-display
Peer dependencies: react >= 18, react-dom >= 18
import { useSpectralCompute, SpectrogramCanvas, WaveformCanvas, LoudnessCanvas } from "@e9g/spectral-display";
function AudioDisplay({ device, metadata, readSamples }) {
const computeResult = useSpectralCompute({
metadata,
query: { startMs: 0, endMs: 30000, width: 800, height: 200 },
readSamples,
config: { device, frequencyScale: "mel", colormap: "lava" },
});
return (
<div style={{ position: "relative", width: 800, height: 200 }}>
<SpectrogramCanvas computeResult={computeResult} />
<div style={{ position: "absolute", inset: 0 }}>
<WaveformCanvas computeResult={computeResult} />
</div>
<div style={{ position: "absolute", inset: 0 }}>
<LoudnessCanvas computeResult={computeResult} />
</div>
</div>
);
}
Pass your own GPUDevice via config.device to share it across components. If omitted, the hook acquires one automatically.
The readSamples callback provides audio data on demand:
const readSamples = (channel: number, sampleOffset: number, sampleCount: number) => {
// Return a Float32Array of samples for the given channel and range
return Promise.resolve(channelData[channel].subarray(sampleOffset, sampleOffset + sampleCount));
};
Frequency content over time. Supports linear, log, mel, and ERB frequency scales with configurable FFT size, dB range, and colormap.

Peak amplitude envelope showing min/max sample values per time column.

BS.1770-4 loudness metrics: RMS envelope (filled), momentary LUFS (400ms window), short-term LUFS (3s window), and integrated LUFS (horizontal dashed line). LUFS values are mapped to amplitude (10^(lufs/20)) so they visually correspond to the waveform scale. True peak is shown as a red dashed horizontal line at the interpolated peak amplitude.

useSpectralCompute(options: SpectralOptions): ComputeResultThe main hook. Manages the GPU engine lifecycle, runs the processing pipeline, and returns results reactively.
| Field | Type | Description |
|---|---|---|
metadata | SpectralMetadata | Audio file properties |
query | SpectralQuery | Time range and output dimensions |
readSamples | (channel, offset, count) => Promise<Float32Array> | Callback to provide audio samples |
config | Partial<SpectralConfig> | Optional processing configuration |
| Field | Type | Description |
|---|---|---|
sampleRate | number | Sample rate in Hz |
sampleCount | number | Total samples per channel |
channelCount | number | Number of audio channels |
channelWeights | ReadonlyArray<number> | Optional BS.1770-4 channel weights (default: all 1.0) |
| Field | Type | Description |
|---|---|---|
startMs | number | Start time in milliseconds |
endMs | number | End time in milliseconds |
width | number | Output width in pixels |
height | number | Output height in pixels |
All fields are optional — defaults are applied automatically.
| Field | Type | Default | Description |
|---|---|---|---|
fftSize | number | 4096 | FFT window size (power of 2) |
frequencyScale | FrequencyScale | "log" | "linear", "log", "mel", or "erb" |
dbRange | [number, number] | [-120, 0] | Spectrogram dB range [min, max] |
colormap | string | ColormapDefinition | "lava" | "lava", "viridis", or custom colormap |
waveformColor | [number, number, number] | Auto | RGB color for waveform rendering |
device | GPUDevice | Auto | WebGPU device (acquired automatically if omitted) |
signal | AbortSignal | Internal | External abort signal for cancellation |
spectrogram | boolean | true | Enable spectrogram GPU computation |
loudness | boolean | true | Enable K-weighting and LUFS computation |
truePeak | boolean | true | Enable BS.1770-4 true peak measurement |
Discriminated union with status field:
{ status: "idle" } — no computation started{ status: "error", error: Error } — pipeline failed{ status: "ready", spectrogramTexture, waveformBuffer, waveformPointCount, loudnessData, options } — results available<SpectrogramCanvas computeResult={computeResult} />Renders the spectrogram texture to a canvas via GPU blit.
<WaveformCanvas computeResult={computeResult} color={[r, g, b]} />Renders the waveform envelope via GPU compute. color is optional RGB (0-255).
<LoudnessCanvas computeResult={computeResult} />Renders loudness metrics on a 2D canvas. Optional boolean props to toggle each visualization:
| Prop | Default | Description |
|---|---|---|
rmsEnvelope | true | RMS amplitude envelope fill |
momentary | false | 400ms momentary LUFS line |
shortTerm | false | 3s short-term LUFS line |
integrated | true | Integrated LUFS horizontal line |
truePeak | false | True peak amplitude line |
colors | Built-in | Override colors per visualization |
All components accept a ref prop for canvas element access.
navigator.gpu for support.scheduler.yield() — optional. Used for cooperative yielding during processing. Falls back to setTimeout if unavailable.ISC
FAQs
WebGPU-accelerated audio visualization for React. Renders spectrograms, waveforms, and BS.1770-4 loudness metrics from raw audio samples.
We found that @e9g/spectral-display demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.