Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
5d7cb36
initial typescript
spessasus Jul 27, 2025
ec3e74f
initial typescript (it's pain)
spessasus Jul 28, 2025
c9ad2d2
further typescript
spessasus Jul 28, 2025
77dc6f0
worklet valid
spessasus Jul 29, 2025
aba1510
it compiles
spessasus Jul 29, 2025
566ec98
first example is working
spessasus Jul 29, 2025
6c2756c
Merge branch 'master' into typescript
spessasus Jul 30, 2025
4c30523
typescript build files
spessasus Jul 30, 2025
e98feae
Merge branch 'master' into typescript
spessasus Jul 30, 2025
0f108c2
update for core update
spessasus Aug 1, 2025
a10acfa
Properly implement all examples
spessasus Aug 2, 2025
5393730
eslint stylistic & begin migration guide
spessasus Aug 2, 2025
d70a1f4
migration guide
spessasus Aug 2, 2025
7a4ea77
BasicSynthesizer
spessasus Aug 6, 2025
a7ae853
Rework effect processors
spessasus Aug 7, 2025
b9c7b24
remove console.log
spessasus Aug 7, 2025
a669d1f
structure rework
spessasus Aug 7, 2025
e3e43d7
initial worker synthesizer
spessasus Aug 7, 2025
aca8c28
workerSynthesizer renderAudio and example update
spessasus Aug 9, 2025
3031a25
eslint tweaks
spessasus Aug 10, 2025
46bc005
remove tempoChange event
spessasus Aug 10, 2025
051e160
better types
spessasus Aug 11, 2025
54e8d2a
better audio to wav
spessasus Aug 11, 2025
a851da6
Unified synthesizer core
spessasus Aug 11, 2025
bc21821
SF2 write in worker synth
spessasus Aug 12, 2025
101396d
better MIDIDeviceHandler
spessasus Aug 12, 2025
c4ef96a
writeDLS
spessasus Aug 12, 2025
b9ec3f0
midiData can be undefined!
spessasus Aug 12, 2025
5c0dfdd
write RMIDI!
spessasus Aug 13, 2025
cfb5258
better MIDI device handler
spessasus Aug 13, 2025
ad2220b
fix alt name
spessasus Aug 13, 2025
e7150ab
Compression quality in the function
spessasus Aug 13, 2025
e7821b2
better worker synth API
spessasus Aug 14, 2025
69fafe7
type tweaks
spessasus Aug 14, 2025
f8f2b88
better pitch wheel
spessasus Aug 14, 2025
f067560
fix current time desync
spessasus Aug 15, 2025
b085be3
fix deleting sound bank
spessasus Aug 15, 2025
00d0625
sf2 extension
spessasus Aug 15, 2025
d6acfaa
reference migration guide
spessasus Aug 15, 2025
ae66563
automatic time adjustment
spessasus Aug 15, 2025
01ec39e
Latency selection for worker
spessasus Aug 16, 2025
64530f9
copy tracks but without events
spessasus Aug 16, 2025
27efb1c
update for core!
spessasus Aug 18, 2025
8e154a4
rename the worklet file
spessasus Aug 21, 2025
37985f1
LSB patch
spessasus Aug 26, 2025
f77291d
Merge pull request #14 from spessasus/typescript-lsb
spessasus Aug 26, 2025
710f608
Fix build on Windows
spessasus Sep 1, 2025
394f3df
core fix
spessasus Sep 2, 2025
bfa527c
initial documentation
spessasus Sep 4, 2025
c1447ca
further documentation!
spessasus Sep 4, 2025
1ed5530
sequencer documentation!
spessasus Sep 4, 2025
651732d
finish docs!
spessasus Sep 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ body:
description: Steps to reproduce the behavior.
placeholder: |
1. Load this MIDI...
2. Load this soundfont
2. Load this sf2/dls file
3. Play '...'
4. See error...
validations:
Expand All @@ -62,6 +62,6 @@ body:
- type: textarea
attributes:
label: Additional info
description: Any additional info and attachments (screenshots, MIDIs, soundfonts, other environments) go here.
description: Any additional info and attachments (screenshots, MIDIs, sf2/dls files, other environments) go here.
validations:
required: false
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ body:
- type: textarea
attributes:
label: Additional info
description: Any additional info and attachments (screenshots, MIDIs, soundfonts, other environments) go here.
description: Any additional info and attachments (screenshots, MIDIs, sf2/dls files, other environments) go here.
validations:
required: false
6 changes: 4 additions & 2 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ jobs:
python-version: '3.13'
- name: Install Node dependencies
run: npm ci
- name: Install Python dependencies
run: pip install -r docs/requirements.txt
- name: Build Pages
run: npm run build
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload dist folder
path: './dist'
# Upload docs folder
path: './docs'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ $RECYCLE.BIN/

# Windows shortcuts
*.lnk
/synthetizer/worklet_processor.min.js.map
*.tgz
/synthetizer/
/spessasynth_lib.wiki/
dist/
synthetizer/
*.tgz
gh-pages/
/gh-pages/
7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/jsLinters/eslint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/prettier.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/spessasynth_lib.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"tabWidth": 4,
"semi": true,
"singleQuote": false,
"trailingComma": "none",
"endOfLine": "lf"
}
95 changes: 48 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
<img src='https://raw.githubusercontent.com/spessasus/SpessaSynth/refs/heads/master/src/website/spessasynth_logo_rounded.png' width='300' alt='SpessaSynth logo'>
</p>

**A powerful SF2/DLS/MIDI JavaScript library for the browsers.**
*A powerful SF2/DLS/MIDI JavaScript library for the browsers, based on spessasynth_core.
This is a WebAudioAPI wrapper for the [spessasynth_core](https://github.com/spessasus/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**](https://spessasus.github.io/spessasynth_lib/extra/4-0-migration-guide)

*This is a WebAudioAPI wrapper for the [spessasynth_core](https://github.com/spessasus/spessasynth_core) library.*

It allows you to:
- Play MIDI files using SF2/SF3/DLS files!
Expand All @@ -14,25 +17,12 @@ It allows you to:
- Convert DLS to SF2! (and back!)
- [and more!](#current-features)

**The next major update (4.0) will include many breaking changes.
The documentation will be updated when the update releases.
[The migration guide will be published here.](https://github.com/spessasus/spessasynth_lib/pull/10)**


**SpessaSynth Project index**

- [spessasynth_core](https://github.com/spessasus/spessasynth_core) - SF2/DLS/MIDI library
- [spessasynth_lib](https://github.com/spessasus/spessasynth_lib) (you are here) - spessasynth_core wrapper optimized for browsers and WebAudioAPI
- [SpessaSynth](https://github.com/spessasus/SpessaSynth) - online/local MIDI player/editor application
- [SpessaFont](https://github.com/spessasus/SpessaFont) - online SF2/DLS editor


> **TIP:**
>
> Looking for a bare JS version that works without WebAudioAPI? Try [spessasynth_core](https://github.com/spessasus/spessasynth_core)!

```shell
npm install --save spessasynth_lib
```


### [Project site (consider giving it a star!)](https://github.com/spessasus/spessasynth_lib)

Expand All @@ -41,64 +31,75 @@ npm install --save spessasynth_lib
- [SpessaFont - Online SoundFont/DLS Editor](https://spessasus.github.io/SpessaFont)


### [Complete documentation](https://spessasus.github.io/spessasynth_lib/)
### [Documentation](https://github.com/spessasus/spessasynth_lib/wiki/)

#### Basic example: play a single note

```js
import { Synthetizer } from "spessasynth_lib"

const sfont = await (await fetch("soundfont.sf3")).arrayBuffer();
const ctx = new AudioContext();
// make sure you copied the worklet processor!
await ctx.audioWorklet.addModule("./worklet_processor.min.js");
const synth = new Synthetizer(ctx.destination, sfont);
document.getElementById("button").onclick = async () =>
{
await ctx.resume();
synth.programChange(0, 48); // strings ensemble
synth.noteOn(0, 52, 127);
}
```
**SpessaSynth Project index**

*Audio may sometimes sound distorted in Chromium-based browsers: Chrome, Edge, Brave,
etc. due to a **[Chromium Bug](https://issues.chromium.org/issues/367304685).**
I can't do anything about it, only hope that it gets fixed.
Please consider voting for it on the bug tracker to get it fixed!*
- [spessasynth_core](https://github.com/spessasus/spessasynth_core) - SF2/DLS/MIDI library
- [spessasynth_lib](https://github.com/spessasus/spessasynth_lib) (you are here) - spessasynth_core wrapper optimized for browsers and WebAudioAPI
- [SpessaSynth](https://github.com/spessasus/SpessaSynth) - online/local MIDI player/editor application
- [SpessaFont](https://github.com/spessasus/SpessaFont) - online SF2/DLS editor

## Current Features

### [All the features of spessasynth_core!](https://github.com/spessasus/spessasynth_core?#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:](https://spessasus.github.io/spessasynth_lib/)** *With [examples!](https://spessasus.github.io/spessasynth_lib/getting-started/#examples)*
- **Easy to Use:** *Basic setup is just [two lines of code!](https://spessasus.github.io/spessasynth_lib/getting-started/#minimal-setup)*
- **No external dependencies:** *Just spessasynth_core!*
- **Reverb and chorus support:** [customizable!](https://spessasus.github.io/spessasynth_lib/synthesizer/#effects-configuration-object)
- **Export audio files** using [OfflineAudioContext](https://developer.mozilla.org/en-US/docs/Web/API/OfflineAudioContext)
- **Written using AudioWorklets:**
- Runs in a **separate thread** for maximum performance
- Does not stop playing even when the main thread is frozen
- Supported by all modern browsers
- **Reverb and chorus support:** [customizable](https://spessasus.github.io/spessasynth_lib/synthesizer/#effects-configuration-object) and can be used standalone!
- **Export audio files** using [OfflineAudioContext](https://developer.mozilla.org/en-US/docs/Web/API/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](https://issues.chromium.org/issues/367304685)!
- **High-performance mode:** Play Rush E! *note: may kill your browser ;)*

#### TODO
- Enhance the built-in chorus and reverb effects (suggestions welcome!)

### Special Thanks
- [FluidSynth](https://github.com/FluidSynth/fluidsynth) - for the source code that helped implement functionality and fixes
- [Polyphone](https://www.polyphone-soundfonts.com/) - for the soundfont testing and editing tool
- [Polyphone](https://www.polyphone-soundfonts.com/) - for the sound bank testing and editing tool
- [Meltysynth](https://github.com/sinshu/meltysynth) - for the initial low-pass filter implementation
- [RecordingBlogs](https://www.recordingblogs.com/) - for detailed explanations on MIDI messages
- [stbvorbis.js](https://github.com/hajimehoshi/stbvorbis.js) - for the Vorbis decoder
- [fflate](https://github.com/101arrowz/fflate) - for the MIT DEFLATE implementation
- [tsup](https://github.com/egoist/tsup) - for the TypeScript bundler
- [foo_midi](https://github.com/stuerp/foo_midi) - for useful resources on XMF file format
- [Falcosoft](https://falcosoft.hu) - for help with the RMIDI format
- [Christian Collins](https://schristiancollins.com) - 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

```js
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.
Expand Down
25 changes: 0 additions & 25 deletions build_scripts/build.js

This file was deleted.

6 changes: 6 additions & 0 deletions build_scripts/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { runCommandSync } from "./run_command.ts";

console.log("Building spessasynth_lib...");
runCommandSync("npm run build:npm");
runCommandSync("npm run build:pages");
console.log("spessasynth_lib built successfully.");
5 changes: 0 additions & 5 deletions build_scripts/build_docs.js

This file was deleted.

8 changes: 8 additions & 0 deletions build_scripts/build_docs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { runCommandSync } from "./run_command.ts";
import { GH_PAGES_DIR } from "./util.ts";

export const buildDocs = () => {
console.log("Building MkDocs...");
runCommandSync(`mkdocs build -c -s -d ${GH_PAGES_DIR}`);
console.log("MkDocs built successfully.");
};
52 changes: 52 additions & 0 deletions build_scripts/build_npm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import path from "path";
import { NPM_DIST_DIR } from "./util.ts";
import esbuild from "esbuild";
import * as tsup from "tsup";

console.log("Building NPM package...");
const dirname = import.meta.dirname;
const INPUT_PATH = path.join(dirname, "..", "src", "worklet_processor.ts");
const OUTPUT_PATH = path.join(
dirname,
"..",
NPM_DIST_DIR,
"spessasynth_processor.min.js"
);
try
{
// Main bundle
await tsup.build({
entry: ["src/index.ts"],
format: "esm",
dts: true,
sourcemap: true,
outDir: "dist"
})

// Worklet
// Esbuild src/worklet_processor/ts
// --bundle
// --tree-shaking=true
// --minify
// --sourcemap=linked
// --format=esm
// --outfile=dist/spessasynth_processor.min.js
// --platform=browser
esbuild.buildSync({
entryPoints: [INPUT_PATH],
bundle: true,
treeShaking: true,
minify: true,
format: "esm",
platform: "browser",
sourcemap: "linked",
outfile: OUTPUT_PATH,
logLevel: "info",
target: "esnext"
});
console.log("NPM package built successfully.");
}
catch(e)
{
console.error(e, "\nFailed to build the NPM package.")
}
19 changes: 0 additions & 19 deletions build_scripts/build_pages.js

This file was deleted.

13 changes: 13 additions & 0 deletions build_scripts/build_pages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { buildDocs } from "./build_docs.ts";
import { buildExamples } from "../examples/build_examples.ts";

console.log("Building for GitHub Pages...");
try {
buildDocs();
buildExamples();
console.log("Pages built successfully.");
}
catch(e)
{
console.error(e, "\n\nFailed to build GitHub pages. Did you install MkDocs?")
}
Loading