# What I'm Asking For
A [softsynth](https://en.wikipedia.org/wiki/Software_synthesizer) that uses [sample-based synthesis](https://en.wikipedia.org/wiki/Sample-based_synthesis) to render notes into audio. For use in WebView2's [Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API).
I would prefer a softsynth that uses a SoundFont file.
# TL;DR
- SoundFonts > Individual Instrument Audio Files
- Better timing
- Can play notes programmatically
- Can add/change audio effects live
- MIDI file support
- Variable note length
- Supported instruments can sustain indefinitely
# Why Use a Softsynth?
- Provides a more flexible way to time notes, not being limited to increments of `world.tick_lag`
- Typically provides support for programmatically turn notes on and off
- I can make a parser for Player Piano notes and play it like this
- Ability to add/change audio effects live
- e.g. chrous, reverb, or filter
- May provide support for playing MIDI files
- **If** this is allowed, I would like to reccomend a MIDI file limit of around 500 KB
- Though that's just me setting an arbitrary limit
## Variable Note Length
- Instruments notes can be played longer or shorter without audio cliping
- Supported instruments (e.g. organ, trombone) can be sustained indefinitely
- Allows the following instruments work as intended:
- `outbackcatgirl` attempted to do sustained organs, which didn't work well due to audio cliping
- `ithebinman` wants to have sustained trombones to make a manual trombone instrument with sliding
# Why Use a SoundFont?
## Takes Up Less Space
- For instance, `GeneralUser GS v1.471.sf2` includes around 128 instruments while being around 29.8 MB
- While the 12 insturments Goonstation currently has are collectively around 5.6 MB
- Goonstation Instrument List: saxophone, tambourine, triangle, trumpet, banjo, bass, cowbell, elecguitar, fiddle, guitar, organ, piano
- SoundFont files can be edited to remove unnecessary instruments, reducing file size
# Softsynth List
## JavaScript
### SpessaSynth
- https://github.com/spessasus/SpessaSynth
- License: MIT (one file under Apache 2.0)
Possibly the best fit when looking at features, license, and language.
### webaudiofont
- https://github.com/surikov/webaudiofont
- License: GPL3
Has the necessary features, but the license is possibly an issue.
## WASM
These would need to be converted to WASM to be used. Would likely use [Audio Worklets](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API#audio_processing_in_javascript).
### TinySoundFont
- Language: C
- https://github.com/schellingb/TinySoundFont
- License: MIT
Would need to be ported for use.
### RustySynth
- Language: Rust
- https://github.com/sinshu/rustysynth
- License: MIT
Would need to be ported for use. Probably easier to port than a C library.
### fluidsynth-emscripten
- Language: C
- https://github.com/jet2jet/fluidsynth-emscripten
- License: LGPL2.1
Porting the original [fluidsynth](https://github.com/FluidSynth/fluidsynth) library is likely beyond my ability, so this is probably a better alternative.
It's forked from an older version of fluidsynth, but appears to still work without issue in a [project's](https://github.com/jet2jet/js-synthesizer?tab=readme-ov-file) [demo](https://www.pg-fl.jp/music/js-synthesizer/index.en.htm) that uses it.