spessasynth_lib 3.25.23 → 3.26.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 (162) hide show
  1. package/README.md +29 -114
  2. package/external_midi/midi_handler.js +14 -14
  3. package/external_midi/web_midi_link.js +3 -3
  4. package/index.js +33 -33
  5. package/package.json +19 -6
  6. package/{midi → sequencer}/midi_data.js +1 -1
  7. package/sequencer/{worklet_wrapper/sequencer.js → sequencer.js} +13 -12
  8. package/sequencer/{worklet_wrapper/sequencer_message.js → sequencer_message.js} +1 -1
  9. package/synthetizer/README.md +29 -1
  10. package/synthetizer/audio_effects/reverb_as_binary.js +2 -2
  11. package/synthetizer/{worklet_wrapper/key_modifier_manager.js → key_modifier_manager.js} +11 -2
  12. package/synthetizer/{worklet_wrapper/synth_event_handler.js → synth_event_handler.js} +16 -13
  13. package/synthetizer/{worklet_wrapper/synth_soundfont_manager.js → synth_soundfont_manager.js} +8 -5
  14. package/synthetizer/{worklet_wrapper/synthetizer.js → synthetizer.js} +29 -23
  15. package/synthetizer/{audio_engine/message_protocol/worklet_message.js → worklet_message.js} +15 -2
  16. package/synthetizer/{worklet_wrapper/worklet_processor.js → worklet_processor.js} +214 -31
  17. package/synthetizer/worklet_processor.min.js +13 -12
  18. package/synthetizer/worklet_processor.min.js.map +7 -0
  19. package/synthetizer/{worklet_wrapper/worklet_url.js → worklet_url.js} +2 -0
  20. package/utils/buffer_to_wav.js +7 -165
  21. package/utils/other.js +3 -84
  22. package/externals/fflate/LICENSE +0 -21
  23. package/externals/fflate/fflate.min.js +0 -1
  24. package/externals/stbvorbis_sync/@types/stbvorbis_sync.d.ts +0 -12
  25. package/externals/stbvorbis_sync/LICENSE +0 -202
  26. package/externals/stbvorbis_sync/NOTICE +0 -6
  27. package/externals/stbvorbis_sync/stbvorbis_sync.min.js +0 -1
  28. package/midi/README.md +0 -32
  29. package/midi/basic_midi.js +0 -565
  30. package/midi/midi_builder.js +0 -202
  31. package/midi/midi_loader.js +0 -324
  32. package/midi/midi_message.js +0 -254
  33. package/midi/midi_sequence.js +0 -225
  34. package/midi/midi_tools/get_note_times.js +0 -154
  35. package/midi/midi_tools/midi_editor.js +0 -611
  36. package/midi/midi_tools/midi_writer.js +0 -99
  37. package/midi/midi_tools/rmidi_writer.js +0 -567
  38. package/midi/midi_tools/used_keys_loaded.js +0 -238
  39. package/midi/xmf_loader.js +0 -454
  40. package/sequencer/sequencer_engine/events.js +0 -104
  41. package/sequencer/sequencer_engine/play.js +0 -353
  42. package/sequencer/sequencer_engine/process_event.js +0 -169
  43. package/sequencer/sequencer_engine/process_tick.js +0 -106
  44. package/sequencer/sequencer_engine/sequencer_engine.js +0 -335
  45. package/sequencer/sequencer_engine/song_control.js +0 -229
  46. package/soundfont/README.md +0 -13
  47. package/soundfont/basic_soundfont/basic_instrument.js +0 -77
  48. package/soundfont/basic_soundfont/basic_preset.js +0 -336
  49. package/soundfont/basic_soundfont/basic_sample.js +0 -197
  50. package/soundfont/basic_soundfont/basic_soundfont.js +0 -565
  51. package/soundfont/basic_soundfont/basic_zone.js +0 -64
  52. package/soundfont/basic_soundfont/basic_zones.js +0 -43
  53. package/soundfont/basic_soundfont/generator.js +0 -220
  54. package/soundfont/basic_soundfont/modulator.js +0 -378
  55. package/soundfont/basic_soundfont/riff_chunk.js +0 -149
  56. package/soundfont/basic_soundfont/write_dls/art2.js +0 -173
  57. package/soundfont/basic_soundfont/write_dls/articulator.js +0 -49
  58. package/soundfont/basic_soundfont/write_dls/combine_zones.js +0 -400
  59. package/soundfont/basic_soundfont/write_dls/ins.js +0 -103
  60. package/soundfont/basic_soundfont/write_dls/lins.js +0 -18
  61. package/soundfont/basic_soundfont/write_dls/modulator_converter.js +0 -330
  62. package/soundfont/basic_soundfont/write_dls/rgn2.js +0 -121
  63. package/soundfont/basic_soundfont/write_dls/wave.js +0 -94
  64. package/soundfont/basic_soundfont/write_dls/write_dls.js +0 -119
  65. package/soundfont/basic_soundfont/write_dls/wsmp.js +0 -78
  66. package/soundfont/basic_soundfont/write_dls/wvpl.js +0 -32
  67. package/soundfont/basic_soundfont/write_sf2/ibag.js +0 -39
  68. package/soundfont/basic_soundfont/write_sf2/igen.js +0 -80
  69. package/soundfont/basic_soundfont/write_sf2/imod.js +0 -46
  70. package/soundfont/basic_soundfont/write_sf2/inst.js +0 -34
  71. package/soundfont/basic_soundfont/write_sf2/pbag.js +0 -39
  72. package/soundfont/basic_soundfont/write_sf2/pgen.js +0 -82
  73. package/soundfont/basic_soundfont/write_sf2/phdr.js +0 -42
  74. package/soundfont/basic_soundfont/write_sf2/pmod.js +0 -46
  75. package/soundfont/basic_soundfont/write_sf2/sdta.js +0 -80
  76. package/soundfont/basic_soundfont/write_sf2/shdr.js +0 -55
  77. package/soundfont/basic_soundfont/write_sf2/write.js +0 -222
  78. package/soundfont/dls/articulator_converter.js +0 -396
  79. package/soundfont/dls/dls_destinations.js +0 -38
  80. package/soundfont/dls/dls_preset.js +0 -44
  81. package/soundfont/dls/dls_sample.js +0 -75
  82. package/soundfont/dls/dls_soundfont.js +0 -186
  83. package/soundfont/dls/dls_sources.js +0 -62
  84. package/soundfont/dls/dls_zone.js +0 -95
  85. package/soundfont/dls/read_articulation.js +0 -299
  86. package/soundfont/dls/read_instrument.js +0 -121
  87. package/soundfont/dls/read_instrument_list.js +0 -17
  88. package/soundfont/dls/read_lart.js +0 -35
  89. package/soundfont/dls/read_region.js +0 -152
  90. package/soundfont/dls/read_samples.js +0 -270
  91. package/soundfont/load_soundfont.js +0 -21
  92. package/soundfont/read_sf2/generators.js +0 -46
  93. package/soundfont/read_sf2/instruments.js +0 -66
  94. package/soundfont/read_sf2/modulators.js +0 -36
  95. package/soundfont/read_sf2/presets.js +0 -80
  96. package/soundfont/read_sf2/samples.js +0 -304
  97. package/soundfont/read_sf2/soundfont.js +0 -305
  98. package/soundfont/read_sf2/zones.js +0 -263
  99. package/synthetizer/audio_engine/README.md +0 -25
  100. package/synthetizer/audio_engine/engine_components/compute_modulator.js +0 -266
  101. package/synthetizer/audio_engine/engine_components/controller_tables.js +0 -88
  102. package/synthetizer/audio_engine/engine_components/key_modifier_manager.js +0 -149
  103. package/synthetizer/audio_engine/engine_components/lfo.js +0 -26
  104. package/synthetizer/audio_engine/engine_components/lowpass_filter.js +0 -282
  105. package/synthetizer/audio_engine/engine_components/midi_audio_channel.js +0 -471
  106. package/synthetizer/audio_engine/engine_components/modulation_envelope.js +0 -181
  107. package/synthetizer/audio_engine/engine_components/modulator_curves.js +0 -89
  108. package/synthetizer/audio_engine/engine_components/soundfont_manager.js +0 -228
  109. package/synthetizer/audio_engine/engine_components/stereo_panner.js +0 -120
  110. package/synthetizer/audio_engine/engine_components/unit_converter.js +0 -73
  111. package/synthetizer/audio_engine/engine_components/voice.js +0 -519
  112. package/synthetizer/audio_engine/engine_components/volume_envelope.js +0 -401
  113. package/synthetizer/audio_engine/engine_components/wavetable_oscillator.js +0 -263
  114. package/synthetizer/audio_engine/engine_methods/controller_control/controller_change.js +0 -132
  115. package/synthetizer/audio_engine/engine_methods/controller_control/master_parameters.js +0 -48
  116. package/synthetizer/audio_engine/engine_methods/controller_control/reset_controllers.js +0 -241
  117. package/synthetizer/audio_engine/engine_methods/create_midi_channel.js +0 -27
  118. package/synthetizer/audio_engine/engine_methods/data_entry/data_entry_coarse.js +0 -253
  119. package/synthetizer/audio_engine/engine_methods/data_entry/data_entry_fine.js +0 -66
  120. package/synthetizer/audio_engine/engine_methods/mute_channel.js +0 -17
  121. package/synthetizer/audio_engine/engine_methods/note_on.js +0 -175
  122. package/synthetizer/audio_engine/engine_methods/portamento_time.js +0 -92
  123. package/synthetizer/audio_engine/engine_methods/program_change.js +0 -61
  124. package/synthetizer/audio_engine/engine_methods/render_voice.js +0 -196
  125. package/synthetizer/audio_engine/engine_methods/soundfont_management/clear_sound_font.js +0 -30
  126. package/synthetizer/audio_engine/engine_methods/soundfont_management/get_preset.js +0 -22
  127. package/synthetizer/audio_engine/engine_methods/soundfont_management/reload_sound_font.js +0 -40
  128. package/synthetizer/audio_engine/engine_methods/soundfont_management/send_preset_list.js +0 -34
  129. package/synthetizer/audio_engine/engine_methods/soundfont_management/set_embedded_sound_font.js +0 -21
  130. package/synthetizer/audio_engine/engine_methods/stopping_notes/kill_note.js +0 -20
  131. package/synthetizer/audio_engine/engine_methods/stopping_notes/note_off.js +0 -55
  132. package/synthetizer/audio_engine/engine_methods/stopping_notes/stop_all_channels.js +0 -16
  133. package/synthetizer/audio_engine/engine_methods/stopping_notes/stop_all_notes.js +0 -30
  134. package/synthetizer/audio_engine/engine_methods/stopping_notes/voice_killing.js +0 -63
  135. package/synthetizer/audio_engine/engine_methods/system_exclusive.js +0 -776
  136. package/synthetizer/audio_engine/engine_methods/tuning_control/channel_pressure.js +0 -24
  137. package/synthetizer/audio_engine/engine_methods/tuning_control/pitch_wheel.js +0 -33
  138. package/synthetizer/audio_engine/engine_methods/tuning_control/poly_pressure.js +0 -31
  139. package/synthetizer/audio_engine/engine_methods/tuning_control/set_master_tuning.js +0 -15
  140. package/synthetizer/audio_engine/engine_methods/tuning_control/set_modulation_depth.js +0 -27
  141. package/synthetizer/audio_engine/engine_methods/tuning_control/set_octave_tuning.js +0 -19
  142. package/synthetizer/audio_engine/engine_methods/tuning_control/set_tuning.js +0 -27
  143. package/synthetizer/audio_engine/engine_methods/tuning_control/transpose_all_channels.js +0 -15
  144. package/synthetizer/audio_engine/engine_methods/tuning_control/transpose_channel.js +0 -34
  145. package/synthetizer/audio_engine/main_processor.js +0 -765
  146. package/synthetizer/audio_engine/message_protocol/README.md +0 -13
  147. package/synthetizer/audio_engine/message_protocol/message_sending.js +0 -22
  148. package/synthetizer/audio_engine/snapshot/apply_synthesizer_snapshot.js +0 -14
  149. package/synthetizer/audio_engine/snapshot/channel_snapshot.js +0 -175
  150. package/synthetizer/audio_engine/snapshot/synthesizer_snapshot.js +0 -122
  151. package/synthetizer/synth_constants.js +0 -20
  152. package/utils/README.md +0 -5
  153. package/utils/byte_functions/big_endian.js +0 -32
  154. package/utils/byte_functions/little_endian.js +0 -77
  155. package/utils/byte_functions/string.js +0 -107
  156. package/utils/byte_functions/variable_length_quantity.js +0 -42
  157. package/utils/indexed_array.js +0 -52
  158. package/utils/loggin.js +0 -79
  159. package/utils/sysex_detector.js +0 -58
  160. package/utils/xg_hacks.js +0 -193
  161. /package/sequencer/{worklet_wrapper/default_sequencer_options.js → default_sequencer_options.js} +0 -0
  162. /package/synthetizer/{worklet_wrapper/sfman_message.js → sfman_message.js} +0 -0
@@ -1,40 +0,0 @@
1
- import { loadSoundFont } from "../../../../soundfont/load_soundfont.js";
2
- import { returnMessageType } from "../../message_protocol/worklet_message.js";
3
- import { SpessaSynthInfo } from "../../../../utils/loggin.js";
4
- import { consoleColors } from "../../../../utils/other.js";
5
-
6
- /**
7
- * @param buffer {ArrayBuffer}
8
- * @param isOverride {Boolean}
9
- * @this {SpessaSynthProcessor}
10
- */
11
- export function reloadSoundFont(buffer, isOverride = false)
12
- {
13
- this.clearSoundFont(false, isOverride);
14
- try
15
- {
16
- if (isOverride)
17
- {
18
- this.overrideSoundfont = loadSoundFont(buffer);
19
- }
20
- else
21
- {
22
- this.soundfontManager.reloadManager(buffer);
23
- }
24
- }
25
- catch (e)
26
- {
27
- this.post({
28
- messageType: returnMessageType.soundfontError,
29
- messageData: e
30
- });
31
- return;
32
- }
33
- this.getDefaultPresets();
34
- this.midiAudioChannels.forEach(c =>
35
- c.programChange(c.preset.program)
36
- );
37
- this.postReady();
38
- this.sendPresetList();
39
- SpessaSynthInfo("%cSpessaSynth is ready!", consoleColors.recognized);
40
- }
@@ -1,34 +0,0 @@
1
- /**
2
- * @this {SpessaSynthProcessor}
3
- */
4
- export function sendPresetList()
5
- {
6
- /**
7
- * @type {{bank: number, presetName: string, program: number}[]}
8
- */
9
- const mainFont = this.soundfontManager.getPresetList();
10
- if (this.overrideSoundfont !== undefined)
11
- {
12
- this.overrideSoundfont.presets.forEach(p =>
13
- {
14
- const bankCheck = p.bank === 128 ? 128 : p.bank + this.soundfontBankOffset;
15
- const exists = mainFont.find(pr => pr.bank === bankCheck && pr.program === p.program);
16
- if (exists !== undefined)
17
- {
18
- exists.presetName = p.presetName;
19
- }
20
- else
21
- {
22
- mainFont.push({
23
- presetName: p.presetName,
24
- bank: bankCheck,
25
- program: p.program
26
- });
27
- }
28
- });
29
- }
30
- this.processorInitialized.then(() =>
31
- {
32
- this.callEvent("presetlistchange", mainFont);
33
- });
34
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Sets the embedded (RMI soundfont)
3
- * @param font {ArrayBuffer}
4
- * @param offset {number}
5
- * @this {SpessaSynthProcessor}
6
- */
7
- export function setEmbeddedSoundFont(font, offset)
8
- {
9
- // set offset
10
- this.soundfontBankOffset = offset;
11
- this.reloadSoundFont(font, true);
12
- // preload all samples
13
- this.overrideSoundfont.samples.forEach(s => s.getAudioData());
14
-
15
- // apply snapshot again if applicable
16
- if (this._snapshot !== undefined)
17
- {
18
- this.applySynthesizerSnapshot(this._snapshot);
19
- this.resetAllControllers();
20
- }
21
- }
@@ -1,20 +0,0 @@
1
- import { generatorTypes } from "../../../../soundfont/basic_soundfont/generator.js";
2
-
3
- /**
4
- * Stops a note nearly instantly
5
- * @param midiNote {number}
6
- * @param releaseTime {number} ticks
7
- * @this {MidiAudioChannel}
8
- */
9
- export function killNote(midiNote, releaseTime = -12000)
10
- {
11
- this.voices.forEach(v =>
12
- {
13
- if (v.realKey !== midiNote)
14
- {
15
- return;
16
- }
17
- v.modulatedGenerators[generatorTypes.releaseVolEnv] = releaseTime; // set release to be very short
18
- v.release(this.synth.currentSynthTime);
19
- });
20
- }
@@ -1,55 +0,0 @@
1
- import { SpessaSynthWarn } from "../../../../utils/loggin.js";
2
-
3
- /**
4
- * Release a note
5
- * @param midiNote {number}
6
- * @this {MidiAudioChannel}
7
- */
8
- export function noteOff(midiNote)
9
- {
10
- if (midiNote > 127 || midiNote < 0)
11
- {
12
- SpessaSynthWarn(`Received a noteOn for note`, midiNote, "Ignoring.");
13
- return;
14
- }
15
-
16
- let realKey = midiNote + this.channelTransposeKeyShift;
17
-
18
- // if high performance mode, kill notes instead of stopping them
19
- if (this.synth.highPerformanceMode)
20
- {
21
- // if the channel is percussion channel, do not kill the notes
22
- if (!this.drumChannel)
23
- {
24
- this.killNote(realKey, -6950);
25
- this.synth.callEvent("noteoff", {
26
- midiNote: midiNote,
27
- channel: this.channelNumber
28
- });
29
- return;
30
- }
31
- }
32
-
33
- const channelVoices = this.voices;
34
- channelVoices.forEach(v =>
35
- {
36
- if (v.realKey !== realKey || v.isInRelease === true)
37
- {
38
- return;
39
- }
40
- // if hold pedal, move to sustain
41
- if (this.holdPedal)
42
- {
43
- this.sustainedVoices.push(v);
44
- }
45
- else
46
- {
47
- v.release(this.synth.currentSynthTime);
48
- }
49
- });
50
- this.synth.callEvent("noteoff", {
51
- midiNote: midiNote,
52
- channel: this.channelNumber
53
- });
54
- }
55
-
@@ -1,16 +0,0 @@
1
- import { SpessaSynthInfo } from "../../../../utils/loggin.js";
2
- import { consoleColors } from "../../../../utils/other.js";
3
-
4
- /**
5
- * @this {SpessaSynthProcessor}
6
- * @param force {boolean}
7
- */
8
- export function stopAllChannels(force = false)
9
- {
10
- SpessaSynthInfo("%cStop all received!", consoleColors.info);
11
- for (let i = 0; i < this.midiAudioChannels.length; i++)
12
- {
13
- this.midiAudioChannels[i].stopAllNotes(force);
14
- }
15
- this.callEvent("stopall", undefined);
16
- }
@@ -1,30 +0,0 @@
1
- /**
2
- * stops all notes on a given channel
3
- * @param force {boolean}
4
- * @this {MidiAudioChannel}
5
- */
6
- export function stopAllNotes(force = false)
7
- {
8
- if (force)
9
- {
10
- // force stop all
11
- this.voices.length = 0;
12
- this.sustainedVoices.length = 0;
13
- this.sendChannelProperty();
14
- }
15
- else
16
- {
17
- this.voices.forEach(v =>
18
- {
19
- if (v.isInRelease)
20
- {
21
- return;
22
- }
23
- v.release(this.synth.currentSynthTime);
24
- });
25
- this.sustainedVoices.forEach(v =>
26
- {
27
- v.release(this.synth.currentSynthTime);
28
- });
29
- }
30
- }
@@ -1,63 +0,0 @@
1
- /**
2
- * @param channel {MidiAudioChannel}
3
- * @param voice {Voice}
4
- * @return {number}
5
- */
6
- function getPriority(channel, voice)
7
- {
8
- let priority = 0;
9
- if (channel.drumChannel)
10
- {
11
- // important
12
- priority += 5;
13
- }
14
- if (voice.isInRelease)
15
- {
16
- // not important
17
- priority -= 5;
18
- }
19
- // less velocity = less important
20
- priority += voice.velocity / 25; // map to 0-5
21
- // the newer, more important
22
- priority -= voice.volumeEnvelope.state;
23
- if (voice.isInRelease)
24
- {
25
- priority -= 5;
26
- }
27
- priority -= voice.volumeEnvelope.currentAttenuationDb / 50;
28
- return priority;
29
- }
30
-
31
- /**
32
- * @this {SpessaSynthProcessor}
33
- * @param amount {number}
34
- */
35
- export function voiceKilling(amount)
36
- {
37
- let allVoices = [];
38
- for (const channel of this.midiAudioChannels)
39
- {
40
- for (const voice of channel.voices)
41
- {
42
- if (!voice.finished)
43
- {
44
- const priority = getPriority(channel, voice);
45
- allVoices.push({ channel, voice, priority });
46
- }
47
- }
48
- }
49
-
50
- // Step 2: Sort voices by priority (ascending order)
51
- allVoices.sort((a, b) => a.priority - b.priority);
52
- const voicesToRemove = allVoices.slice(0, amount);
53
-
54
- for (const { channel, voice } of voicesToRemove)
55
- {
56
- const index = channel.voices.indexOf(voice);
57
- if (index > -1)
58
- {
59
- channel.voices.splice(index, 1);
60
- }
61
- }
62
- }
63
-