Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

spessasus/spessasynth_lib

Open more actions menu

Repository files navigation

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!

Made with spessasynth_lib

SpessaSynth Project index

Current Features

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.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.