← Back to Home

SPA Documentation

Complete reference for Synthetic Parametric Audio format v1.1

Overview

What is SPA?

SPA (Synthetic Parametric Audio) is an XML-based format for procedural sound generation. Unlike traditional audio files that store waveform data, SPA files contain instructions for generating sounds algorithmically.

<?xml version="1.0" encoding="UTF-8"?>
<spa xmlns="https://spa.audio/ns" version="1.0">
  <tone wave="sine" freq="440" dur="1" />
</spa>

Key Benefits

  • Tiny file sizes: A complex sound effect can be just 200 bytes vs 200KB for WAV
  • AI-friendly: Declarative XML format that AI models can easily understand and generate
  • Procedural: Parameters can be modified in real-time for dynamic sound generation
  • Cross-platform: Works in browsers, Node.js, and any platform with audio synthesis

Basic Structure

Every SPA file starts with an XML declaration and a root <spa> element with namespace and version attributes:

<?xml version="1.0" encoding="UTF-8"?>
<spa xmlns="https://spa.audio/ns" version="1.0">
  <!-- Sound elements go here -->
</spa>

Elements

Tone Element

Generates oscillator-based sounds with various waveforms. The fundamental building block for melodic and harmonic content.

Required Attributes

  • wave: Waveform type - sine, square, triangle, saw, pulse
  • freq: Frequency in Hz (20-20000)
  • dur: Duration in seconds (0.01-60)

Optional Attributes

  • amp: Amplitude/volume (0-1, default: 1)
  • envelope: ADSR envelope (default: "0,0,1,0")
  • pan: Stereo position (-1 to 1, default: 0)
  • filter: Filter type (lowpass, highpass, bandpass)
  • cutoff: Filter cutoff frequency (20-20000 Hz)
  • resonance: Filter resonance (0.1-20, default: 1)
  • phase: Initial phase offset (0-360 degrees)
  • at: Start time in seconds (for root-level timing)
  • effect: Effect chain (comma-separated IDs)

Wave Types

sine

Pure, smooth tone - fundamental frequency only

square

Hollow, buzzy sound - odd harmonics

triangle

Mellow, flute-like - weak harmonics

saw

Bright, rich sound - all harmonics

Example

<tone wave="sine"
      freq="440"
      dur="1"
      amp="0.8"
      envelope="0.01,0.1,0.7,0.2"
      pan="0.5"
      filter="lowpass"
      cutoff="2000"
      resonance="2" />

Noise Element

Generates various types of noise for percussive sounds, textures, and ambient effects.

Required Attributes

  • color: Noise type - white, pink, brown, blue, violet, grey
  • dur: Duration in seconds (0.01-60)

Noise Colors

white

Equal energy at all frequencies - hiss

pink

Natural sounding - rain, wind

brown

Deep rumble - thunder, ocean

blue

High frequency emphasis - steam

Example

<noise color="pink"
       dur="2"
       amp="0.3"
       envelope="0.5,0,1,0.5"
       filter="highpass"
       cutoff="500" />

Group Element

Container element for layering multiple sounds that play simultaneously. Groups can be nested for complex hierarchies.

Characteristics

  • • All child elements play at the same time
  • • Can contain: tone, noise, and nested group elements
  • • Supports optional id, amp, pan, at, and effect attributes
  • • Group-level attributes affect all children
  • • Can use repeat functionality for echo effects

Example - C Major Chord

<group amp="0.5">
  <tone wave="sine" freq="261.63" dur="1" /> <!-- C -->
  <tone wave="sine" freq="329.63" dur="1" /> <!-- E -->
  <tone wave="sine" freq="392" dur="1" />    <!-- G -->
</group>

Sequence Element

Container for creating timed sequences of sounds. Each child element must have an at attribute specifying when it plays.

Attributes

  • tempo: BPM for beat-based timing (20-300, optional)
  • effect: Apply effects to entire sequence

Timing

  • • Time-based: Use at in seconds
  • • Beat-based: Set tempo and use at as beat numbers
  • • All children MUST have at attribute

Example - Simple Melody

<sequence>
  <tone wave="sine" freq="262" dur="0.25" at="0" />    <!-- C -->
  <tone wave="sine" freq="294" dur="0.25" at="0.25" /> <!-- D -->
  <tone wave="sine" freq="330" dur="0.25" at="0.5" />  <!-- E -->
  <tone wave="sine" freq="349" dur="0.25" at="0.75" /> <!-- F -->
  <tone wave="sine" freq="392" dur="0.5" at="1" />     <!-- G -->
</sequence>

+Sound Shaping

+Advanced Features

+Complete Reference

+Example Library