DevTools Logo

Audio Waveform to SVG

Audio Waveform to SVG

Turn audio samples into a minimal, copyable SVG path locally

Waveform settings

Source: Synthetic sine wave

About

Upload browser-supported audio or use the built-in sine wave, inspect an inline SVG preview, and copy the generated SVG code.

Examples

Constant-one peak

Input
analyzeWaveform(new Float32Array([1, 1, 1, 1]), 2).blobs
Output
[{ peak: 1, max: 1, min: 1, rms: 1 }, { peak: 1, max: 1, min: 1, rms: 1 }]

A full-scale DC signal peaks at 1 in every bucket with unit RMS.

Bar vs line output

Input
generateWaveformPath(analysis, { style: "bar" }) vs { style: "line" }
Output
{ bar: "M x y L x y ...", line: "M x y L x y ..." (different strings) }

Bar emits per-blob verticals while line emits one envelope polyline.

About this tool

Audio Waveform to SVG turns samples into vector art: analyzeWaveform(samples, blobCount 64) buckets the input into min(blobCount, samples.length) blobs, each with start, end, min, max, rms, and peak, throwing on empty samples or a non-positive-integer blob count.

Paths come from generateWaveformPath(analysis, { width 800, height 240, style }): bar draws one vertical M/L segment per blob center, line draws the upper-envelope polyline, and area closes the upper plus reversed lower envelope with Z — coordinates format to 3 decimals around a center of height / 2 scaled by height / 2.

generateWaveformSvg(samples, { blobs, width, height, style, color #2563eb, strokeWidth }) wraps the path in an <svg> with viewBox, role img, and aria-label: bar uses stroke width 2 with no fill, line uses 3 with no fill, and area fills with the stroke color at 0.22 opacity.

How to use this tool

  1. Analyze samples

    Pass a Float32Array or number array with a blob count — 64 buckets by default, capped by sample length.

  2. Pick a style

    Choose bar for peaks, line for envelopes, or area for filled waveforms at 800×240 by default.

  3. Export SVG

    Call generateWaveformSvg for a complete <svg> string, or generateWaveformPath to embed the d attribute.

Use cases

Previewing takes

Render recorded buffers as inline SVG thumbnails in track lists.

Documenting audio

Embed deterministic waveform figures in reports and changelogs.

Styling players

Swap bar, line, and area styles to match player themes without re-analyzing.

Common mistakes

Mistake:Requesting more blobs than samples.

Fix:Blob count caps at samples.length — two samples with blobs 10 still yield two blobs.

Mistake:Passing an empty analysis to the path builder.

Fix:Zero-blob analysis throws — guard on blobs.length before calling generateWaveformPath.

Frequently asked questions

What does this tool do?

It analyzes samples with analyzeWaveform into min/max/rms/peak blobs, builds vector data with generateWaveformPath (bar, line, area), and wraps it in a complete <svg> via generateWaveformSvg.

How are blobs, styles, and sizes handled?

Blob count defaults to 64 and caps at samples.length; bar draws per-blob verticals, line draws the envelope polyline, area closes the filled shape; width/height default to 800×240 with bar stroke 2, line/area stroke 3, and color #2563eb.

Is my audio uploaded or stored?

No. Bucketing, path building, and SVG serialization run fully client-side.

Why did analysis throw, or blobs come back short?

Empty samples or zero-blob analysis throws cannot be empty and blob counts must be positive integers; short input caps blobs at the sample length, so two samples yield two blobs.

References & standards

.env Secret Safety Linter

Validate .env syntax and spot likely leaked credentials or placeholder secrets.

.htaccess Generator

Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth

2D Fluid Dynamics & Particle Physics Sandbox

A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.

AI Function Calling Schema Generator

Generate function calling JSON schemas from TypeScript interfaces

Algorithm Arena & Data Structure Visualizer

Interactive arena for algorithms and data structures: eight sorting algorithms racing on one seeded input, six pathfinding algorithms walking generated mazes, and BST, AVL, Red-Black, B-tree, heap and trie operations replayed step by step with rotations highlighted. Every run shows the Big-O table and the phase-highlighted reference implementation in four languages, and compared values can be played as pitch (sonification) through the shared audio engine. Everything runs client-side; inputs never leave the browser.

Ansible Playbook Generator

Build an Ansible playbook — hosts, vars, and tasks with modules — as YAML