Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

spessasynth_lib

spessasus1.2kApache-2.04.0.11TypeScript support: included

MIDI and SoundFont2/DLS library for the browsers with no compromises

soundfont, synthesizer, synth, sf2, sf3, dls, dls-to-sf2, midi, rmi, midi-player, web-audio-api, web-midi-api, player, soundfont2, soundfont3, audio-buffer-to-wav

readme

SpessaSynth logo

A powerful SF2/DLS/MIDI JavaScript library for the browsers, based on spessasynth_core. This is a WebAudioAPI wrapper for the spessasynth_core library.

v4.0.0 TypeScript Update is here! The NPM package now contains type declarations for easier developing! Read about breaking changes here

It allows you to:

  • Play MIDI files using SF2/SF3/DLS files!
  • Read and write MIDI files!
  • Write SF2/SF3 files!
  • Convert DLS to SF2! (and back!)
  • and more!

TIP:

Looking for a bare JS version that works without WebAudioAPI? Try spessasynth_core!

Project site (consider giving it a star!)

Made with spessasynth_lib

Documentation

SpessaSynth Project index

Current Features

All the features of spessasynth_core!

On top of that...

  • Fully typed: Faster development and IDE auto-completion!
  • Modular design: Easy integration into other projects (load what you need)
  • Detailed documentation: With examples!
  • Easy to Use: Basic setup is just two lines of code!
  • No external dependencies: Just spessasynth_core!
  • Reverb and chorus support: customizable and can be used standalone!
  • Export audio files using OfflineAudioContext!
  • AudioWorklet synthesizer:
    • Runs in a separate thread for maximum performance!
    • Does not stop playing even when the main thread is frozen!
    • Supported by all modern browsers!
  • Web Worker synthesizer:
    • Synthesize directly in the Web Worker!
    • Direct audio engine access!
    • Export audio automatically in the worker!
    • Avoids Chromium Audio Bugs!
  • High-performance mode: Play Rush E! note: may kill your browser ;)

Special Thanks

  • FluidSynth - for the source code that helped implement functionality and fixes
  • Polyphone - for the sound bank testing and editing tool
  • Meltysynth - for the initial low-pass filter implementation
  • RecordingBlogs - for detailed explanations on MIDI messages
  • stbvorbis.js - for the Vorbis decoder
  • fflate - for the MIT DEFLATE implementation
  • tsup - for the TypeScript bundler
  • foo_midi - for useful resources on XMF file format
  • Falcosoft - for help with the RMIDI format
  • Christian Collins - for various bug reports regarding the synthesizer
  • And You! - for checking out this project. I hope you like it :)

Basic example: play a single note

import { WorkletSynthesizer } from "spessasynth_lib"

// SF2, SF3, SFOGG and DLS files are all supported!
const sfont = await (await fetch("soundfont.sf3")).arrayBuffer();
const ctx = new AudioContext();
// make sure you copied the worklet processor!
await ctx.audioWorklet.addModule("./spessasynth_processor.min.js");
const synth = new WorkletSynthesizer(ctx);
await synth.soundBankManager.addSoundBank(sfont, "main");
await synth.isReady;
document.getElementById("button").onclick = async () =>
{
    await ctx.resume();
    synth.programChange(0, 48); // strings ensemble
    synth.noteOn(0, 52, 127);
}

License

Copyright © 2025 Spessasus Licensed under the Apache-2.0 License.

SoundFont® is a registered trademark of Creative Technology Ltd.