spessasynth_core 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 (157) hide show
  1. package/README.md +85 -51
  2. package/dist/index.d.ts +4057 -0
  3. package/dist/index.js +17178 -0
  4. package/dist/index.js.map +1 -0
  5. package/package.json +24 -6
  6. package/index.js +0 -132
  7. package/src/externals/README.md +0 -6
  8. package/src/externals/fflate/LICENSE +0 -21
  9. package/src/externals/fflate/fflate.min.js +0 -1
  10. package/src/externals/stbvorbis_sync/@types/stbvorbis_sync.d.ts +0 -12
  11. package/src/externals/stbvorbis_sync/LICENSE +0 -202
  12. package/src/externals/stbvorbis_sync/NOTICE +0 -6
  13. package/src/externals/stbvorbis_sync/stbvorbis_sync.min.js +0 -1
  14. package/src/midi/README.md +0 -32
  15. package/src/midi/basic_midi.js +0 -587
  16. package/src/midi/midi_builder.js +0 -203
  17. package/src/midi/midi_loader.js +0 -321
  18. package/src/midi/midi_message.js +0 -254
  19. package/src/midi/midi_sequence.js +0 -230
  20. package/src/midi/midi_tools/get_note_times.js +0 -154
  21. package/src/midi/midi_tools/midi_editor.js +0 -611
  22. package/src/midi/midi_tools/midi_writer.js +0 -105
  23. package/src/midi/midi_tools/rmidi_writer.js +0 -566
  24. package/src/midi/midi_tools/used_keys_loaded.js +0 -256
  25. package/src/midi/xmf_loader.js +0 -454
  26. package/src/sequencer/README.md +0 -9
  27. package/src/sequencer/events.js +0 -81
  28. package/src/sequencer/play.js +0 -362
  29. package/src/sequencer/process_event.js +0 -165
  30. package/src/sequencer/process_tick.js +0 -104
  31. package/src/sequencer/sequencer_engine.js +0 -372
  32. package/src/sequencer/song_control.js +0 -196
  33. package/src/soundfont/README.md +0 -11
  34. package/src/soundfont/basic_soundfont/basic_global_zone.js +0 -6
  35. package/src/soundfont/basic_soundfont/basic_instrument.js +0 -115
  36. package/src/soundfont/basic_soundfont/basic_instrument_zone.js +0 -45
  37. package/src/soundfont/basic_soundfont/basic_preset.js +0 -313
  38. package/src/soundfont/basic_soundfont/basic_preset_zone.js +0 -39
  39. package/src/soundfont/basic_soundfont/basic_sample.js +0 -477
  40. package/src/soundfont/basic_soundfont/basic_soundbank.js +0 -740
  41. package/src/soundfont/basic_soundfont/basic_zone.js +0 -145
  42. package/src/soundfont/basic_soundfont/generator.js +0 -76
  43. package/src/soundfont/basic_soundfont/generator_types.js +0 -151
  44. package/src/soundfont/basic_soundfont/modulator.js +0 -581
  45. package/src/soundfont/basic_soundfont/riff_chunk.js +0 -195
  46. package/src/soundfont/basic_soundfont/write_dls/art2.js +0 -174
  47. package/src/soundfont/basic_soundfont/write_dls/articulator.js +0 -49
  48. package/src/soundfont/basic_soundfont/write_dls/combine_zones.js +0 -374
  49. package/src/soundfont/basic_soundfont/write_dls/ins.js +0 -85
  50. package/src/soundfont/basic_soundfont/write_dls/lins.js +0 -15
  51. package/src/soundfont/basic_soundfont/write_dls/modulator_converter.js +0 -330
  52. package/src/soundfont/basic_soundfont/write_dls/rgn2.js +0 -120
  53. package/src/soundfont/basic_soundfont/write_dls/wave.js +0 -71
  54. package/src/soundfont/basic_soundfont/write_dls/write_dls.js +0 -124
  55. package/src/soundfont/basic_soundfont/write_dls/wsmp.js +0 -78
  56. package/src/soundfont/basic_soundfont/write_dls/wvpl.js +0 -35
  57. package/src/soundfont/basic_soundfont/write_sf2/ibag.js +0 -60
  58. package/src/soundfont/basic_soundfont/write_sf2/igen.js +0 -91
  59. package/src/soundfont/basic_soundfont/write_sf2/imod.js +0 -62
  60. package/src/soundfont/basic_soundfont/write_sf2/inst.js +0 -42
  61. package/src/soundfont/basic_soundfont/write_sf2/pbag.js +0 -57
  62. package/src/soundfont/basic_soundfont/write_sf2/pgen.js +0 -92
  63. package/src/soundfont/basic_soundfont/write_sf2/phdr.js +0 -61
  64. package/src/soundfont/basic_soundfont/write_sf2/pmod.js +0 -62
  65. package/src/soundfont/basic_soundfont/write_sf2/sdta.js +0 -131
  66. package/src/soundfont/basic_soundfont/write_sf2/shdr.js +0 -77
  67. package/src/soundfont/basic_soundfont/write_sf2/write.js +0 -287
  68. package/src/soundfont/dls/articulator_converter.js +0 -402
  69. package/src/soundfont/dls/dls_destinations.js +0 -38
  70. package/src/soundfont/dls/dls_instrument.js +0 -20
  71. package/src/soundfont/dls/dls_preset.js +0 -43
  72. package/src/soundfont/dls/dls_sample.js +0 -238
  73. package/src/soundfont/dls/dls_soundfont.js +0 -183
  74. package/src/soundfont/dls/dls_sources.js +0 -63
  75. package/src/soundfont/dls/dls_zone.js +0 -89
  76. package/src/soundfont/dls/read_articulation.js +0 -300
  77. package/src/soundfont/dls/read_instrument.js +0 -118
  78. package/src/soundfont/dls/read_instrument_list.js +0 -17
  79. package/src/soundfont/dls/read_lart.js +0 -35
  80. package/src/soundfont/dls/read_region.js +0 -157
  81. package/src/soundfont/dls/read_samples.js +0 -154
  82. package/src/soundfont/load_soundfont.js +0 -21
  83. package/src/soundfont/read_sf2/generators.js +0 -43
  84. package/src/soundfont/read_sf2/instrument_zones.js +0 -75
  85. package/src/soundfont/read_sf2/instruments.js +0 -71
  86. package/src/soundfont/read_sf2/modulators.js +0 -25
  87. package/src/soundfont/read_sf2/preset_zones.js +0 -79
  88. package/src/soundfont/read_sf2/presets.js +0 -80
  89. package/src/soundfont/read_sf2/samples.js +0 -317
  90. package/src/soundfont/read_sf2/soundfont.js +0 -452
  91. package/src/soundfont/read_sf2/zones.js +0 -28
  92. package/src/synthetizer/README.md +0 -7
  93. package/src/synthetizer/audio_engine/README.md +0 -9
  94. package/src/synthetizer/audio_engine/engine_components/compute_modulator.js +0 -289
  95. package/src/synthetizer/audio_engine/engine_components/controller_tables.js +0 -90
  96. package/src/synthetizer/audio_engine/engine_components/dynamic_modulator_system.js +0 -95
  97. package/src/synthetizer/audio_engine/engine_components/enums.js +0 -18
  98. package/src/synthetizer/audio_engine/engine_components/key_modifier_manager.js +0 -151
  99. package/src/synthetizer/audio_engine/engine_components/lfo.js +0 -26
  100. package/src/synthetizer/audio_engine/engine_components/lowpass_filter.js +0 -282
  101. package/src/synthetizer/audio_engine/engine_components/midi_audio_channel.js +0 -551
  102. package/src/synthetizer/audio_engine/engine_components/modulation_envelope.js +0 -181
  103. package/src/synthetizer/audio_engine/engine_components/modulator_curves.js +0 -89
  104. package/src/synthetizer/audio_engine/engine_components/soundfont_manager.js +0 -265
  105. package/src/synthetizer/audio_engine/engine_components/stereo_panner.js +0 -124
  106. package/src/synthetizer/audio_engine/engine_components/unit_converter.js +0 -73
  107. package/src/synthetizer/audio_engine/engine_components/voice.js +0 -525
  108. package/src/synthetizer/audio_engine/engine_components/volume_envelope.js +0 -402
  109. package/src/synthetizer/audio_engine/engine_components/wavetable_oscillator.js +0 -274
  110. package/src/synthetizer/audio_engine/engine_methods/controller_control/controller_change.js +0 -159
  111. package/src/synthetizer/audio_engine/engine_methods/controller_control/master_parameters.js +0 -53
  112. package/src/synthetizer/audio_engine/engine_methods/controller_control/reset_controllers.js +0 -254
  113. package/src/synthetizer/audio_engine/engine_methods/create_midi_channel.js +0 -20
  114. package/src/synthetizer/audio_engine/engine_methods/data_entry/awe32.js +0 -198
  115. package/src/synthetizer/audio_engine/engine_methods/data_entry/data_entry_coarse.js +0 -281
  116. package/src/synthetizer/audio_engine/engine_methods/data_entry/data_entry_fine.js +0 -109
  117. package/src/synthetizer/audio_engine/engine_methods/mute_channel.js +0 -17
  118. package/src/synthetizer/audio_engine/engine_methods/note_on.js +0 -220
  119. package/src/synthetizer/audio_engine/engine_methods/portamento_time.js +0 -92
  120. package/src/synthetizer/audio_engine/engine_methods/program_change.js +0 -35
  121. package/src/synthetizer/audio_engine/engine_methods/render_voice.js +0 -214
  122. package/src/synthetizer/audio_engine/engine_methods/soundfont_management/embedded_sound_bank.js +0 -42
  123. package/src/synthetizer/audio_engine/engine_methods/soundfont_management/get_preset.js +0 -0
  124. package/src/synthetizer/audio_engine/engine_methods/soundfont_management/update_preset_list.js +0 -19
  125. package/src/synthetizer/audio_engine/engine_methods/stopping_notes/kill_note.js +0 -23
  126. package/src/synthetizer/audio_engine/engine_methods/stopping_notes/note_off.js +0 -56
  127. package/src/synthetizer/audio_engine/engine_methods/stopping_notes/stop_all_channels.js +0 -16
  128. package/src/synthetizer/audio_engine/engine_methods/stopping_notes/stop_all_notes.js +0 -30
  129. package/src/synthetizer/audio_engine/engine_methods/stopping_notes/voice_killing.js +0 -63
  130. package/src/synthetizer/audio_engine/engine_methods/system_exclusive.js +0 -1058
  131. package/src/synthetizer/audio_engine/engine_methods/tuning_control/channel_pressure.js +0 -23
  132. package/src/synthetizer/audio_engine/engine_methods/tuning_control/pitch_wheel.js +0 -31
  133. package/src/synthetizer/audio_engine/engine_methods/tuning_control/poly_pressure.js +0 -29
  134. package/src/synthetizer/audio_engine/engine_methods/tuning_control/set_master_tuning.js +0 -15
  135. package/src/synthetizer/audio_engine/engine_methods/tuning_control/set_modulation_depth.js +0 -26
  136. package/src/synthetizer/audio_engine/engine_methods/tuning_control/set_octave_tuning.js +0 -19
  137. package/src/synthetizer/audio_engine/engine_methods/tuning_control/set_tuning.js +0 -27
  138. package/src/synthetizer/audio_engine/engine_methods/tuning_control/transpose_all_channels.js +0 -15
  139. package/src/synthetizer/audio_engine/engine_methods/tuning_control/transpose_channel.js +0 -34
  140. package/src/synthetizer/audio_engine/main_processor.js +0 -817
  141. package/src/synthetizer/audio_engine/snapshot/apply_synthesizer_snapshot.js +0 -16
  142. package/src/synthetizer/audio_engine/snapshot/channel_snapshot.js +0 -175
  143. package/src/synthetizer/audio_engine/snapshot/synthesizer_snapshot.js +0 -116
  144. package/src/synthetizer/audio_engine/synth_processor_options.js +0 -18
  145. package/src/synthetizer/synth_constants.js +0 -26
  146. package/src/utils/README.md +0 -8
  147. package/src/utils/buffer_to_wav.js +0 -197
  148. package/src/utils/byte_functions/big_endian.js +0 -32
  149. package/src/utils/byte_functions/little_endian.js +0 -77
  150. package/src/utils/byte_functions/string.js +0 -92
  151. package/src/utils/byte_functions/variable_length_quantity.js +0 -42
  152. package/src/utils/fill_with_defaults.js +0 -21
  153. package/src/utils/indexed_array.js +0 -34
  154. package/src/utils/loggin.js +0 -71
  155. package/src/utils/other.js +0 -92
  156. package/src/utils/sysex_detector.js +0 -58
  157. package/src/utils/xg_hacks.js +0 -193
@@ -1,402 +0,0 @@
1
- import { DLSSources } from "./dls_sources.js";
2
- import {
3
- DecodedModulator,
4
- getModSourceEnum,
5
- Modulator,
6
- modulatorCurveTypes,
7
- modulatorSources
8
- } from "../basic_soundfont/modulator.js";
9
- import { midiControllers } from "../../midi/midi_message.js";
10
- import { DLSDestinations } from "./dls_destinations.js";
11
-
12
- import { consoleColors } from "../../utils/other.js";
13
- import { SpessaSynthWarn } from "../../utils/loggin.js";
14
- import { generatorTypes } from "../basic_soundfont/generator_types.js";
15
-
16
- /**
17
- * @param source {number}
18
- * @returns {{enum: number, isCC: boolean}|undefined}
19
- */
20
- function getSF2SourceFromDLS(source)
21
- {
22
- let sourceEnum = undefined;
23
- let isCC = false;
24
- switch (source)
25
- {
26
- default:
27
- case DLSSources.modLfo:
28
- case DLSSources.vibratoLfo:
29
- case DLSSources.coarseTune:
30
- case DLSSources.fineTune:
31
- case DLSSources.modEnv:
32
- return undefined; // cannot be this in sf2
33
-
34
- case DLSSources.keyNum:
35
- sourceEnum = modulatorSources.noteOnKeyNum;
36
- break;
37
- case DLSSources.none:
38
- sourceEnum = modulatorSources.noController;
39
- break;
40
- case DLSSources.modulationWheel:
41
- sourceEnum = midiControllers.modulationWheel;
42
- isCC = true;
43
- break;
44
- case DLSSources.pan:
45
- sourceEnum = midiControllers.pan;
46
- isCC = true;
47
- break;
48
- case DLSSources.reverb:
49
- sourceEnum = midiControllers.reverbDepth;
50
- isCC = true;
51
- break;
52
- case DLSSources.chorus:
53
- sourceEnum = midiControllers.chorusDepth;
54
- isCC = true;
55
- break;
56
- case DLSSources.expression:
57
- sourceEnum = midiControllers.expressionController;
58
- isCC = true;
59
- break;
60
- case DLSSources.volume:
61
- sourceEnum = midiControllers.mainVolume;
62
- isCC = true;
63
- break;
64
- case DLSSources.velocity:
65
- sourceEnum = modulatorSources.noteOnVelocity;
66
- break;
67
- case DLSSources.polyPressure:
68
- sourceEnum = modulatorSources.polyPressure;
69
- break;
70
- case DLSSources.channelPressure:
71
- sourceEnum = modulatorSources.channelPressure;
72
- break;
73
- case DLSSources.pitchWheel:
74
- sourceEnum = modulatorSources.pitchWheel;
75
- break;
76
- case DLSSources.pitchWheelRange:
77
- sourceEnum = modulatorSources.pitchWheelRange;
78
- break;
79
- }
80
- if (sourceEnum === undefined)
81
- {
82
- throw new Error(`Unknown DLS Source: ${source}`);
83
- }
84
- return { enum: sourceEnum, isCC: isCC };
85
- }
86
-
87
- /**
88
- * @param destination {number}
89
- * @param amount {number}
90
- * @returns {generatorTypes|{gen: generatorTypes, newAmount: number}} // transform amount to sf2 units
91
- */
92
- function getSF2GeneratorFromDLS(destination, amount)
93
- {
94
- switch (destination)
95
- {
96
- default:
97
- case DLSDestinations.none:
98
- return undefined;
99
- case DLSDestinations.pan:
100
- return generatorTypes.pan;
101
- case DLSDestinations.gain:
102
- return { gen: generatorTypes.initialAttenuation, newAmount: amount * -1 };
103
- case DLSDestinations.pitch:
104
- return generatorTypes.fineTune;
105
- case DLSDestinations.keyNum:
106
- return generatorTypes.overridingRootKey;
107
-
108
- // vol env
109
- case DLSDestinations.volEnvDelay:
110
- return generatorTypes.delayVolEnv;
111
- case DLSDestinations.volEnvAttack:
112
- return generatorTypes.attackVolEnv;
113
- case DLSDestinations.volEnvHold:
114
- return generatorTypes.holdVolEnv;
115
- case DLSDestinations.volEnvDecay:
116
- return generatorTypes.decayVolEnv;
117
- case DLSDestinations.volEnvSustain:
118
- return { gen: generatorTypes.sustainVolEnv, newAmount: 1000 - amount };
119
- case DLSDestinations.volEnvRelease:
120
- return generatorTypes.releaseVolEnv;
121
-
122
- // mod env
123
- case DLSDestinations.modEnvDelay:
124
- return generatorTypes.delayModEnv;
125
- case DLSDestinations.modEnvAttack:
126
- return generatorTypes.attackModEnv;
127
- case DLSDestinations.modEnvHold:
128
- return generatorTypes.holdModEnv;
129
- case DLSDestinations.modEnvDecay:
130
- return generatorTypes.decayModEnv;
131
- case DLSDestinations.modEnvSustain:
132
- return { gen: generatorTypes.sustainModEnv, newAmount: (1000 - amount) / 10 };
133
- case DLSDestinations.modEnvRelease:
134
- return generatorTypes.releaseModEnv;
135
-
136
- case DLSDestinations.filterCutoff:
137
- return generatorTypes.initialFilterFc;
138
- case DLSDestinations.filterQ:
139
- return generatorTypes.initialFilterQ;
140
- case DLSDestinations.chorusSend:
141
- return generatorTypes.chorusEffectsSend;
142
- case DLSDestinations.reverbSend:
143
- return generatorTypes.reverbEffectsSend;
144
-
145
- // lfo
146
- case DLSDestinations.modLfoFreq:
147
- return generatorTypes.freqModLFO;
148
- case DLSDestinations.modLfoDelay:
149
- return generatorTypes.delayModLFO;
150
- case DLSDestinations.vibLfoFreq:
151
- return generatorTypes.freqVibLFO;
152
- case DLSDestinations.vibLfoDelay:
153
- return generatorTypes.delayVibLFO;
154
- }
155
- }
156
-
157
- /**
158
- * checks for combos such as mod lfo as source and pitch as destination which results in modLfoToPitch
159
- * @param source {number}
160
- * @param destination {number}
161
- * @returns {generatorTypes} real destination
162
- */
163
- function checkForSpecialDLSCombo(source, destination)
164
- {
165
- if (source === DLSSources.vibratoLfo && destination === DLSDestinations.pitch)
166
- {
167
- // vibrato lfo to pitch
168
- return generatorTypes.vibLfoToPitch;
169
- }
170
- else if (source === DLSSources.modLfo && destination === DLSDestinations.pitch)
171
- {
172
- // mod lfo to pitch
173
- return generatorTypes.modLfoToPitch;
174
- }
175
- else if (source === DLSSources.modLfo && destination === DLSDestinations.filterCutoff)
176
- {
177
- // mod lfo to filter
178
- return generatorTypes.modLfoToFilterFc;
179
- }
180
- else if (source === DLSSources.modLfo && destination === DLSDestinations.gain)
181
- {
182
- // mod lfo to volume
183
- return generatorTypes.modLfoToVolume;
184
- }
185
- else if (source === DLSSources.modEnv && destination === DLSDestinations.filterCutoff)
186
- {
187
- // mod envelope to filter
188
- return generatorTypes.modEnvToFilterFc;
189
- }
190
- else if (source === DLSSources.modEnv && destination === DLSDestinations.pitch)
191
- {
192
- // mod envelope to pitch
193
- return generatorTypes.modEnvToPitch;
194
- }
195
- else
196
- {
197
- return undefined;
198
- }
199
- }
200
-
201
- // noinspection JSUnusedGlobalSymbols
202
- /**
203
- * @param source {number}
204
- * @param control {number}
205
- * @param destination {number}
206
- * @param value {number}
207
- * @param transform {number}
208
- * @param msg {string}
209
- */
210
- export function modulatorConverterDebug(
211
- source,
212
- control,
213
- destination,
214
- value,
215
- transform,
216
- msg = "Attempting to convert the following DLS Articulator to SF2 Modulator:"
217
- )
218
- {
219
- const type = Object.keys(DLSDestinations).find(k => DLSDestinations[k] === destination);
220
- const srcType = Object.keys(DLSSources).find(k => DLSSources[k] === source);
221
- const ctrlType = Object.keys(DLSSources).find(k => DLSSources[k] === control);
222
- const typeString = type ? type : destination.toString(16);
223
- const srcString = srcType ? srcType : source.toString(16);
224
- const ctrlString = ctrlType ? ctrlType : control.toString(16);
225
- console.debug(
226
- `%c${msg}
227
- Source: %c${srcString}%c
228
- Control: %c${ctrlString}%c
229
- Destination: %c${typeString}%c
230
- Amount: %c${value}%c
231
- Transform: %c${transform}%c...`,
232
- consoleColors.info,
233
- consoleColors.recognized,
234
- consoleColors.info,
235
- consoleColors.recognized,
236
- consoleColors.info,
237
- consoleColors.recognized,
238
- consoleColors.info,
239
- consoleColors.recognized,
240
- consoleColors.info,
241
- consoleColors.recognized,
242
- consoleColors.info
243
- );
244
- }
245
-
246
- /**
247
- * @param source {number}
248
- * @param control {number}
249
- * @param destination {number}
250
- * @param transform {number}
251
- * @param value {number}
252
- * @returns {Modulator|undefined}
253
- */
254
- export function getSF2ModulatorFromArticulator(
255
- source,
256
- control,
257
- destination,
258
- transform,
259
- value
260
- )
261
- {
262
- // modulatorConverterDebug(
263
- // source,
264
- // control,
265
- // destination,
266
- // value,
267
- // transform
268
- // );
269
- // check for special combinations
270
- const specialDestination = checkForSpecialDLSCombo(source, destination);
271
- /**
272
- * @type {generatorTypes}
273
- */
274
- let destinationGenerator;
275
- /**
276
- * @type {{enum: number, isCC: boolean}}
277
- */
278
- let sf2Source;
279
- let swapSources = false;
280
- let isSourceNoController = false;
281
- let newValue = value;
282
- if (specialDestination === undefined)
283
- {
284
- // determine destination
285
- const sf2GenDestination = getSF2GeneratorFromDLS(destination, value);
286
- if (sf2GenDestination === undefined)
287
- {
288
- // cannot be a valid modulator
289
- SpessaSynthWarn(`Invalid destination: ${destination}`);
290
- return undefined;
291
- }
292
- /**
293
- * @type {generatorTypes}
294
- */
295
- destinationGenerator = sf2GenDestination;
296
- if (sf2GenDestination.newAmount !== undefined)
297
- {
298
- newValue = sf2GenDestination.newAmount;
299
- destinationGenerator = sf2GenDestination.gen;
300
- }
301
- sf2Source = getSF2SourceFromDLS(source);
302
- if (sf2Source === undefined)
303
- {
304
- // cannot be a valid modulator
305
- SpessaSynthWarn(`Invalid source: ${source}`);
306
- return undefined;
307
- }
308
- }
309
- else
310
- {
311
- destinationGenerator = specialDestination;
312
- swapSources = true;
313
- sf2Source = { enum: modulatorSources.noController, isCC: false };
314
- isSourceNoController = true;
315
- }
316
- let sf2SecondSource = getSF2SourceFromDLS(control);
317
- if (sf2SecondSource === undefined)
318
- {
319
- // cannot be a valid modulator
320
- SpessaSynthWarn(`Invalid control: ${control}`);
321
- return undefined;
322
- }
323
-
324
- // get transforms and final enums
325
- let sourceEnumFinal;
326
- if (isSourceNoController)
327
- {
328
- // we force it into this state because before it was some strange value,
329
- // like vibrato lfo bipolar, for example,
330
- // since we turn it into NoController -> vibLfoToPitch,
331
- // the result is the same and bipolar controller is technically 0
332
- sourceEnumFinal = 0x0;
333
- }
334
- else
335
- {
336
- // output transform is ignored as it's not a thing in sfont format
337
- // unless the curve type of source is linear, then output is copied
338
- const outputTransform = transform & 0b1111;
339
- // source curve type maps to a desfont curve type in section 2.10, table 9
340
- let sourceTransform = (transform >> 10) & 0b1111;
341
- if (sourceTransform === modulatorCurveTypes.linear && outputTransform !== modulatorCurveTypes.linear)
342
- {
343
- sourceTransform = outputTransform;
344
- }
345
- const sourceIsBipolar = (transform >> 14) & 1;
346
- let sourceIsNegative = (transform >> 15) & 1;
347
- // special case: for attenuation, invert source (dls gain is the opposite of sf2 attenuation)
348
- if (destinationGenerator === generatorTypes.initialAttenuation)
349
- {
350
- // if the value is negative, the source shall be negative!
351
- // why?
352
- // IDK, it makes it work with ROCK.RMI and NOKIA_S30.dls
353
- if (value < 0)
354
- {
355
- sourceIsNegative = 1;
356
- }
357
- }
358
- sourceEnumFinal = getModSourceEnum(
359
- sourceTransform,
360
- sourceIsBipolar,
361
- sourceIsNegative,
362
- sf2Source.isCC,
363
- sf2Source.enum
364
- );
365
- }
366
-
367
- // a corrupted rendition of gm.dls was found under
368
- // https://sembiance.com/fileFormatSamples/audio/downloadableSoundBank/
369
- // which specifies a whopping -32,768 decibels of attenuation
370
- if (destinationGenerator === generatorTypes.initialAttenuation)
371
- {
372
- newValue = Math.max(960, Math.min(0, newValue));
373
- }
374
-
375
- const secSourceTransform = (transform >> 4) & 0b1111;
376
- const secSourceIsBipolar = (transform >> 8) & 1;
377
- const secSourceIsNegative = transform >> 9 & 1;
378
- let secSourceEnumFinal = getModSourceEnum(
379
- secSourceTransform,
380
- secSourceIsBipolar,
381
- secSourceIsNegative,
382
- sf2SecondSource.isCC,
383
- sf2SecondSource.enum
384
- );
385
-
386
- if (swapSources)
387
- {
388
- const temp = secSourceEnumFinal;
389
- secSourceEnumFinal = sourceEnumFinal;
390
- sourceEnumFinal = temp;
391
- }
392
-
393
- // return the modulator!
394
- return new DecodedModulator(
395
- sourceEnumFinal,
396
- secSourceEnumFinal,
397
- destinationGenerator,
398
- newValue,
399
- 0x0
400
- );
401
-
402
- }
@@ -1,38 +0,0 @@
1
- /**
2
- *
3
- * @enum {number}
4
- */
5
- export const DLSDestinations = {
6
- none: 0x0, // no destination
7
- gain: 0x1, // linear gain
8
- reserved: 0x2, // reserved
9
- pitch: 0x3, // pitch in cents
10
- pan: 0x4, // pan 10ths of a percent
11
- keyNum: 0x5, // MIDI key number
12
- // nuh uh, the channel controllers are not supported!
13
- chorusSend: 0x80, // chorus send level 10ths of a percent
14
- reverbSend: 0x81, // reverb send level 10ths of a percent
15
-
16
- modLfoFreq: 0x104, // modulation LFO frequency
17
- modLfoDelay: 0x105, // modulation LFO delay
18
-
19
- vibLfoFreq: 0x114, // vibrato LFO frequency
20
- vibLfoDelay: 0x115, // vibrato LFO delay
21
-
22
- volEnvAttack: 0x206, // volume envelope attack
23
- volEnvDecay: 0x207, // volume envelope decay
24
- volEnvRelease: 0x209, // volume envelope release
25
- volEnvSustain: 0x20a, // volume envelope sustain
26
- volEnvDelay: 0x20b, // volume envelope delay
27
- volEnvHold: 0x20c, // volume envelope hold
28
-
29
- modEnvAttack: 0x30a, // modulation envelope attack
30
- modEnvDecay: 0x30b, // modulation envelope decay
31
- modEnvRelease: 0x30d, // modulation envelope release
32
- modEnvSustain: 0x30e, // modulation envelope sustain
33
- modEnvDelay: 0x30f, // modulation envelope delay
34
- modEnvHold: 0x310, // modulation envelope hold
35
-
36
- filterCutoff: 0x500, // low pass filter cutoff frequency
37
- filterQ: 0x501 // low pass filter resonance
38
- };
@@ -1,20 +0,0 @@
1
- import { BasicInstrument } from "../basic_soundfont/basic_instrument.js";
2
- import { DLSZone } from "./dls_zone.js";
3
-
4
- export class DLSInstrument extends BasicInstrument
5
- {
6
- constructor()
7
- {
8
- super();
9
- }
10
-
11
- /**
12
- * @returns {DLSZone}
13
- */
14
- createZone()
15
- {
16
- const z = new DLSZone(this);
17
- this.instrumentZones.push(z);
18
- return z;
19
- }
20
- }
@@ -1,43 +0,0 @@
1
- import { BasicPreset } from "../basic_soundfont/basic_preset.js";
2
- import { DLSInstrument } from "./dls_instrument.js";
3
-
4
- export class DLSPreset extends BasicPreset
5
- {
6
- /**
7
- * @type {DLSInstrument}
8
- */
9
- dlsInstrument = new DLSInstrument();
10
-
11
- /**
12
- * Creates a new DLS preset
13
- * @param dls {BasicSoundBank}
14
- * @param ulBank {number}
15
- * @param ulInstrument {number}
16
- */
17
- constructor(dls, ulBank, ulInstrument)
18
- {
19
- // use stock default modulators, dls won't ever have DMOD chunk
20
- super(dls);
21
- this.program = ulInstrument & 127;
22
- const bankMSB = (ulBank >> 8) & 127;
23
- const bankLSB = ulBank & 127;
24
- // switch accordingly
25
- if (bankMSB > 0)
26
- {
27
- this.bank = bankMSB;
28
- }
29
- else
30
- {
31
- this.bank = bankLSB;
32
- }
33
- const isDrums = ulBank >> 31;
34
- if (isDrums)
35
- {
36
- // soundfont bank is 128, so we change it here
37
- this.bank = 128;
38
- }
39
-
40
- const zone = this.createZone();
41
- zone.setInstrument(this.dlsInstrument);
42
- }
43
- }