spessasynth_lib 3.27.8 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +48 -47
  2. package/dist/index.d.ts +1328 -0
  3. package/dist/index.js +3212 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/spessasynth_processor.min.js +21 -0
  6. package/dist/spessasynth_processor.min.js.map +7 -0
  7. package/package.json +26 -14
  8. package/index.js +0 -29
  9. package/src/external_midi/README.md +0 -4
  10. package/src/external_midi/midi_handler.js +0 -130
  11. package/src/external_midi/web_midi_link.js +0 -43
  12. package/src/sequencer/README.md +0 -30
  13. package/src/sequencer/default_sequencer_options.js +0 -9
  14. package/src/sequencer/midi_data.js +0 -67
  15. package/src/sequencer/sequencer.js +0 -813
  16. package/src/sequencer/sequencer_message.js +0 -53
  17. package/src/synthetizer/README.md +0 -30
  18. package/src/synthetizer/audio_effects/effects_config.js +0 -25
  19. package/src/synthetizer/audio_effects/fancy_chorus.js +0 -166
  20. package/src/synthetizer/audio_effects/rb_compressed.min.js +0 -1
  21. package/src/synthetizer/audio_effects/reverb.js +0 -35
  22. package/src/synthetizer/audio_effects/reverb_as_binary.js +0 -18
  23. package/src/synthetizer/key_modifier_manager.js +0 -113
  24. package/src/synthetizer/sfman_message.js +0 -9
  25. package/src/synthetizer/synth_event_handler.js +0 -217
  26. package/src/synthetizer/synth_soundfont_manager.js +0 -115
  27. package/src/synthetizer/synthetizer.js +0 -1033
  28. package/src/synthetizer/worklet_message.js +0 -121
  29. package/src/synthetizer/worklet_processor.js +0 -654
  30. package/src/synthetizer/worklet_url.js +0 -18
  31. package/src/utils/buffer_to_wav.js +0 -40
  32. package/src/utils/fill_with_defaults.js +0 -21
  33. package/src/utils/other.js +0 -11
  34. package/synthetizer/worklet_processor.min.js +0 -22
package/README.md CHANGED
@@ -3,9 +3,12 @@
3
3
  <img src='https://raw.githubusercontent.com/spessasus/SpessaSynth/refs/heads/master/src/website/spessasynth_logo_rounded.png' width='300' alt='SpessaSynth logo'>
4
4
  </p>
5
5
 
6
- **A powerful SF2/DLS/MIDI JavaScript library for the browsers.**
6
+ *A powerful SF2/DLS/MIDI JavaScript library for the browsers, based on spessasynth_core.
7
+ This is a WebAudioAPI wrapper for the [spessasynth_core](https://github.com/spessasus/spessasynth_core) library.*
8
+
9
+ **v4.0.0 TypeScript Update is here! The NPM package now contains type declarations for easier developing!**
10
+ [**Read about breaking changes here**](https://spessasus.github.io/spessasynth_lib/extra/4-0-migration-guide)
7
11
 
8
- *This is a WebAudioAPI wrapper for the [spessasynth_core](https://github.com/spessasus/spessasynth_core) library.*
9
12
 
10
13
  It allows you to:
11
14
  - Play MIDI files using SF2/SF3/DLS files!
@@ -14,25 +17,12 @@ It allows you to:
14
17
  - Convert DLS to SF2! (and back!)
15
18
  - [and more!](#current-features)
16
19
 
17
- **The next major update (4.0) will include many breaking changes.
18
- The documentation will be updated when the update releases.
19
- [The migration guide will be published here.](https://github.com/spessasus/spessasynth_lib/pull/10)**
20
-
21
-
22
- **SpessaSynth Project index**
23
-
24
- - [spessasynth_core](https://github.com/spessasus/spessasynth_core) - SF2/DLS/MIDI library
25
- - [spessasynth_lib](https://github.com/spessasus/spessasynth_lib) (you are here) - spessasynth_core wrapper optimized for browsers and WebAudioAPI
26
- - [SpessaSynth](https://github.com/spessasus/SpessaSynth) - online/local MIDI player/editor application
27
- - [SpessaFont](https://github.com/spessasus/SpessaFont) - online SF2/DLS editor
28
-
29
20
 
30
21
  > **TIP:**
22
+ >
31
23
  > Looking for a bare JS version that works without WebAudioAPI? Try [spessasynth_core](https://github.com/spessasus/spessasynth_core)!
32
24
 
33
- ```shell
34
- npm install --save spessasynth_lib
35
- ```
25
+
36
26
 
37
27
  ### [Project site (consider giving it a star!)](https://github.com/spessasus/spessasynth_lib)
38
28
 
@@ -41,64 +31,75 @@ npm install --save spessasynth_lib
41
31
  - [SpessaFont - Online SoundFont/DLS Editor](https://spessasus.github.io/SpessaFont)
42
32
 
43
33
 
44
- ### [Complete documentation](https://spessasus.github.io/spessasynth_lib/)
34
+ ### [Documentation](https://spessasus.github.io/spessasynth_lib)
45
35
 
46
- #### Basic example: play a single note
47
36
 
48
- ```js
49
- import { Synthetizer } from "spessasynth_lib"
50
37
 
51
- const sfont = await (await fetch("soundfont.sf3")).arrayBuffer();
52
- const ctx = new AudioContext();
53
- // make sure you copied the worklet processor!
54
- await ctx.audioWorklet.addModule("./worklet_processor.min.js");
55
- const synth = new Synthetizer(ctx.destination, sfont);
56
- document.getElementById("button").onclick = async () =>
57
- {
58
- await ctx.resume();
59
- synth.programChange(0, 48); // strings ensemble
60
- synth.noteOn(0, 52, 127);
61
- }
62
- ```
38
+ **SpessaSynth Project index**
63
39
 
64
- *Audio may sometimes sound distorted in Chromium-based browsers: Chrome, Edge, Brave,
65
- etc. due to a **[Chromium Bug](https://issues.chromium.org/issues/367304685).**
66
- I can't do anything about it, only hope that it gets fixed.
67
- Please consider voting for it on the bug tracker to get it fixed!*
40
+ - [spessasynth_core](https://github.com/spessasus/spessasynth_core) - SF2/DLS/MIDI library
41
+ - [spessasynth_lib](https://github.com/spessasus/spessasynth_lib) (you are here) - spessasynth_core wrapper optimized for browsers and WebAudioAPI
42
+ - [SpessaSynth](https://github.com/spessasus/SpessaSynth) - online/local MIDI player/editor application
43
+ - [SpessaFont](https://github.com/spessasus/SpessaFont) - online SF2/DLS editor
68
44
 
69
45
  ## Current Features
70
46
 
71
47
  ### [All the features of spessasynth_core!](https://github.com/spessasus/spessasynth_core?#current-features)
72
48
 
73
49
  ### On top of that...
50
+ - **Fully typed:** *Faster development and IDE auto-completion!*
74
51
  - **Modular design:** *Easy integration into other projects (load what you need)*
75
52
  - **[Detailed documentation:](https://spessasus.github.io/spessasynth_lib/)** *With [examples!](https://spessasus.github.io/spessasynth_lib/getting-started/#examples)*
76
53
  - **Easy to Use:** *Basic setup is just [two lines of code!](https://spessasus.github.io/spessasynth_lib/getting-started/#minimal-setup)*
77
54
  - **No external dependencies:** *Just spessasynth_core!*
78
- - **Reverb and chorus support:** [customizable!](https://spessasus.github.io/spessasynth_lib/synthesizer/#effects-configuration-object)
79
- - **Export audio files** using [OfflineAudioContext](https://developer.mozilla.org/en-US/docs/Web/API/OfflineAudioContext)
80
- - **Written using AudioWorklets:**
81
- - Runs in a **separate thread** for maximum performance
82
- - Does not stop playing even when the main thread is frozen
83
- - Supported by all modern browsers
55
+ - **Reverb and chorus support:** [customizable](https://spessasus.github.io/spessasynth_lib/synthesizer/#effects-configuration-object) and can be used standalone!
56
+ - **Export audio files** using [OfflineAudioContext](https://developer.mozilla.org/en-US/docs/Web/API/OfflineAudioContext)!
57
+ - **AudioWorklet synthesizer:**
58
+ - Runs in a **separate thread** for maximum performance!
59
+ - Does not stop playing even when the main thread is frozen!
60
+ - Supported by all modern browsers!
61
+ - **Web Worker synthesizer:**
62
+ - Synthesize directly in the Web Worker!
63
+ - Direct audio engine access!
64
+ - Export audio automatically in the worker!
65
+ - Avoids [Chromium Audio Bugs](https://issues.chromium.org/issues/367304685)!
84
66
  - **High-performance mode:** Play Rush E! *note: may kill your browser ;)*
85
67
 
86
- #### TODO
87
- - Enhance the built-in chorus and reverb effects (suggestions welcome!)
88
-
89
68
  ### Special Thanks
90
69
  - [FluidSynth](https://github.com/FluidSynth/fluidsynth) - for the source code that helped implement functionality and fixes
91
- - [Polyphone](https://www.polyphone-soundfonts.com/) - for the soundfont testing and editing tool
70
+ - [Polyphone](https://www.polyphone-soundfonts.com/) - for the sound bank testing and editing tool
92
71
  - [Meltysynth](https://github.com/sinshu/meltysynth) - for the initial low-pass filter implementation
93
72
  - [RecordingBlogs](https://www.recordingblogs.com/) - for detailed explanations on MIDI messages
94
73
  - [stbvorbis.js](https://github.com/hajimehoshi/stbvorbis.js) - for the Vorbis decoder
95
74
  - [fflate](https://github.com/101arrowz/fflate) - for the MIT DEFLATE implementation
75
+ - [tsup](https://github.com/egoist/tsup) - for the TypeScript bundler
96
76
  - [foo_midi](https://github.com/stuerp/foo_midi) - for useful resources on XMF file format
97
77
  - [Falcosoft](https://falcosoft.hu) - for help with the RMIDI format
98
78
  - [Christian Collins](https://schristiancollins.com) - for various bug reports regarding the synthesizer
99
79
  - **And You!** - for checking out this project. I hope you like it :)
100
80
 
101
81
 
82
+ ### Basic example: play a single note
83
+
84
+ ```js
85
+ import { WorkletSynthesizer } from "spessasynth_lib"
86
+
87
+ // SF2, SF3, SFOGG and DLS files are all supported!
88
+ const sfont = await (await fetch("soundfont.sf3")).arrayBuffer();
89
+ const ctx = new AudioContext();
90
+ // make sure you copied the worklet processor!
91
+ await ctx.audioWorklet.addModule("./spessasynth_processor.min.js");
92
+ const synth = new WorkletSynthesizer(ctx);
93
+ await synth.soundBankManager.addSoundBank(sfont, "main");
94
+ await synth.isReady;
95
+ document.getElementById("button").onclick = async () =>
96
+ {
97
+ await ctx.resume();
98
+ synth.programChange(0, 48); // strings ensemble
99
+ synth.noteOn(0, 52, 127);
100
+ }
101
+ ```
102
+
102
103
  # License
103
104
  Copyright © 2025 Spessasus
104
105
  Licensed under the Apache-2.0 License.