audio

Library

Install

import audio from 'audio'
await audio('voice.wav').trim().normalize('podcast').save('clean.mp3')

How it works

A sound is a chain of edits. Nothing is rendered until it is played, saved or measured. On top of its packages it adds paging (no 2 GB limit), streaming (it plays and encodes while it decodes) and non-destructive edits (infinite undo).

Examples

  1. Clean a take, and prove it meets Apple's podcast spec.

    let voice = audio('voice.wav')
      .trim().normalize('podcast')
    await voice.save('clean.mp3')
    let { pass, rules } =
      await voice.check('podcast')
  2. Master a song to a reference track: its tone, width and loudness.

    audio('mix.wav')
      .master(await audio('ref.wav'))
      .save('master.wav')
  3. Tighten the pauses of a talking-head video; the same cuts go to the video editor.

    let talk = audio('talk.mp4')
      .shrink(0.3)
    await talk.save('talk.m4a')
    await talk.save('talk.edl')
  4. The page's Audio element in Node, Bun and Deno: one import, the same events and promises.

    import 'audio/polyfill'
    let song = new Audio('song.mp3')
    await song.play()
    song.currentTime = 30

Run

npx audio voice.wav trim normalize podcast save clean.mp3

How it works

A source, its edits in order, a sink. With no sink, a file opens in the terminal's player.

Examples

  1. Check a file against a delivery spec. A fail exits 1, so the line guards a build.

    $ audio clean.mp3 check podcast
      ✓ Loudness -16.44 LUFS  -17 to -15
      ✓ True peak -1.18 dBTP  ≤ -1
      pass
  2. Play a hook on a loop; play with effects applied live.

    $ audio song.mp3 30s..45s play loop
    $ audio song.mp3 normalize \
        broadcast highpass 80hz play
  3. Split an album at its cue sheet, each track tagged.

    $ audio album.wav split \
        --cue album.cue \
        save '{i} - {title}.mp3'

Use

import audio from 'audio'
await audio('take.wav').compressor(-30, 8).save('out.wav')

How it works

A plugin is a processor from an @audio package: an effect, a repair, a synth. Its family installs with audio and loads at the first render that calls it. A value takes its parameter’s unit. The same processor runs in an AudioWorklet and, experimental and on macOS, builds to VST3 and CLAP.

Examples

  1. By its name, a value in its parameter’s unit.

    audio('take.wav')
      .compressor({ attack: '10ms' })
      .delay({ time: '250ms' })
  2. One of your own: a block processor, by a name of yours.

    audio.op('invert', (inp, out) => {
      for (let c = 0; c < inp.length; c++)
        out[c].set(inp[c].map(v => -v))
    })
    audio('take.wav').invert()
  3. The contract: a function that returns a function, its parameters on it.

    export const gain = (ctx) =>
      (inputs, outputs, params) => { … }
    gain.params = {
      gain: { type: 'number', min: -60,
        max: 24, default: 0, unit: 'dB' },
    }

Use

<script type="module"
  src="https://audio.js.org/audio/elements/index.js"></script>

How it works

The editor in parts: custom elements a page composes, each the HTML face of a module the editor itself runs on, in the page's own DOM and styled by it. A sound's script runs in a worker; the page's thread stays free.

Examples

  1. A sound as a script makes it, with its picture and its parts

    <audio-clip>
      <audio src="take.mp3"
        data-name="take.mp3"></audio>
      <audio-code>
        <pre><code>audio('take.mp3')
      .trim()
      .save('clean.mp3')</code></pre>
      </audio-code>
      <audio-wave></audio-wave>
      <audio-play></audio-play>
      <audio-save></audio-save>
    </audio-clip>
  2. A script alone, coloured as the editor colours it, editable

    <audio-code>
      <pre><code>audio('take.mp3')
      .normalize('podcast')</code></pre>
    </audio-code>
  3. The editor whole, in any page: the element's text is its script

    <script type="module"
      src="https://audio.js.org/embed.js">
    </script>
    <audio-repl height="320">
      <pre>audio('chime.wav').trim()</pre>
    </audio-repl>

Connect

npx add-mcp "npx -y audio --mcp"

What it does

An agent measures, edits and plays sound with the same calls a script makes: Claude Code, Codex, Cursor, Gemini CLI, Zed and others.

Examples

  1. Ask for the result, not the steps.

    > make ~/Desktop/interview.m4a
      podcast-ready and tell me the
      loudness before and after
  2. The same as an agent skill.

    $ npx skills add audiojs/audio
  3. Your own agent inside the editor: it measures, looks at, edits and plays the sound that is open there.

    $ npx audio --bridge
    audio bridge on http://127.0.0.1:7777

FAQ

How is it different from the Web Audio API?

Audio.js is platform independent stack with own DSP.

See web-audio-api

Does it need ffmpeg or native addons?

No FFmpeg: codecs and DSP are JavaScript and WebAssembly. In Node, the speaker and the microphone use one small addon, prebuilt for macOS, Linux and Windows. Nothing compiles at install.

What formats does it decode and encode?
Decode, 24WAV, MP3, FLAC, Opus, Vorbis, AAC, MP4, AIFF, CAF, WebM, WavPack, APE, TTA, MPC, AC-3, E-AC-3, DTS, WMA, AMR, GSM, DSD, QOA, AVI, MOD
Encode, 14WAV, MP3, FLAC, Opus, OGG, AAC, MP4, ALAC, AIFF, CAF, WebM, WavPack, GSM, QOA

A package each, loaded on first use.

Is it as fast as FFmpeg or SoX?

Not as fast as FFmpeg yet: FFmpeg wins four of the six timed against it. Ahead of SoX in four of five.

10-minute fileaudioFFmpegSoX
WAV decode246 ms73 ms50 ms
MP3 decode306 ms484 ms–
LUFS229 ms336 ms–
Peak normalize405 ms–555 ms
Resample to 48 kHz450 ms292 ms1.04 s
Time stretch 0.8×3.09 s665 ms5.82 s
Pitch shift +2 st2.83 s821 ms6.02 s

How it was measured, 2026-11. Shorter is faster.

How big is it?
In a page155.5 KB gzipped; codecs load on first use
One package@audio/decode-wav: 24 KB
All of itnpm i audio: 16.6 MB, the 24 decoders and 14 encoders in it, nothing compiled
For scaleFFmpeg in WebAssembly, @ffmpeg/core: 64.7 MB

Sizes unpacked, as npm states them, 26 Nov 2026.

TypeScript?

Yes. audio ships its types, audio.d.ts.