waveshow
waveshow(
y,options?):CanvasRenderingContext2D
Defined in: packages/pleco-xa/src/scripts/xa-display.js:445
Visualize a waveform in the time domain on a Canvas element
Renders audio waveform with envelope display and optional decimation for efficient display of long audio files.
Parameters
Section titled “Parameters”number[] | Float32Array<ArrayBufferLike>
Audio time series
options?
Section titled “options?”Display options
number
Transparency (0-1, default: 0.7)
canvas
Section titled “canvas”HTMLCanvasElement
Target canvas element (required)
string
Waveform color (default: ‘#1f77b4’)
drawAxes
Section titled “drawAxes”boolean
Draw axis labels and ticks (default: true)
envelope
Section titled “envelope”boolean
Show envelope for decimated display (default: true)
maxPoints
Section titled “maxPoints”number
Maximum number of points to display (default: 11025)
offset
Section titled “offset”number
Time offset in seconds (default: 0.0)
number
Sample rate in Hz (default: 22050)
string
X-axis type: ‘time’, ‘samples’, ‘s’, ‘ms’ (default: ‘time’)
Returns
Section titled “Returns”CanvasRenderingContext2D
Canvas 2D context with rendered waveform
Example
Section titled “Example”// Display waveformconst canvas = document.getElementById('wave-canvas');const y = new Float32Array(audioBuffer.getChannelData(0));waveshow(y, { canvas: canvas, sr: 44100, color: '#2ca02c', envelope: true});