spessasynth_lib 3.27.7 → 4.0.0

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 +50 -44
  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 +28 -9
  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,20 +17,12 @@ It allows you to:
14
17
  - Convert DLS to SF2! (and back!)
15
18
  - [and more!](#current-features)
16
19
 
17
- **SpessaSynth Project index**
18
-
19
- - [spessasynth_core](https://github.com/spessasus/spessasynth_core) - SF2/DLS/MIDI library
20
- - [spessasynth_lib](https://github.com/spessasus/spessasynth_lib) (you are here) - spessasynth_core wrapper optimized for browsers and WebAudioAPI
21
- - [SpessaSynth](https://github.com/spessasus/SpessaSynth) - online/local MIDI player/editor application
22
- - [SpessaFont](https://github.com/spessasus/SpessaFont) - online SF2/DLS editor
23
-
24
20
 
25
21
  > **TIP:**
22
+ >
26
23
  > Looking for a bare JS version that works without WebAudioAPI? Try [spessasynth_core](https://github.com/spessasus/spessasynth_core)!
27
24
 
28
- ```shell
29
- npm install --save spessasynth_lib
30
- ```
25
+
31
26
 
32
27
  ### [Project site (consider giving it a star!)](https://github.com/spessasus/spessasynth_lib)
33
28
 
@@ -36,64 +31,75 @@ npm install --save spessasynth_lib
36
31
  - [SpessaFont - Online SoundFont/DLS Editor](https://spessasus.github.io/SpessaFont)
37
32
 
38
33
 
39
- ### [Complete documentation](https://github.com/spessasus/spessasynth_lib/wiki/)
34
+ ### [Documentation](https://spessasus.github.io/spessasynth_lib)
40
35
 
41
- #### Basic example: play a single note
42
36
 
43
- ```js
44
- import { Synthetizer } from "spessasynth_lib"
45
37
 
46
- const sfont = await (await fetch("soundfont.sf3")).arrayBuffer();
47
- const ctx = new AudioContext();
48
- // make sure you copied the worklet processor!
49
- await ctx.audioWorklet.addModule("./worklet_processor.min.js");
50
- const synth = new Synthetizer(ctx.destination, sfont);
51
- document.getElementById("button").onclick = async () =>
52
- {
53
- await ctx.resume();
54
- synth.programChange(0, 48); // strings ensemble
55
- synth.noteOn(0, 52, 127);
56
- }
57
- ```
38
+ **SpessaSynth Project index**
58
39
 
59
- *Audio may sometimes sound distorted in Chromium-based browsers: Chrome, Edge, Brave,
60
- etc. due to a **[Chromium Bug](https://issues.chromium.org/issues/367304685).**
61
- I can't do anything about it, only hope that it gets fixed.
62
- 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
63
44
 
64
45
  ## Current Features
65
46
 
66
47
  ### [All the features of spessasynth_core!](https://github.com/spessasus/spessasynth_core?#current-features)
67
48
 
68
49
  ### On top of that...
50
+ - **Fully typed:** *Faster development and IDE auto-completion!*
69
51
  - **Modular design:** *Easy integration into other projects (load what you need)*
70
- - **[Detailed documentation:](https://github.com/spessasus/spessasynth_lib/wiki/Home)** *With [examples!](https://github.com/spessasus/spessasynth_lib/wiki/Getting-Started#examples)*
71
- - **Easy to Use:** *Basic setup is just [two lines of code!](https://github.com/spessasus/spessasynth_lib/wiki/Getting-Started#minimal-setup)*
52
+ - **[Detailed documentation:](https://spessasus.github.io/spessasynth_lib/)** *With [examples!](https://spessasus.github.io/spessasynth_lib/getting-started/#examples)*
53
+ - **Easy to Use:** *Basic setup is just [two lines of code!](https://spessasus.github.io/spessasynth_lib/getting-started/#minimal-setup)*
72
54
  - **No external dependencies:** *Just spessasynth_core!*
73
- - **Reverb and chorus support:** [customizable!](https://github.com/spessasus/spessasynth_lib/wiki/Synthetizer-Class#effects-configuration-object)
74
- - **Export audio files** using [OfflineAudioContext](https://developer.mozilla.org/en-US/docs/Web/API/OfflineAudioContext)
75
- - **Written using AudioWorklets:**
76
- - Runs in a **separate thread** for maximum performance
77
- - Does not stop playing even when the main thread is frozen
78
- - 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)!
79
66
  - **High-performance mode:** Play Rush E! *note: may kill your browser ;)*
80
67
 
81
- #### TODO
82
- - Enhance the built-in chorus and reverb effects (suggestions welcome!)
83
-
84
68
  ### Special Thanks
85
69
  - [FluidSynth](https://github.com/FluidSynth/fluidsynth) - for the source code that helped implement functionality and fixes
86
- - [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
87
71
  - [Meltysynth](https://github.com/sinshu/meltysynth) - for the initial low-pass filter implementation
88
72
  - [RecordingBlogs](https://www.recordingblogs.com/) - for detailed explanations on MIDI messages
89
73
  - [stbvorbis.js](https://github.com/hajimehoshi/stbvorbis.js) - for the Vorbis decoder
90
74
  - [fflate](https://github.com/101arrowz/fflate) - for the MIT DEFLATE implementation
75
+ - [tsup](https://github.com/egoist/tsup) - for the TypeScript bundler
91
76
  - [foo_midi](https://github.com/stuerp/foo_midi) - for useful resources on XMF file format
92
77
  - [Falcosoft](https://falcosoft.hu) - for help with the RMIDI format
93
78
  - [Christian Collins](https://schristiancollins.com) - for various bug reports regarding the synthesizer
94
79
  - **And You!** - for checking out this project. I hope you like it :)
95
80
 
96
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
+
97
103
  # License
98
104
  Copyright © 2025 Spessasus
99
105
  Licensed under the Apache-2.0 License.