spessasynth_core 3.27.8 → 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 (157) hide show
  1. package/README.md +85 -51
  2. package/dist/index.d.ts +4057 -0
  3. package/dist/index.js +17188 -0
  4. package/dist/index.js.map +1 -0
  5. package/package.json +23 -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
@@ -0,0 +1,4057 @@
1
+ /**
2
+ * Indexed_array.ts
3
+ * purpose: extends Uint8Array with a currentIndex property.
4
+ */
5
+ declare class IndexedByteArray extends Uint8Array {
6
+ /**
7
+ * The current index of the array.
8
+ */
9
+ currentIndex: number;
10
+ /**
11
+ * Returns a section of an array.
12
+ * @param start The beginning of the specified portion of the array.
13
+ * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'.
14
+ */
15
+ slice(start?: number, end?: number): IndexedByteArray;
16
+ }
17
+
18
+ /**
19
+ * Writes an audio into a valid WAV file.
20
+ * @param audioData the audio data channels.
21
+ * @param sampleRate the sample rate, in Hertz.
22
+ * @param options Additional options for writing the file.
23
+ * @returns the binary file.
24
+ */
25
+ declare function audioToWav(audioData: Float32Array[], sampleRate: number, options?: Partial<WaveWriteOptions>): ArrayBuffer;
26
+
27
+ /**
28
+ * Reads number as Big endian.
29
+ * @param dataArray the array to read from.
30
+ * @param bytesAmount the number of bytes to read.
31
+ * @param offset the offset to start reading from.
32
+ * @returns the number.
33
+ */
34
+ declare function readBigEndian(dataArray: number[] | ArrayLike<number>, bytesAmount: number, offset?: number): number;
35
+
36
+ /**
37
+ * Reads the number as little endian from an IndexedByteArray.
38
+ * @param dataArray the array to read from.
39
+ * @param bytesAmount the number of bytes to read.
40
+ * @returns the number.
41
+ */
42
+ declare function readLittleEndianIndexed(dataArray: IndexedByteArray, bytesAmount: number): number;
43
+
44
+ /**
45
+ * Reads bytes as an ASCII string from an IndexedByteArray.
46
+ * @param dataArray the IndexedByteArray to read from.
47
+ * @param bytes the amount of bytes to read.
48
+ * @returns the string.
49
+ */
50
+ declare function readBinaryStringIndexed(dataArray: IndexedByteArray, bytes: number): string;
51
+
52
+ /**
53
+ * Reads VLQ from a MIDI byte array.
54
+ * @param MIDIbyteArray the array to read from.
55
+ * @returns the number.
56
+ */
57
+ declare function readVariableLengthQuantity(MIDIbyteArray: IndexedByteArray): number;
58
+
59
+ /**
60
+ * Enables or disables logging.
61
+ * @param enableInfo enables info.
62
+ * @param enableWarn enables warning.
63
+ * @param enableGroup enables groups.
64
+ */
65
+ declare function SpessaSynthLogging(enableInfo: boolean, enableWarn: boolean, enableGroup: boolean): void;
66
+ declare function SpessaSynthInfo(...message: unknown[]): void;
67
+ declare function SpessaSynthWarn(...message: unknown[]): void;
68
+ declare function SpessaSynthGroup(...message: unknown[]): void;
69
+ declare function SpessaSynthGroupCollapsed(...message: unknown[]): void;
70
+ declare function SpessaSynthGroupEnd(): void;
71
+
72
+ /**
73
+ * All SoundFont2 Generator enumerations.
74
+ */
75
+ declare const generatorTypes: {
76
+ readonly INVALID: -1;
77
+ readonly startAddrsOffset: 0;
78
+ readonly endAddrOffset: 1;
79
+ readonly startloopAddrsOffset: 2;
80
+ readonly endloopAddrsOffset: 3;
81
+ readonly startAddrsCoarseOffset: 4;
82
+ readonly modLfoToPitch: 5;
83
+ readonly vibLfoToPitch: 6;
84
+ readonly modEnvToPitch: 7;
85
+ readonly initialFilterFc: 8;
86
+ readonly initialFilterQ: 9;
87
+ readonly modLfoToFilterFc: 10;
88
+ readonly modEnvToFilterFc: 11;
89
+ readonly endAddrsCoarseOffset: 12;
90
+ readonly modLfoToVolume: 13;
91
+ readonly unused1: 14;
92
+ readonly chorusEffectsSend: 15;
93
+ readonly reverbEffectsSend: 16;
94
+ readonly pan: 17;
95
+ readonly unused2: 18;
96
+ readonly unused3: 19;
97
+ readonly unused4: 20;
98
+ readonly delayModLFO: 21;
99
+ readonly freqModLFO: 22;
100
+ readonly delayVibLFO: 23;
101
+ readonly freqVibLFO: 24;
102
+ readonly delayModEnv: 25;
103
+ readonly attackModEnv: 26;
104
+ readonly holdModEnv: 27;
105
+ readonly decayModEnv: 28;
106
+ readonly sustainModEnv: 29;
107
+ readonly releaseModEnv: 30;
108
+ readonly keyNumToModEnvHold: 31;
109
+ readonly keyNumToModEnvDecay: 32;
110
+ readonly delayVolEnv: 33;
111
+ readonly attackVolEnv: 34;
112
+ readonly holdVolEnv: 35;
113
+ readonly decayVolEnv: 36;
114
+ readonly sustainVolEnv: 37;
115
+ readonly releaseVolEnv: 38;
116
+ readonly keyNumToVolEnvHold: 39;
117
+ readonly keyNumToVolEnvDecay: 40;
118
+ readonly instrument: 41;
119
+ readonly reserved1: 42;
120
+ readonly keyRange: 43;
121
+ readonly velRange: 44;
122
+ readonly startloopAddrsCoarseOffset: 45;
123
+ readonly keyNum: 46;
124
+ readonly velocity: 47;
125
+ readonly initialAttenuation: 48;
126
+ readonly reserved2: 49;
127
+ readonly endloopAddrsCoarseOffset: 50;
128
+ readonly coarseTune: 51;
129
+ readonly fineTune: 52;
130
+ readonly sampleID: 53;
131
+ readonly sampleModes: 54;
132
+ readonly reserved3: 55;
133
+ readonly scaleTuning: 56;
134
+ readonly exclusiveClass: 57;
135
+ readonly overridingRootKey: 58;
136
+ readonly unused5: 59;
137
+ readonly endOper: 60;
138
+ readonly vibLfoToVolume: 61;
139
+ readonly vibLfoToFilterFc: 62;
140
+ };
141
+ type GeneratorType = (typeof generatorTypes)[keyof typeof generatorTypes];
142
+ declare const GENERATORS_AMOUNT: number;
143
+ declare const MAX_GENERATOR: number;
144
+ /**
145
+ * Min: minimum value, max: maximum value, def: default value, nrpn: nrpn scale...
146
+ */
147
+ declare const generatorLimits: {
148
+ min: number;
149
+ max: number;
150
+ def: number;
151
+ nrpn: number;
152
+ }[];
153
+
154
+ /**
155
+ * Returned structure containing extended SF2 chunks.
156
+ */
157
+ interface ExtendedSF2Chunks {
158
+ /**
159
+ * The PDTA part of the chunk.
160
+ */
161
+ pdta: IndexedByteArray;
162
+ /**
163
+ * The XDTA (https://github.com/spessasus/soundfont-proposals/blob/main/extended_limits.md) part of the chunk.
164
+ */
165
+ xdta: IndexedByteArray;
166
+ }
167
+ /**
168
+ * Write indexes for tracking writing a SoundFont file.
169
+ */
170
+ interface SoundFontWriteIndexes {
171
+ /**
172
+ * Generator start index.
173
+ */
174
+ gen: number;
175
+ /**
176
+ * Modulator start index.
177
+ */
178
+ mod: number;
179
+ /**
180
+ * Zone start index.
181
+ */
182
+ bag: number;
183
+ /**
184
+ * Preset/instrument start index.
185
+ */
186
+ hdr: number;
187
+ }
188
+
189
+ declare class Generator {
190
+ /**
191
+ * The generator's SF2 type.
192
+ */
193
+ generatorType: GeneratorType;
194
+ /**
195
+ * The generator's 16-bit value.
196
+ */
197
+ generatorValue: number;
198
+ /**
199
+ * Constructs a new generator
200
+ * @param type generator type
201
+ * @param value generator value
202
+ * @param validate if the limits should be validated
203
+ */
204
+ constructor(type: GeneratorType, value: number, validate?: boolean);
205
+ write(genData: IndexedByteArray, indexes: SoundFontWriteIndexes): void;
206
+ toString(): string;
207
+ }
208
+
209
+ declare const sampleTypes: {
210
+ readonly monoSample: 1;
211
+ readonly rightSample: 2;
212
+ readonly leftSample: 4;
213
+ readonly linkedSample: 8;
214
+ readonly romMonoSample: 32769;
215
+ readonly romRightSample: 32770;
216
+ readonly romLeftSample: 32772;
217
+ readonly romLinkedSample: 32776;
218
+ };
219
+ type SampleType = (typeof sampleTypes)[keyof typeof sampleTypes];
220
+ declare const modulatorSources: {
221
+ readonly noController: 0;
222
+ readonly noteOnVelocity: 2;
223
+ readonly noteOnKeyNum: 3;
224
+ readonly polyPressure: 10;
225
+ readonly channelPressure: 13;
226
+ readonly pitchWheel: 14;
227
+ readonly pitchWheelRange: 16;
228
+ readonly link: 127;
229
+ };
230
+ type ModulatorSourceEnum = (typeof modulatorSources)[keyof typeof modulatorSources];
231
+ declare const modulatorCurveTypes: {
232
+ readonly linear: 0;
233
+ readonly concave: 1;
234
+ readonly convex: 2;
235
+ readonly switch: 3;
236
+ };
237
+ type ModulatorCurveType = (typeof modulatorCurveTypes)[keyof typeof modulatorCurveTypes];
238
+ declare const modulatorTransformTypes: {
239
+ readonly linear: 0;
240
+ readonly absolute: 2;
241
+ };
242
+ type ModulatorTransformType = (typeof modulatorTransformTypes)[keyof typeof modulatorTransformTypes];
243
+ type DLSTransform = ModulatorCurveType;
244
+ declare const dlsSources: {
245
+ readonly none: 0;
246
+ readonly modLfo: 1;
247
+ readonly velocity: 2;
248
+ readonly keyNum: 3;
249
+ readonly volEnv: 4;
250
+ readonly modEnv: 5;
251
+ readonly pitchWheel: 6;
252
+ readonly polyPressure: 7;
253
+ readonly channelPressure: 8;
254
+ readonly vibratoLfo: 9;
255
+ readonly modulationWheel: 129;
256
+ readonly volume: 135;
257
+ readonly pan: 138;
258
+ readonly expression: 139;
259
+ readonly chorus: 221;
260
+ readonly reverb: 219;
261
+ readonly pitchWheelRange: 256;
262
+ readonly fineTune: 257;
263
+ readonly coarseTune: 258;
264
+ };
265
+ type DLSSource = (typeof dlsSources)[keyof typeof dlsSources];
266
+ declare const dlsDestinations: {
267
+ readonly none: 0;
268
+ readonly gain: 1;
269
+ readonly reserved: 2;
270
+ readonly pitch: 3;
271
+ readonly pan: 4;
272
+ readonly keyNum: 5;
273
+ readonly chorusSend: 128;
274
+ readonly reverbSend: 129;
275
+ readonly modLfoFreq: 260;
276
+ readonly modLfoDelay: 261;
277
+ readonly vibLfoFreq: 276;
278
+ readonly vibLfoDelay: 277;
279
+ readonly volEnvAttack: 518;
280
+ readonly volEnvDecay: 519;
281
+ readonly reservedEG1: 520;
282
+ readonly volEnvRelease: 521;
283
+ readonly volEnvSustain: 522;
284
+ readonly volEnvDelay: 523;
285
+ readonly volEnvHold: 524;
286
+ readonly modEnvAttack: 778;
287
+ readonly modEnvDecay: 779;
288
+ readonly reservedEG2: 780;
289
+ readonly modEnvRelease: 781;
290
+ readonly modEnvSustain: 782;
291
+ readonly modEnvDelay: 783;
292
+ readonly modEnvHold: 784;
293
+ readonly filterCutoff: 1280;
294
+ readonly filterQ: 1281;
295
+ };
296
+ type DLSDestination = (typeof dlsDestinations)[keyof typeof dlsDestinations];
297
+ declare const DLSLoopTypes: {
298
+ readonly forward: 0;
299
+ readonly loopAndRelease: 1;
300
+ };
301
+ type DLSLoopType = (typeof DLSLoopTypes)[keyof typeof DLSLoopTypes];
302
+
303
+ declare class BasicZone {
304
+ /**
305
+ * The zone's velocity range.
306
+ * min -1 means that it is a default value
307
+ */
308
+ velRange: GenericRange;
309
+ /**
310
+ * The zone's key range.
311
+ * min -1 means that it is a default value.
312
+ */
313
+ keyRange: GenericRange;
314
+ /**
315
+ * The zone's generators.
316
+ */
317
+ generators: Generator[];
318
+ /**
319
+ * The zone's modulators.
320
+ */
321
+ modulators: Modulator[];
322
+ get hasKeyRange(): boolean;
323
+ get hasVelRange(): boolean;
324
+ /**
325
+ * The current tuning in cents, taking in both coarse and fine generators.
326
+ */
327
+ get fineTuning(): number;
328
+ /**
329
+ * The current tuning in cents, taking in both coarse and fine generators.
330
+ */
331
+ set fineTuning(tuningCents: number);
332
+ /**
333
+ * Adds to a given generator, or its default value.
334
+ */
335
+ addToGenerator(type: GeneratorType, value: number, validate?: boolean): void;
336
+ /**
337
+ * Sets a generator to a given value if preset, otherwise adds a new one.
338
+ */
339
+ setGenerator(type: GeneratorType, value: number | undefined, validate?: boolean): void;
340
+ /**
341
+ * Adds generators to the zone.
342
+ * @param generators
343
+ */
344
+ addGenerators(...generators: Generator[]): void;
345
+ addModulators(...modulators: Modulator[]): void;
346
+ getGenerator<K>(generatorType: GeneratorType, notFoundValue: number | K): number | K;
347
+ copyFrom(zone: BasicZone): void;
348
+ getGenCount(): number;
349
+ write(genData: IndexedByteArray, modData: IndexedByteArray, bagData: ExtendedSF2Chunks, indexes: SoundFontWriteIndexes, bank: BasicSoundBank): void;
350
+ /**
351
+ * Filters the generators and prepends the range generators.
352
+ */
353
+ protected getWriteGenerators(bank: BasicSoundBank): Generator[];
354
+ }
355
+
356
+ declare class BasicGlobalZone extends BasicZone {
357
+ }
358
+
359
+ declare class BasicInstrumentZone extends BasicZone {
360
+ /**
361
+ * The instrument this zone belongs to.
362
+ */
363
+ readonly parentInstrument: BasicInstrument;
364
+ /**
365
+ * For tracking on the individual zone level, since multiple presets can refer to the same instrument.
366
+ */
367
+ useCount: number;
368
+ /**
369
+ * Creates a new instrument zone.
370
+ * @param instrument The parent instrument.
371
+ * @param sample The sample to use in this zone.
372
+ */
373
+ constructor(instrument: BasicInstrument, sample: BasicSample);
374
+ /**
375
+ * Zone's sample.
376
+ */
377
+ private _sample;
378
+ /**
379
+ * Zone's sample.
380
+ */
381
+ get sample(): BasicSample;
382
+ /**
383
+ * Sets a sample for this zone.
384
+ * @param sample the sample to set.
385
+ */
386
+ set sample(sample: BasicSample);
387
+ getGenCount(): number;
388
+ getWriteGenerators(bank: BasicSoundBank): Generator[];
389
+ }
390
+
391
+ declare class BasicPresetZone extends BasicZone {
392
+ /**
393
+ * The preset this zone belongs to.
394
+ */
395
+ readonly parentPreset: BasicPreset;
396
+ /**
397
+ * Creates a new preset zone.
398
+ * @param preset the preset this zone belongs to.
399
+ * @param instrument the instrument to use in this zone.
400
+ */
401
+ constructor(preset: BasicPreset, instrument: BasicInstrument);
402
+ /**
403
+ * Zone's instrument.
404
+ */
405
+ private _instrument;
406
+ /**
407
+ * Zone's instrument.
408
+ */
409
+ get instrument(): BasicInstrument;
410
+ /**
411
+ * Zone's instrument.
412
+ */
413
+ set instrument(instrument: BasicInstrument);
414
+ getGenCount(): number;
415
+ getWriteGenerators(bank: BasicSoundBank): Generator[];
416
+ }
417
+
418
+ interface MIDIPatch {
419
+ /**
420
+ * The MIDI program number.
421
+ */
422
+ program: number;
423
+ /**
424
+ * The MIDI bank MSB number.
425
+ */
426
+ bankMSB: number;
427
+ /**
428
+ * The MIDI bank LSB number.
429
+ */
430
+ bankLSB: number;
431
+ /**
432
+ * If the preset is marked as GM/GS drum preset. Note that XG drums do not have this flag.
433
+ */
434
+ isGMGSDrum: boolean;
435
+ }
436
+ interface MIDIPatchNamed extends MIDIPatch {
437
+ /**
438
+ * The name of the patch.
439
+ */
440
+ name: string;
441
+ }
442
+ declare class MIDIPatchTools {
443
+ /**
444
+ * Converts a MIDI patch to a string.
445
+ */
446
+ static toMIDIString(patch: MIDIPatch): string;
447
+ /**
448
+ * Gets a MIDI patch from a string.
449
+ * @param string
450
+ */
451
+ static fromMIDIString(string: string): MIDIPatch;
452
+ /**
453
+ * Converts a named MIDI patch to string.
454
+ * @param patch
455
+ */
456
+ static toNamedMIDIString(patch: MIDIPatchNamed): string;
457
+ /**
458
+ * Checks if two MIDI patches match.
459
+ * @param patch1
460
+ * @param patch2
461
+ */
462
+ static matches(patch1: MIDIPatch, patch2: MIDIPatch): boolean;
463
+ /**
464
+ * Gets a named MIDI patch from a string.
465
+ * @param string
466
+ */
467
+ static fromNamedMIDIString(string: string): MIDIPatchNamed;
468
+ static sorter(a: MIDIPatch, b: MIDIPatch): number;
469
+ }
470
+
471
+ declare class BasicPreset implements MIDIPatchNamed {
472
+ /**
473
+ * The parent soundbank instance
474
+ * Currently used for determining default modulators and XG status
475
+ */
476
+ readonly parentSoundBank: BasicSoundBank;
477
+ /**
478
+ * The preset's name
479
+ */
480
+ name: string;
481
+ program: number;
482
+ bankMSB: number;
483
+ bankLSB: number;
484
+ isGMGSDrum: boolean;
485
+ /**
486
+ * The preset's zones
487
+ */
488
+ zones: BasicPresetZone[];
489
+ /**
490
+ * Preset's global zone
491
+ */
492
+ readonly globalZone: BasicGlobalZone;
493
+ /**
494
+ * Unused metadata
495
+ */
496
+ library: number;
497
+ /**
498
+ * Unused metadata
499
+ */
500
+ genre: number;
501
+ /**
502
+ * Unused metadata
503
+ */
504
+ morphology: number;
505
+ /**
506
+ * Creates a new preset representation.
507
+ * @param parentSoundBank the sound bank this preset belongs to.
508
+ * @param globalZone optional, a global zone to use.
509
+ */
510
+ constructor(parentSoundBank: BasicSoundBank, globalZone?: BasicGlobalZone);
511
+ get isXGDrums(): boolean;
512
+ /**
513
+ * Checks if this preset is a drum preset
514
+ */
515
+ get isAnyDrums(): boolean;
516
+ /**
517
+ * Unlinks everything from this preset.
518
+ */
519
+ delete(): void;
520
+ /**
521
+ * Deletes an instrument zone from this preset.
522
+ * @param index the zone's index to delete.
523
+ */
524
+ deleteZone(index: number): void;
525
+ /**
526
+ * Creates a new preset zone and returns it.
527
+ * @param instrument the instrument to use in the zone.
528
+ */
529
+ createZone(instrument: BasicInstrument): BasicPresetZone;
530
+ /**
531
+ * Preloads (loads and caches synthesis data) for a given key range.
532
+ */
533
+ preload(keyMin: number, keyMax: number): void;
534
+ /**
535
+ * Checks if the bank and program numbers are the same for the given preset as this one.
536
+ * @param preset The preset to check.
537
+ */
538
+ matches(preset: MIDIPatch): boolean;
539
+ getSize(): {
540
+ mod: number;
541
+ bag: number;
542
+ gen: number;
543
+ hdr: number;
544
+ };
545
+ /**
546
+ * Returns the synthesis data from this preset
547
+ * @param midiNote the MIDI note number
548
+ * @param velocity the MIDI velocity
549
+ * @returns the returned sound data
550
+ */
551
+ getSynthesisData(midiNote: number, velocity: number): VoiceSynthesisData[];
552
+ /**
553
+ * BankMSB:bankLSB:program:isGMGSDrum
554
+ */
555
+ toMIDIString(): string;
556
+ toString(): string;
557
+ /**
558
+ * Combines preset into an instrument, flattening the preset zones into instrument zones.
559
+ * This is a really complex function that attempts to work around the DLS limitations of only having the instrument layer.
560
+ * @returns The instrument containing the flattened zones. In theory, it should exactly the same as this preset.
561
+ */
562
+ toFlattenedInstrument(): BasicInstrument;
563
+ write(genData: IndexedByteArray, modData: IndexedByteArray, bagData: ExtendedSF2Chunks, phdrData: ExtendedSF2Chunks, indexes: SoundFontWriteIndexes, bank: BasicSoundBank): void;
564
+ }
565
+
566
+ /**
567
+ * Represents a single instrument
568
+ */
569
+ declare class BasicInstrument {
570
+ /**
571
+ * The instrument's name
572
+ */
573
+ name: string;
574
+ /**
575
+ * The instrument's zones
576
+ */
577
+ zones: BasicInstrumentZone[];
578
+ /**
579
+ * Instrument's global zone
580
+ */
581
+ readonly globalZone: BasicGlobalZone;
582
+ /**
583
+ * Instrument's linked presets (the presets that use it)
584
+ * note that duplicates are allowed since one preset can use the same instrument multiple times.
585
+ */
586
+ readonly linkedTo: BasicPreset[];
587
+ /**
588
+ * How many presets is this instrument used by
589
+ */
590
+ get useCount(): number;
591
+ /**
592
+ * Creates a new instrument zone and returns it.
593
+ * @param sample The sample to use in the zone.
594
+ */
595
+ createZone(sample: BasicSample): BasicInstrumentZone;
596
+ /**
597
+ * Links the instrument ta a given preset
598
+ * @param preset the preset to link to
599
+ */
600
+ linkTo(preset: BasicPreset): void;
601
+ /**
602
+ * Unlinks the instrument from a given preset
603
+ * @param preset the preset to unlink from
604
+ */
605
+ unlinkFrom(preset: BasicPreset): void;
606
+ deleteUnusedZones(): void;
607
+ delete(): void;
608
+ /**
609
+ * Deletes a given instrument zone if it has no uses
610
+ * @param index the index of the zone to delete
611
+ * @param force ignores the use count and deletes forcibly
612
+ * @returns if the zone has been deleted
613
+ */
614
+ deleteZone(index: number, force?: boolean): boolean;
615
+ /**
616
+ * Globalizes the instrument *in-place.*
617
+ * This means trying to move as many generators and modulators
618
+ * to the global zone as possible to reduce clutter and the count of parameters.
619
+ */
620
+ globalize(): void;
621
+ getSize(): {
622
+ mod: number;
623
+ bag: number;
624
+ gen: number;
625
+ hdr: number;
626
+ };
627
+ write(genData: IndexedByteArray, modData: IndexedByteArray, bagData: ExtendedSF2Chunks, instData: ExtendedSF2Chunks, indexes: SoundFontWriteIndexes, bank: BasicSoundBank): void;
628
+ }
629
+
630
+ declare class BasicSample {
631
+ /**
632
+ * The sample's name.
633
+ */
634
+ name: string;
635
+ /**
636
+ * Sample rate in Hz.
637
+ */
638
+ sampleRate: number;
639
+ /**
640
+ * Original pitch of the sample as a MIDI note number.
641
+ */
642
+ originalKey: number;
643
+ /**
644
+ * Pitch correction, in cents. Can be negative.
645
+ */
646
+ pitchCorrection: number;
647
+ /**
648
+ * Linked sample, unused if mono.
649
+ */
650
+ linkedSample?: BasicSample;
651
+ /**
652
+ * The type of the sample.
653
+ */
654
+ sampleType: SampleType;
655
+ /**
656
+ * Relative to the start of the sample in sample points.
657
+ */
658
+ loopStart: number;
659
+ /**
660
+ * Relative to the start of the sample in sample points.
661
+ */
662
+ loopEnd: number;
663
+ /**
664
+ * Sample's linked instruments (the instruments that use it)
665
+ * note that duplicates are allowed since one instrument can use the same sample multiple times.
666
+ */
667
+ linkedTo: BasicInstrument[];
668
+ /**
669
+ * Indicates if the data was overridden, so it cannot be copied back unchanged.
670
+ */
671
+ protected dataOverridden: boolean;
672
+ /**
673
+ * The compressed sample data if the sample has been compressed.
674
+ */
675
+ protected compressedData?: Uint8Array;
676
+ /**
677
+ * The sample's audio data.
678
+ */
679
+ protected audioData?: Float32Array;
680
+ /**
681
+ * The basic representation of a sample
682
+ * @param sampleName The sample's name
683
+ * @param sampleRate The sample's rate in Hz
684
+ * @param originalKey The sample's pitch as a MIDI note number
685
+ * @param pitchCorrection The sample's pitch correction in cents
686
+ * @param sampleType The sample's type, an enum that can indicate SF3
687
+ * @param loopStart The sample's loop start relative to the sample start in sample points
688
+ * @param loopEnd The sample's loop end relative to the sample start in sample points
689
+ */
690
+ constructor(sampleName: string, sampleRate: number, originalKey: number, pitchCorrection: number, sampleType: SampleType, loopStart: number, loopEnd: number);
691
+ /**
692
+ * Indicates if the sample is compressed using vorbis SF3.
693
+ */
694
+ get isCompressed(): boolean;
695
+ /**
696
+ * If the sample is linked to another sample.
697
+ */
698
+ get isLinked(): boolean;
699
+ /**
700
+ * The sample's use count
701
+ */
702
+ get useCount(): number;
703
+ /**
704
+ * Get raw data for writing the file, either a compressed bit stream or signed 16-bit little endian PCM data.
705
+ * @param allowVorbis if vorbis file data is allowed.
706
+ * @return either s16le or vorbis data.
707
+ */
708
+ getRawData(allowVorbis: boolean): Uint8Array;
709
+ /**
710
+ * Resamples the audio data to a given sample rate.
711
+ */
712
+ resampleData(newSampleRate: number): void;
713
+ /**
714
+ * Compresses the audio data
715
+ * @param encodeVorbis the compression function to use when compressing
716
+ */
717
+ compressSample(encodeVorbis: SampleEncodingFunction): Promise<void>;
718
+ /**
719
+ * Sets the sample type and unlinks if needed.
720
+ * @param type The type to set it to.
721
+ */
722
+ setSampleType(type: SampleType): void;
723
+ /**
724
+ * Unlinks the sample from its stereo link if it has any.
725
+ */
726
+ unlinkSample(): void;
727
+ /**
728
+ * Links a stereo sample.
729
+ * @param sample the sample to link to.
730
+ * @param type either left, right or linked.
731
+ */
732
+ setLinkedSample(sample: BasicSample, type: SampleType): void;
733
+ /**
734
+ * Links the sample to a given instrument
735
+ * @param instrument the instrument to link to
736
+ */
737
+ linkTo(instrument: BasicInstrument): void;
738
+ /**
739
+ * Unlinks the sample from a given instrument
740
+ * @param instrument the instrument to unlink from
741
+ */
742
+ unlinkFrom(instrument: BasicInstrument): void;
743
+ /**
744
+ * Get the float32 audio data.
745
+ * Note that this either decodes the compressed data or passes the ready sampleData.
746
+ * If neither are set then it will throw an error!
747
+ * @returns the audio data
748
+ */
749
+ getAudioData(): Float32Array;
750
+ /**
751
+ * Replaces the audio data *in-place*.
752
+ * @param audioData The new audio data as Float32.
753
+ * @param sampleRate The new sample rate, in Hertz.
754
+ */
755
+ setAudioData(audioData: Float32Array, sampleRate: number): void;
756
+ /**
757
+ * Replaces the audio with a compressed data sample and flags the sample as compressed
758
+ * @param data the new compressed data
759
+ */
760
+ setCompressedData(data: Uint8Array): void;
761
+ /**
762
+ * Encodes s16le sample
763
+ * @return the encoded data
764
+ */
765
+ protected encodeS16LE(): IndexedByteArray;
766
+ /**
767
+ * Decode binary vorbis into a float32 pcm
768
+ */
769
+ protected decodeVorbis(): Float32Array;
770
+ }
771
+ declare class EmptySample extends BasicSample {
772
+ /**
773
+ * A simplified class for creating samples.
774
+ */
775
+ constructor();
776
+ }
777
+
778
+ declare const midiMessageTypes: {
779
+ readonly noteOff: 128;
780
+ readonly noteOn: 144;
781
+ readonly polyPressure: 160;
782
+ readonly controllerChange: 176;
783
+ readonly programChange: 192;
784
+ readonly channelPressure: 208;
785
+ readonly pitchWheel: 224;
786
+ readonly systemExclusive: 240;
787
+ readonly timecode: 241;
788
+ readonly songPosition: 242;
789
+ readonly songSelect: 243;
790
+ readonly tuneRequest: 246;
791
+ readonly clock: 248;
792
+ readonly start: 250;
793
+ readonly continue: 251;
794
+ readonly stop: 252;
795
+ readonly activeSensing: 254;
796
+ readonly reset: 255;
797
+ readonly sequenceNumber: 0;
798
+ readonly text: 1;
799
+ readonly copyright: 2;
800
+ readonly trackName: 3;
801
+ readonly instrumentName: 4;
802
+ readonly lyric: 5;
803
+ readonly marker: 6;
804
+ readonly cuePoint: 7;
805
+ readonly programName: 8;
806
+ readonly midiChannelPrefix: 32;
807
+ readonly midiPort: 33;
808
+ readonly endOfTrack: 47;
809
+ readonly setTempo: 81;
810
+ readonly smpteOffset: 84;
811
+ readonly timeSignature: 88;
812
+ readonly keySignature: 89;
813
+ readonly sequenceSpecific: 127;
814
+ };
815
+ type MIDIMessageType = (typeof midiMessageTypes)[keyof typeof midiMessageTypes];
816
+ declare const midiControllers: {
817
+ readonly bankSelect: 0;
818
+ readonly modulationWheel: 1;
819
+ readonly breathController: 2;
820
+ readonly undefinedCC3: 3;
821
+ readonly footController: 4;
822
+ readonly portamentoTime: 5;
823
+ readonly dataEntryMSB: 6;
824
+ readonly mainVolume: 7;
825
+ readonly balance: 8;
826
+ readonly undefinedCC9: 9;
827
+ readonly pan: 10;
828
+ readonly expressionController: 11;
829
+ readonly effectControl1: 12;
830
+ readonly effectControl2: 13;
831
+ readonly undefinedCC14: 14;
832
+ readonly undefinedCC15: 15;
833
+ readonly generalPurposeController1: 16;
834
+ readonly generalPurposeController2: 17;
835
+ readonly generalPurposeController3: 18;
836
+ readonly generalPurposeController4: 19;
837
+ readonly undefinedCC20: 20;
838
+ readonly undefinedCC21: 21;
839
+ readonly undefinedCC22: 22;
840
+ readonly undefinedCC23: 23;
841
+ readonly undefinedCC24: 24;
842
+ readonly undefinedCC25: 25;
843
+ readonly undefinedCC26: 26;
844
+ readonly undefinedCC27: 27;
845
+ readonly undefinedCC28: 28;
846
+ readonly undefinedCC29: 29;
847
+ readonly undefinedCC30: 30;
848
+ readonly undefinedCC31: 31;
849
+ readonly bankSelectLSB: 32;
850
+ readonly modulationWheelLSB: 33;
851
+ readonly breathControllerLSB: 34;
852
+ readonly undefinedCC3LSB: 35;
853
+ readonly footControllerLSB: 36;
854
+ readonly portamentoTimeLSB: 37;
855
+ readonly dataEntryLSB: 38;
856
+ readonly mainVolumeLSB: 39;
857
+ readonly balanceLSB: 40;
858
+ readonly undefinedCC9LSB: 41;
859
+ readonly panLSB: 42;
860
+ readonly expressionControllerLSB: 43;
861
+ readonly effectControl1LSB: 44;
862
+ readonly effectControl2LSB: 45;
863
+ readonly undefinedCC14LSB: 46;
864
+ readonly undefinedCC15LSB: 47;
865
+ readonly undefinedCC16LSB: 48;
866
+ readonly undefinedCC17LSB: 49;
867
+ readonly undefinedCC18LSB: 50;
868
+ readonly undefinedCC19LSB: 51;
869
+ readonly undefinedCC20LSB: 52;
870
+ readonly undefinedCC21LSB: 53;
871
+ readonly undefinedCC22LSB: 54;
872
+ readonly undefinedCC23LSB: 55;
873
+ readonly undefinedCC24LSB: 56;
874
+ readonly undefinedCC25LSB: 57;
875
+ readonly undefinedCC26LSB: 58;
876
+ readonly undefinedCC27LSB: 59;
877
+ readonly undefinedCC28LSB: 60;
878
+ readonly undefinedCC29LSB: 61;
879
+ readonly undefinedCC30LSB: 62;
880
+ readonly undefinedCC31LSB: 63;
881
+ readonly sustainPedal: 64;
882
+ readonly portamentoOnOff: 65;
883
+ readonly sostenutoPedal: 66;
884
+ readonly softPedal: 67;
885
+ readonly legatoFootswitch: 68;
886
+ readonly hold2Pedal: 69;
887
+ readonly soundVariation: 70;
888
+ readonly filterResonance: 71;
889
+ readonly releaseTime: 72;
890
+ readonly attackTime: 73;
891
+ readonly brightness: 74;
892
+ readonly decayTime: 75;
893
+ readonly vibratoRate: 76;
894
+ readonly vibratoDepth: 77;
895
+ readonly vibratoDelay: 78;
896
+ readonly soundController10: 79;
897
+ readonly generalPurposeController5: 80;
898
+ readonly generalPurposeController6: 81;
899
+ readonly generalPurposeController7: 82;
900
+ readonly generalPurposeController8: 83;
901
+ readonly portamentoControl: 84;
902
+ readonly undefinedCC85: 85;
903
+ readonly undefinedCC86: 86;
904
+ readonly undefinedCC87: 87;
905
+ readonly undefinedCC88: 88;
906
+ readonly undefinedCC89: 89;
907
+ readonly undefinedCC90: 90;
908
+ readonly reverbDepth: 91;
909
+ readonly tremoloDepth: 92;
910
+ readonly chorusDepth: 93;
911
+ readonly detuneDepth: 94;
912
+ readonly phaserDepth: 95;
913
+ readonly dataIncrement: 96;
914
+ readonly dataDecrement: 97;
915
+ readonly nonRegisteredParameterLSB: 98;
916
+ readonly nonRegisteredParameterMSB: 99;
917
+ readonly registeredParameterLSB: 100;
918
+ readonly registeredParameterMSB: 101;
919
+ readonly undefinedCC102LSB: 102;
920
+ readonly undefinedCC103LSB: 103;
921
+ readonly undefinedCC104LSB: 104;
922
+ readonly undefinedCC105LSB: 105;
923
+ readonly undefinedCC106LSB: 106;
924
+ readonly undefinedCC107LSB: 107;
925
+ readonly undefinedCC108LSB: 108;
926
+ readonly undefinedCC109LSB: 109;
927
+ readonly undefinedCC110LSB: 110;
928
+ readonly undefinedCC111LSB: 111;
929
+ readonly undefinedCC112LSB: 112;
930
+ readonly undefinedCC113LSB: 113;
931
+ readonly undefinedCC114LSB: 114;
932
+ readonly undefinedCC115LSB: 115;
933
+ readonly undefinedCC116LSB: 116;
934
+ readonly undefinedCC117LSB: 117;
935
+ readonly undefinedCC118LSB: 118;
936
+ readonly undefinedCC119LSB: 119;
937
+ readonly allSoundOff: 120;
938
+ readonly resetAllControllers: 121;
939
+ readonly localControlOnOff: 122;
940
+ readonly allNotesOff: 123;
941
+ readonly omniModeOff: 124;
942
+ readonly omniModeOn: 125;
943
+ readonly monoModeOn: 126;
944
+ readonly polyModeOn: 127;
945
+ };
946
+ type MIDIController = (typeof midiControllers)[keyof typeof midiControllers];
947
+
948
+ type GenericRIFFFourCC = "RIFF" | "LIST" | "INFO";
949
+ type WAVFourCC = "wave" | "cue " | "fmt ";
950
+ type FourCC = GenericRIFFFourCC | SoundBankInfoFourCC | SF2InfoFourCC | SF2ChunkFourCC | DLSInfoFourCC | DLSChunkFourCC | RMIDInfoFourCC | WAVFourCC;
951
+
952
+ interface SoundBankManagerListEntry {
953
+ /**
954
+ * The unique string identifier of the sound bank.
955
+ */
956
+ id: string;
957
+ /**
958
+ * The sound bank itself.
959
+ */
960
+ soundBank: BasicSoundBank;
961
+ /**
962
+ * The bank MSB offset for this sound bank.
963
+ */
964
+ bankOffset: number;
965
+ }
966
+ interface SF2VersionTag {
967
+ /**
968
+ * The major revision number of the sound bank.
969
+ */
970
+ major: number;
971
+ /**
972
+ * The minor revision number of this sound bank.
973
+ */
974
+ minor: number;
975
+ }
976
+ type GenericBankInfoFourCC = "INAM" | "ICRD" | "IENG" | "IPRD" | "ICOP" | "ICMT" | "ISFT";
977
+ type SF2InfoFourCC = GenericBankInfoFourCC | "ifil" | "isng" | "irom" | "iver" | "DMOD" | "LIST";
978
+ type SF2ChunkFourCC = "pdta" | "xdta" | "sdta" | "smpl" | "sm24" | "phdr" | "pbag" | "pmod" | "pgen" | "inst" | "ibag" | "imod" | "igen" | "shdr";
979
+ type DLSInfoFourCC = GenericBankInfoFourCC | "ISBJ";
980
+ type DLSChunkFourCC = WAVFourCC | "dls " | "dlid" | "cdl " | "ptbl" | "vers" | "colh" | "wvpl" | "wsmp" | "data" | "lart" | "lar2" | "art2" | "art1" | "lrgn" | "rgnh" | "wlnk" | "lins" | "ins " | "insh" | "rgn " | "rgn2" | "pgal";
981
+ interface SoundBankInfoData {
982
+ /**
983
+ * Name.
984
+ */
985
+ name: string;
986
+ /**
987
+ * The sound bank's version.
988
+ */
989
+ version: SF2VersionTag;
990
+ /**
991
+ * Creation date.
992
+ */
993
+ creationDate: Date;
994
+ /**
995
+ * Sound engine.
996
+ */
997
+ soundEngine: string;
998
+ /**
999
+ * Author.
1000
+ */
1001
+ engineer?: string;
1002
+ /**
1003
+ * Product.
1004
+ */
1005
+ product?: string;
1006
+ /**
1007
+ * Copyright.
1008
+ */
1009
+ copyright?: string;
1010
+ /**
1011
+ * Comment.
1012
+ */
1013
+ comment?: string;
1014
+ /**
1015
+ * Subject.
1016
+ */
1017
+ subject?: string;
1018
+ /**
1019
+ * ROM information.
1020
+ */
1021
+ romInfo?: string;
1022
+ /**
1023
+ * Software used to edit the file.
1024
+ */
1025
+ software?: string;
1026
+ /**
1027
+ * A tag that only applies to SF2 and will usually be undefined.
1028
+ */
1029
+ romVersion?: SF2VersionTag;
1030
+ }
1031
+ type SoundBankInfoFourCC = keyof SoundBankInfoData;
1032
+ interface VoiceSynthesisData {
1033
+ instrumentGenerators: Generator[];
1034
+ presetGenerators: Generator[];
1035
+ modulators: Modulator[];
1036
+ sample: BasicSample;
1037
+ }
1038
+ type SampleEncodingFunction = (audioData: Float32Array, sampleRate: number) => Promise<Uint8Array>;
1039
+ type ModulatorSourceIndex = ModulatorSourceEnum | MIDIController;
1040
+ /**
1041
+ * A function to track progress during writing.
1042
+ */
1043
+ type ProgressFunction = (
1044
+ /**
1045
+ * The written sample name.
1046
+ */
1047
+ sampleName: string,
1048
+ /**
1049
+ * The sample's index.
1050
+ */
1051
+ sampleIndex: number,
1052
+ /**
1053
+ * The total sample count for progress displaying.
1054
+ */
1055
+ sampleCount: number) => Promise<unknown>;
1056
+ /**
1057
+ * Options for writing a SoundFont2 file.
1058
+ */
1059
+ interface SoundFont2WriteOptions {
1060
+ /**
1061
+ * If the soundfont should be compressed with a given function.
1062
+ */
1063
+ compress: boolean;
1064
+ /**
1065
+ * The function for compressing samples. It can be undefined if not compressed.
1066
+ */
1067
+ compressionFunction?: SampleEncodingFunction;
1068
+ /**
1069
+ * A function to show progress for writing large banks. It can be undefined.
1070
+ */
1071
+ progressFunction?: ProgressFunction;
1072
+ /**
1073
+ * If the DMOD chunk should be written. Recommended.
1074
+ * Note that it will only be written if the modulators are unchanged.
1075
+ */
1076
+ writeDefaultModulators: boolean;
1077
+ /**
1078
+ * If the XDTA chunk should be written to allow virtually infinite parameters. Recommended.
1079
+ * Note that it will only be written needed.
1080
+ */
1081
+ writeExtendedLimits: boolean;
1082
+ /**
1083
+ * If an SF3 bank should be decompressed back to SF2. Not recommended.
1084
+ */
1085
+ decompress: boolean;
1086
+ }
1087
+ /**
1088
+ * Options for writing a DLS file.
1089
+ */
1090
+ interface DLSWriteOptions {
1091
+ /**
1092
+ * A function to show progress for writing large banks. It can be undefined.
1093
+ */
1094
+ progressFunction?: ProgressFunction;
1095
+ }
1096
+ interface GenericRange {
1097
+ min: number;
1098
+ max: number;
1099
+ }
1100
+ interface DLSLoop {
1101
+ loopType: DLSLoopType;
1102
+ loopStart: number;
1103
+ loopLength: number;
1104
+ }
1105
+
1106
+ declare const interpolationTypes: {
1107
+ readonly linear: 0;
1108
+ readonly nearestNeighbor: 1;
1109
+ readonly hermite: 2;
1110
+ };
1111
+ type InterpolationType = (typeof interpolationTypes)[keyof typeof interpolationTypes];
1112
+ declare const synthDisplayTypes: {
1113
+ readonly soundCanvasText: 0;
1114
+ readonly yamahaXGText: 1;
1115
+ readonly soundCanvasDotMatrix: 2;
1116
+ };
1117
+ type SynthDisplayType = (typeof synthDisplayTypes)[keyof typeof synthDisplayTypes];
1118
+ declare const dataEntryStates: {
1119
+ readonly Idle: 0;
1120
+ readonly RPCoarse: 1;
1121
+ readonly RPFine: 2;
1122
+ readonly NRPCoarse: 3;
1123
+ readonly NRPFine: 4;
1124
+ readonly DataCoarse: 5;
1125
+ readonly DataFine: 6;
1126
+ };
1127
+ type DataEntryState = (typeof dataEntryStates)[keyof typeof dataEntryStates];
1128
+ declare const customControllers: {
1129
+ readonly channelTuning: 0;
1130
+ readonly channelTransposeFine: 1;
1131
+ readonly modulationMultiplier: 2;
1132
+ readonly masterTuning: 3;
1133
+ readonly channelTuningSemitones: 4;
1134
+ readonly channelKeyShift: 5;
1135
+ readonly sf2NPRNGeneratorLSB: 6;
1136
+ };
1137
+ type CustomController = (typeof customControllers)[keyof typeof customControllers];
1138
+
1139
+ type SynthSystem = "gm" | "gm2" | "gs" | "xg";
1140
+ interface NoteOnCallback {
1141
+ /** The MIDI note number. */
1142
+ midiNote: number;
1143
+ /** The MIDI channel number. */
1144
+ channel: number;
1145
+ /** The velocity of the note. */
1146
+ velocity: number;
1147
+ }
1148
+ interface NoteOffCallback {
1149
+ /** The MIDI note number. */
1150
+ midiNote: number;
1151
+ /** The MIDI channel number. */
1152
+ channel: number;
1153
+ }
1154
+ interface DrumChangeCallback {
1155
+ /** The MIDI channel number. */
1156
+ channel: number;
1157
+ /** Indicates if the channel is a drum channel. */
1158
+ isDrumChannel: boolean;
1159
+ }
1160
+ interface ProgramChangeCallback extends MIDIPatch {
1161
+ /** The MIDI channel number. */
1162
+ channel: number;
1163
+ }
1164
+ interface ControllerChangeCallback {
1165
+ /** The MIDI channel number. */
1166
+ channel: number;
1167
+ /** The controller number. */
1168
+ controllerNumber: number;
1169
+ /** The value of the controller. */
1170
+ controllerValue: number;
1171
+ }
1172
+ interface MuteChannelCallback {
1173
+ /** The MIDI channel number. */
1174
+ channel: number;
1175
+ /** Indicates if the channel is muted. */
1176
+ isMuted: boolean;
1177
+ }
1178
+ interface PresetListEntry extends MIDIPatchNamed {
1179
+ /**
1180
+ * Indicates if this preset is any kind of drum preset.
1181
+ */
1182
+ isAnyDrums: boolean;
1183
+ }
1184
+ /**
1185
+ * A list of preset changes, each with a name, bank, and program number.
1186
+ */
1187
+ type PresetList = PresetListEntry[];
1188
+ interface SynthDisplayCallback {
1189
+ /** The data to display. */
1190
+ displayData: Uint8Array;
1191
+ /** The type of display. */
1192
+ displayType: SynthDisplayType;
1193
+ }
1194
+ interface PitchWheelCallback {
1195
+ /** The MIDI channel number. */
1196
+ channel: number;
1197
+ /**
1198
+ * The unsigned 14-bit value of the pitch: 0 - 16383.
1199
+ */
1200
+ pitch: number;
1201
+ }
1202
+ interface ChannelPressureCallback {
1203
+ /** The MIDI channel number. */
1204
+ channel: number;
1205
+ /** The pressure value. */
1206
+ pressure: number;
1207
+ }
1208
+ interface PolyPressureCallback {
1209
+ /** The MIDI channel number. */
1210
+ channel: number;
1211
+ /** The MIDI note number. */
1212
+ midiNote: number;
1213
+ /** The pressure value. */
1214
+ pressure: number;
1215
+ }
1216
+ /**
1217
+ * The error message for sound bank errors.
1218
+ */
1219
+ type SoundBankErrorCallback = Error;
1220
+ interface StopAllCallback {
1221
+ /**
1222
+ * The MIDI channel number.
1223
+ */
1224
+ channel: number;
1225
+ /**
1226
+ * If the channel was force stopped. (no release time)
1227
+ */
1228
+ force: boolean;
1229
+ }
1230
+ type MasterParameterChangeCallback = {
1231
+ [P in keyof MasterParameterType]: {
1232
+ /**
1233
+ * The parameter that was changed.
1234
+ */
1235
+ parameter: P;
1236
+ /**
1237
+ * The new value of this parameter.
1238
+ */
1239
+ value: MasterParameterType[P];
1240
+ };
1241
+ }[keyof MasterParameterType];
1242
+ interface ChannelPropertyChangeCallback {
1243
+ /**
1244
+ * The channel number of the new property.
1245
+ */
1246
+ channel: number;
1247
+ /**
1248
+ * The updated property.
1249
+ */
1250
+ property: ChannelProperty;
1251
+ }
1252
+ interface SynthProcessorEventData {
1253
+ /**
1254
+ * This event fires when a note is played.
1255
+ */
1256
+ noteOn: NoteOnCallback;
1257
+ /**
1258
+ * This event fires when a note is released.
1259
+ */
1260
+ noteOff: NoteOffCallback;
1261
+ /**
1262
+ * This event fires when a pitch wheel is changed.
1263
+ */
1264
+ pitchWheel: PitchWheelCallback;
1265
+ /**
1266
+ * This event fires when a controller is changed.
1267
+ */
1268
+ controllerChange: ControllerChangeCallback;
1269
+ /**
1270
+ * This event fires when a program is changed.
1271
+ */
1272
+ programChange: ProgramChangeCallback;
1273
+ /**
1274
+ * This event fires when a channel pressure is changed.
1275
+ */
1276
+ channelPressure: ChannelPressureCallback;
1277
+ /**
1278
+ * This event fires when a polyphonic pressure is changed.
1279
+ */
1280
+ polyPressure: PolyPressureCallback;
1281
+ /**
1282
+ * This event fires when a drum channel is changed.
1283
+ */
1284
+ drumChange: DrumChangeCallback;
1285
+ /**
1286
+ * This event fires when all notes on a channel are stopped.
1287
+ */
1288
+ stopAll: StopAllCallback;
1289
+ /**
1290
+ * This event fires when a new channel is created. There is no data for this event.
1291
+ */
1292
+ newChannel: void;
1293
+ /**
1294
+ * This event fires when a channel is muted or unmuted.
1295
+ */
1296
+ muteChannel: MuteChannelCallback;
1297
+ /**
1298
+ * This event fires when the preset list is changed.
1299
+ */
1300
+ presetListChange: PresetList;
1301
+ /**
1302
+ * This event fires when all controllers on all channels are reset. There is no data for this event.
1303
+ */
1304
+ allControllerReset: void;
1305
+ /**
1306
+ * This event fires when a sound bank parsing error occurs.
1307
+ */
1308
+ soundBankError: SoundBankErrorCallback;
1309
+ /**
1310
+ * This event fires when the synthesizer receives a display message.
1311
+ */
1312
+ synthDisplay: SynthDisplayCallback;
1313
+ /**
1314
+ * This event fires when a master parameter changes.
1315
+ */
1316
+ masterParameterChange: MasterParameterChangeCallback;
1317
+ /**
1318
+ * This event fires when a channel property changes.
1319
+ */
1320
+ channelPropertyChange: ChannelPropertyChangeCallback;
1321
+ }
1322
+ type SynthProcessorEvent = {
1323
+ [K in keyof SynthProcessorEventData]: {
1324
+ type: K;
1325
+ data: SynthProcessorEventData[K];
1326
+ };
1327
+ }[keyof SynthProcessorEventData];
1328
+ interface SynthMethodOptions {
1329
+ /**
1330
+ * The audio context time when the event should execute, in seconds.
1331
+ */
1332
+ time: number;
1333
+ }
1334
+ /**
1335
+ * KeyNum: tuning.
1336
+ */
1337
+ type MTSProgramTuning = MTSNoteTuning[];
1338
+ interface MTSNoteTuning {
1339
+ /**
1340
+ * The base MIDI note to use, -1 means no change.
1341
+ */
1342
+ midiNote: number;
1343
+ /**
1344
+ * Additional tuning.
1345
+ */
1346
+ centTuning: number | null;
1347
+ }
1348
+ /**
1349
+ * Looping mode of the sample.
1350
+ * 0 - no loop.
1351
+ * 1 - loop.
1352
+ * 2 - UNOFFICIAL: polyphone 2.4 added start on release.
1353
+ * 3 - loop then play when released.
1354
+ */
1355
+ type SampleLoopingMode = 0 | 1 | 2 | 3;
1356
+ /**
1357
+ * A list of voices for a given key:velocity.
1358
+ */
1359
+ type VoiceList = Voice[];
1360
+ interface ChannelProperty {
1361
+ /**
1362
+ * The channel's current voice amount.
1363
+ */
1364
+ voicesAmount: number;
1365
+ /**
1366
+ * The channel's current pitch wheel 0 - 16384.
1367
+ */
1368
+ pitchWheel: number;
1369
+ /**
1370
+ * The pitch wheel's range, in semitones.
1371
+ */
1372
+ pitchWheelRange: number;
1373
+ /**
1374
+ * Indicates whether the channel is muted.
1375
+ */
1376
+ isMuted: boolean;
1377
+ /**
1378
+ * Indicates whether the channel is a drum channel.
1379
+ */
1380
+ isDrum: boolean;
1381
+ /**
1382
+ * The channel's transposition, in semitones.
1383
+ */
1384
+ transposition: number;
1385
+ }
1386
+ interface SynthProcessorOptions {
1387
+ /**
1388
+ * Indicates if the event system is enabled. This can be changed later.
1389
+ */
1390
+ enableEventSystem: boolean;
1391
+ /**
1392
+ * The initial time of the synth, in seconds.
1393
+ */
1394
+ initialTime: number;
1395
+ /**
1396
+ * Indicates if the effects are enabled. This can be changed later.
1397
+ */
1398
+ enableEffects: boolean;
1399
+ }
1400
+ /**
1401
+ * The master parameters of the synthesizer.
1402
+ */
1403
+ interface MasterParameterType {
1404
+ /**
1405
+ * The master gain, from 0 to any number. 1 is 100% volume.
1406
+ */
1407
+ masterGain: number;
1408
+ /**
1409
+ * The master pan, from -1 (left) to 1 (right). 0 is center.
1410
+ */
1411
+ masterPan: number;
1412
+ /**
1413
+ * The maximum number of voices that can be played at once.
1414
+ */
1415
+ voiceCap: number;
1416
+ /**
1417
+ * The interpolation type used for sample playback.
1418
+ */
1419
+ interpolationType: InterpolationType;
1420
+ /**
1421
+ * The MIDI system used by the synthesizer for bank selects and system exclusives. (GM, GM2, GS, XG)
1422
+ */
1423
+ midiSystem: SynthSystem;
1424
+ /**
1425
+ * Indicates whether the synthesizer is in monophonic retrigger mode.
1426
+ * This emulates the behavior of Microsoft GS Wavetable Synth,
1427
+ * Where a new note will kill the previous one if it is still playing.
1428
+ */
1429
+ monophonicRetriggerMode: boolean;
1430
+ /**
1431
+ * The reverb gain, from 0 to any number. 1 is 100% reverb.
1432
+ */
1433
+ reverbGain: number;
1434
+ /**
1435
+ * The chorus gain, from 0 to any number. 1 is 100% chorus.
1436
+ */
1437
+ chorusGain: number;
1438
+ /**
1439
+ * Forces note killing instead of releasing. Improves performance in black MIDIs.
1440
+ */
1441
+ blackMIDIMode: boolean;
1442
+ /**
1443
+ * The global transposition in semitones. It can be decimal to provide microtonal tuning.
1444
+ */
1445
+ transposition: number;
1446
+ /**
1447
+ * Synthesizer's device ID for system exclusive messages. Set to -1 to accept all.
1448
+ */
1449
+ deviceID: number;
1450
+ }
1451
+
1452
+ /**
1453
+ * Sets a master parameter of the synthesizer.
1454
+ * @param parameter The type of the master parameter to set.
1455
+ * @param value The value to set for the master parameter.
1456
+ */
1457
+ declare function setMasterParameterInternal<P extends keyof MasterParameterType>(this: SpessaSynthProcessor, parameter: P, value: MasterParameterType[P]): void;
1458
+ /**
1459
+ * Gets a master parameter of the synthesizer.
1460
+ * @param type The type of the master parameter to get.
1461
+ * @returns The value of the master parameter.
1462
+ */
1463
+ declare function getMasterParameterInternal<P extends keyof MasterParameterType>(this: SpessaSynthProcessor, type: P): MasterParameterType[P];
1464
+ /**
1465
+ * Gets all master parameters of the synthesizer.
1466
+ * @returns All the master parameters.
1467
+ */
1468
+ declare function getAllMasterParametersInternal(this: SpessaSynthProcessor): MasterParameterType;
1469
+
1470
+ declare class SoundBankManager {
1471
+ /**
1472
+ * All the sound banks, ordered from the most important to the least.
1473
+ */
1474
+ soundBankList: SoundBankManagerListEntry[];
1475
+ private readonly presetListChangeCallback;
1476
+ private selectablePresetList;
1477
+ /**
1478
+ * @param presetListChangeCallback Supplied by the parent synthesizer class,
1479
+ * this is called whenever the preset list changes.
1480
+ */
1481
+ constructor(presetListChangeCallback: () => unknown);
1482
+ private _presetList;
1483
+ /**
1484
+ * The list of all presets in the sound bank stack.
1485
+ */
1486
+ get presetList(): PresetListEntry[];
1487
+ /**
1488
+ * The current sound bank priority order.
1489
+ * @returns The IDs of the sound banks in the current order.
1490
+ */
1491
+ get priorityOrder(): string[];
1492
+ /**
1493
+ * The current sound bank priority order.
1494
+ * @param newList The new order of sound bank IDs.
1495
+ */
1496
+ set priorityOrder(newList: string[]);
1497
+ /**
1498
+ * Deletes a given sound bank by its ID.
1499
+ * @param id the ID of the sound bank to delete.
1500
+ */
1501
+ deleteSoundBank(id: string): void;
1502
+ /**
1503
+ * Adds a new sound bank with a given ID, or replaces an existing one.
1504
+ * @param font the sound bank to add.
1505
+ * @param id the ID of the sound bank.
1506
+ * @param bankOffset the bank offset of the sound bank.
1507
+ */
1508
+ addSoundBank(font: BasicSoundBank, id: string, bankOffset?: number): void;
1509
+ /**
1510
+ * Gets a given preset from the sound bank stack.
1511
+ * @param patch The MIDI patch to search for.
1512
+ * @param system The MIDI system to select the preset for.
1513
+ * @returns An object containing the preset and its bank offset.
1514
+ */
1515
+ getPreset(patch: MIDIPatch, system: SynthSystem): BasicPreset;
1516
+ destroy(): void;
1517
+ private generatePresetList;
1518
+ }
1519
+
1520
+ /**
1521
+ * Kills the specified number of voices based on their priority.
1522
+ * This function will remove the least important voices from all channels.
1523
+ * @param amount The number of voices to remove.
1524
+ */
1525
+ declare function killVoicesIntenral(this: SpessaSynthProcessor, amount: number): void;
1526
+
1527
+ type TypedArray = Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array | Uint8ClampedArray | Float32Array | Float64Array;
1528
+ /**
1529
+ * Executes a system exclusive message for the synthesizer.
1530
+ * @param syx The system exclusive message as an array of bytes.
1531
+ * @param channelOffset The channel offset to apply (default is 0).
1532
+ * @remarks
1533
+ * This is a rather extensive method that handles various system exclusive messages,
1534
+ * including Roland GS, MIDI Tuning Standard, and other non-realtime messages.
1535
+ */
1536
+ declare function systemExclusiveInternal(this: SpessaSynthProcessor, syx: number[] | IndexedByteArray | TypedArray, channelOffset?: number): void;
1537
+
1538
+ /**
1539
+ * Executes a data entry fine (LSB) change for the current channel.
1540
+ * @param dataValue The value to set for the data entry fine controller (0-127).
1541
+ */
1542
+ declare function dataEntryFine(this: MIDIChannel, dataValue: number): void;
1543
+
1544
+ /**
1545
+ * Handles MIDI controller changes for a channel.
1546
+ * @param controllerNumber The MIDI controller number (0-127).
1547
+ * @param controllerValue The value of the controller (0-127).
1548
+ * @param sendEvent If an event should be emitted.
1549
+ * @remarks
1550
+ * This function processes MIDI controller changes, updating the channel's
1551
+ * midiControllers table and handling special cases like bank select,
1552
+ * data entry, and sustain pedal. It also computes modulators for all voices
1553
+ * in the channel based on the controller change.
1554
+ * If the controller number is greater than 127, it is treated as a channel
1555
+ * configuration controller, and the `force` parameter must be set to true
1556
+ * to allow changes.
1557
+ */
1558
+ declare function controllerChange(this: MIDIChannel, controllerNumber: MIDIController, controllerValue: number, sendEvent?: boolean): void;
1559
+
1560
+ /**
1561
+ * Executes a data entry coarse (MSB) change for the current channel.
1562
+ * @param dataValue The value to set for the data entry coarse controller (0-127).
1563
+ */
1564
+ declare function dataEntryCoarse(this: MIDIChannel, dataValue: number): void;
1565
+
1566
+ /**
1567
+ * Sends a "MIDI Note on" message and starts a note.
1568
+ * @param midiNote The MIDI note number (0-127).
1569
+ * @param velocity The velocity of the note (0-127). If less than 1, it will send a note off instead.
1570
+ */
1571
+ declare function noteOn(this: MIDIChannel, midiNote: number, velocity: number): void;
1572
+
1573
+ /**
1574
+ * Releases a note by its MIDI note number.
1575
+ * If the note is in high performance mode and the channel is not a drum channel,
1576
+ * it kills the note instead of releasing it.
1577
+ * @param midiNote The MIDI note number to release (0-127).
1578
+ */
1579
+ declare function noteOff(this: MIDIChannel, midiNote: number): void;
1580
+
1581
+ /**
1582
+ * Changes the program (preset) of the channel.
1583
+ * @param program The program number (0-127) to change to.
1584
+ */
1585
+ declare function programChange(this: MIDIChannel, program: number): void;
1586
+
1587
+ /**
1588
+ * A class for dynamic modulators
1589
+ * that are assigned for more complex system exclusive messages
1590
+ */
1591
+ declare class DynamicModulatorSystem {
1592
+ /**
1593
+ * The current dynamic modulator list.
1594
+ */
1595
+ modulatorList: {
1596
+ mod: Modulator;
1597
+ id: string;
1598
+ }[];
1599
+ resetModulators(): void;
1600
+ /**
1601
+ * @param source Like in midiControllers: values below NON_CC_INDEX_OFFSET are CCs,
1602
+ * above are regular modulator sources.
1603
+ * @param destination The generator type to modulate.
1604
+ * @param amount The amount of modulation to apply.
1605
+ * @param isBipolar If true, the modulation is bipolar (ranges from -1 to 1 instead of from 0 to 1).
1606
+ * @param isNegative If true, the modulation is negative (goes from 1 to 0 instead of from 0 to 1).
1607
+ */
1608
+ setModulator(source: ModulatorSourceEnum, destination: GeneratorType, amount: number, isBipolar?: boolean, isNegative?: boolean): void;
1609
+ private getModulatorID;
1610
+ private deleteModulator;
1611
+ }
1612
+
1613
+ declare class ProtectedSynthValues {
1614
+ /**
1615
+ * This.tunings[program][key] = tuning
1616
+ */
1617
+ readonly tunings: MTSProgramTuning[];
1618
+ masterParameters: MasterParameterType;
1619
+ /**
1620
+ * The volume gain, set by MIDI sysEx
1621
+ */
1622
+ midiVolume: number;
1623
+ /**
1624
+ * Set via system exclusive.
1625
+ */
1626
+ reverbSend: number;
1627
+ /**
1628
+ * Set via system exclusive.
1629
+ */
1630
+ chorusSend: number;
1631
+ /**
1632
+ * The pan of the left channel
1633
+ */
1634
+ panLeft: number;
1635
+ /**
1636
+ * The pan of the right channel
1637
+ */
1638
+ panRight: number;
1639
+ /**
1640
+ * Synth's default (reset) preset
1641
+ */
1642
+ defaultPreset: BasicPreset | undefined;
1643
+ /**
1644
+ * Synth's default (reset) drum preset
1645
+ */
1646
+ drumPreset: BasicPreset | undefined;
1647
+ readonly volumeEnvelopeSmoothingFactor: number;
1648
+ readonly panSmoothingFactor: number;
1649
+ readonly filterSmoothingFactor: number;
1650
+ /**
1651
+ * Calls when an event occurs.
1652
+ * @param eventType The event type.
1653
+ * @param eventData The event data.
1654
+ */
1655
+ eventCallbackHandler: <K extends keyof SynthProcessorEventData>(eventType: K, eventData: SynthProcessorEventData[K]) => unknown;
1656
+ getVoices: (channel: number, midiNote: number, velocity: number, realKey: number) => VoiceList;
1657
+ voiceKilling: (amount: number) => unknown;
1658
+ /**
1659
+ * Cached voices for all presets for this synthesizer.
1660
+ * Nesting goes like this:
1661
+ * this.cachedVoices[bankMSB][bankLSB][programNumber][midiNote][velocity] = a list of voices for that.
1662
+ */
1663
+ cachedVoices: VoiceList[][][][][];
1664
+ constructor(eventCallbackHandler: <K extends keyof SynthProcessorEventData>(eventType: K, eventData: SynthProcessorEventData[K]) => unknown, getVoices: (channel: number, midiNote: number, velocity: number, realKey: number) => VoiceList, voiceKillingFunction: (amount: number) => unknown, volumeEnvelopeSmoothingFactor: number, panSmoothingFactor: number, filterSmoothingFactor: number);
1665
+ /**
1666
+ * Copied callback so MIDI channels can call it.
1667
+ */
1668
+ callEvent<K extends keyof SynthProcessorEventData>(eventName: K, eventData: SynthProcessorEventData[K]): void;
1669
+ }
1670
+
1671
+ /**
1672
+ * This class represents a single MIDI Channel within the synthesizer.
1673
+ */
1674
+ declare class MIDIChannel {
1675
+ readonly midiControllers: Int16Array;
1676
+ /**
1677
+ * An array indicating if a controller, at the equivalent index in the midiControllers array, is locked
1678
+ * (i.e., not allowed changing).
1679
+ * A locked controller cannot be modified.
1680
+ */
1681
+ lockedControllers: boolean[];
1682
+ /**
1683
+ * An array of custom (non-SF2) control values such as RPN pitch tuning, transpose, modulation depth, etc.
1684
+ * Refer to controller_tables.ts for the index definitions.
1685
+ */
1686
+ readonly customControllers: Float32Array;
1687
+ /**
1688
+ * The key shift of the channel (in semitones).
1689
+ */
1690
+ channelTransposeKeyShift: number;
1691
+ /**
1692
+ * An array of octave tuning values for each note on the channel.
1693
+ * Each index corresponds to a note (0 = C, 1 = C#, ..., 11 = B).
1694
+ * Note: Repeated every 12 notes.
1695
+ */
1696
+ channelOctaveTuning: Int8Array;
1697
+ /**
1698
+ * A system for dynamic modulator assignment for advanced system exclusives.
1699
+ */
1700
+ sysExModulators: DynamicModulatorSystem;
1701
+ /**
1702
+ * Indicates whether this channel is a drum channel.
1703
+ */
1704
+ drumChannel: boolean;
1705
+ /**
1706
+ * Enables random panning for every note played on this channel.
1707
+ */
1708
+ randomPan: boolean;
1709
+ /**
1710
+ * The current state of the data entry for the channel.
1711
+ */
1712
+ dataEntryState: DataEntryState;
1713
+ /**
1714
+ * The currently selected MIDI patch of the channel.
1715
+ * Note that the exact matching preset may not be available, but this represents exactly what MIDI asks for.
1716
+ */
1717
+ readonly patch: MIDIPatch;
1718
+ /**
1719
+ * The preset currently assigned to the channel.
1720
+ */
1721
+ preset?: BasicPreset;
1722
+ /**
1723
+ * Indicates whether the program on this channel is locked.
1724
+ */
1725
+ lockPreset: boolean;
1726
+ /**
1727
+ * Indicates the MIDI system when the preset was locked.
1728
+ */
1729
+ lockedSystem: SynthSystem;
1730
+ /**
1731
+ * Indicates whether the GS NRPN parameters are enabled for this channel.
1732
+ */
1733
+ lockGSNRPNParams: boolean;
1734
+ /**
1735
+ * The vibrato settings for the channel.
1736
+ * @property depth - Depth of the vibrato effect in cents.
1737
+ * @property delay - Delay before the vibrato effect starts (in seconds).
1738
+ * @property rate - Rate of the vibrato oscillation (in Hz).
1739
+ */
1740
+ channelVibrato: {
1741
+ delay: number;
1742
+ depth: number;
1743
+ rate: number;
1744
+ };
1745
+ /**
1746
+ * An array of voices currently active on the channel.
1747
+ */
1748
+ voices: VoiceList;
1749
+ /**
1750
+ * An array of voices that are sustained on the channel.
1751
+ */
1752
+ sustainedVoices: VoiceList;
1753
+ /**
1754
+ * The channel's number (0-based index)
1755
+ */
1756
+ readonly channelNumber: number;
1757
+ /**
1758
+ * Parent processor instance.
1759
+ */
1760
+ synth: SpessaSynthProcessor;
1761
+ /**
1762
+ * Grants access to protected synth values.
1763
+ */
1764
+ synthProps: ProtectedSynthValues;
1765
+ /**
1766
+ * Sends a "MIDI Note on" message and starts a note.
1767
+ * @param midiNote The MIDI note number (0-127).
1768
+ * @param velocity The velocity of the note (0-127). If less than 1, it will send a note off instead.
1769
+ */
1770
+ noteOn: typeof noteOn;
1771
+ /**
1772
+ * Releases a note by its MIDI note number.
1773
+ * If the note is in high performance mode and the channel is not a drum channel,
1774
+ * it kills the note instead of releasing it.
1775
+ * @param midiNote The MIDI note number to release (0-127).
1776
+ */
1777
+ noteOff: typeof noteOff;
1778
+ /**
1779
+ * Changes the program (preset) of the channel.
1780
+ * @param programNumber The program number (0-127) to change to.
1781
+ */
1782
+ programChange: typeof programChange;
1783
+ controllerChange: typeof controllerChange;
1784
+ /**
1785
+ * Reset all controllers for channel.
1786
+ * This will reset all controllers to their default values,
1787
+ * except for the locked controllers.
1788
+ */
1789
+ readonly resetControllers: typeof resetControllers;
1790
+ readonly resetPreset: typeof resetPreset;
1791
+ /**
1792
+ * https://amei.or.jp/midistandardcommittee/Recommended_Practice/e/rp15.pdf
1793
+ * Reset controllers according to RP-15 Recommended Practice.
1794
+ */
1795
+ readonly resetControllersRP15Compliant: typeof resetControllersRP15Compliant;
1796
+ /**
1797
+ * Reset all parameters to their default values.
1798
+ * This includes NRPN and RPN controllers, data entry state,
1799
+ * and generator overrides and offsets.
1800
+ */
1801
+ resetParameters: typeof resetParameters;
1802
+ /**
1803
+ * Executes a data entry fine (LSB) change for the current channel.
1804
+ * @param dataValue The value to set for the data entry fine controller (0-127).
1805
+ */
1806
+ dataEntryFine: typeof dataEntryFine;
1807
+ /**
1808
+ * Executes a data entry coarse (MSB) change for the current channel.
1809
+ * @param dataValue The value to set for the data entry coarse controller (0-127).
1810
+ */
1811
+ dataEntryCoarse: typeof dataEntryCoarse;
1812
+ /**
1813
+ * Will be updated every time something tuning-related gets changed.
1814
+ * This is used to avoid a big addition for every voice rendering call.
1815
+ */
1816
+ protected channelTuningCents: number;
1817
+ /**
1818
+ * An array of offsets generators for SF2 nrpn support.
1819
+ * A value of 0 means no change; -10 means 10 lower, etc.
1820
+ */
1821
+ protected generatorOffsets: Int16Array;
1822
+ /**
1823
+ * A small optimization that disables applying offsets until at least one is set.
1824
+ */
1825
+ protected generatorOffsetsEnabled: boolean;
1826
+ /**
1827
+ * An array of override generators for AWE32 support.
1828
+ * A value of 32,767 means unchanged, as it is not allowed anywhere.
1829
+ */
1830
+ protected generatorOverrides: Int16Array;
1831
+ /**
1832
+ * A small optimization that disables applying overrides until at least one is set.
1833
+ */
1834
+ protected generatorOverridesEnabled: boolean;
1835
+ protected renderVoice: (voice: Voice, timeNow: number, outputLeft: Float32Array<ArrayBufferLike>, outputRight: Float32Array<ArrayBufferLike>, reverbOutputLeft: Float32Array<ArrayBufferLike>, reverbOutputRight: Float32Array<ArrayBufferLike>, chorusOutputLeft: Float32Array<ArrayBufferLike>, chorusOutputRight: Float32Array<ArrayBufferLike>, startIndex: number, sampleCount: number) => boolean;
1836
+ protected panAndMixVoice: (voice: Voice, inputBuffer: Float32Array<ArrayBufferLike>, outputLeft: Float32Array<ArrayBufferLike>, outputRight: Float32Array<ArrayBufferLike>, reverbLeft: Float32Array<ArrayBufferLike>, reverbRight: Float32Array<ArrayBufferLike>, chorusLeft: Float32Array<ArrayBufferLike>, chorusRight: Float32Array<ArrayBufferLike>, startIndex: number) => void;
1837
+ protected computeModulators: (voice: Voice, sourceUsesCC?: 0 | 1 | -1 | undefined, sourceIndex?: number | undefined) => void;
1838
+ /**
1839
+ * Constructs a new MIDI channel.
1840
+ */
1841
+ constructor(synth: SpessaSynthProcessor, synthProps: ProtectedSynthValues, preset: BasicPreset | undefined, channelNumber: number);
1842
+ /**
1843
+ * Indicates whether the channel is muted.
1844
+ */
1845
+ protected _isMuted: boolean;
1846
+ /**
1847
+ * Indicates whether the channel is muted.
1848
+ */
1849
+ get isMuted(): boolean;
1850
+ /**
1851
+ * Indicates whether the sustain (hold) pedal is active.
1852
+ */
1853
+ get holdPedal(): boolean;
1854
+ protected get channelSystem(): SynthSystem;
1855
+ /**
1856
+ * Transposes the channel by given amount of semitones.
1857
+ * @param semitones The number of semitones to transpose the channel by. Can be decimal.
1858
+ * @param force Defaults to false, if true, it will force the transpose even if the channel is a drum channel.
1859
+ */
1860
+ transposeChannel(semitones: number, force?: boolean): void;
1861
+ /**
1862
+ * Sets the octave tuning for a given channel.
1863
+ * @param tuning The tuning array of 12 values, each representing the tuning for a note in the octave.
1864
+ * @remarks
1865
+ * Cent tunings are relative.
1866
+ */
1867
+ setOctaveTuning(tuning: Int8Array): void;
1868
+ /**
1869
+ * Sets the modulation depth for the channel.
1870
+ * @param cents The modulation depth in cents to set.
1871
+ * @remarks
1872
+ * This method sets the modulation depth for the channel by converting the given cents value into a
1873
+ * multiplier. The MIDI specification assumes the default modulation depth is 50 cents,
1874
+ * but it may vary for different sound banks.
1875
+ * For example, if you want a modulation depth of 100 cents,
1876
+ * the multiplier will be 2,
1877
+ * which, for a preset with a depth of 50,
1878
+ * will create a total modulation depth of 100 cents.
1879
+ *
1880
+ */
1881
+ setModulationDepth(cents: number): void;
1882
+ /**
1883
+ * Sets the channel's tuning.
1884
+ * @param cents The tuning in cents to set.
1885
+ * @param log If true, logs the change to the console.
1886
+ */
1887
+ setTuning(cents: number, log?: boolean): void;
1888
+ /**
1889
+ * Sets the pitch of the given channel.
1890
+ * @param pitch The pitch (0 - 16384)
1891
+ */
1892
+ pitchWheel(pitch: number): void;
1893
+ /**
1894
+ * Sets the channel pressure (MIDI Aftertouch).
1895
+ * @param pressure the pressure of the channel.
1896
+ */
1897
+ channelPressure(pressure: number): void;
1898
+ /**
1899
+ * Sets the pressure of the given note on a specific channel.
1900
+ * This is used for polyphonic pressure (aftertouch).
1901
+ * @param midiNote 0 - 127, the MIDI note number to set the pressure for.
1902
+ * @param pressure 0 - 127, the pressure value to set for the note.
1903
+ */
1904
+ polyPressure(midiNote: number, pressure: number): void;
1905
+ setCustomController(type: CustomController, value: number): void;
1906
+ updateChannelTuning(): void;
1907
+ /**
1908
+ * Renders Float32 audio for this channel.
1909
+ * @param outputLeft the left output buffer.
1910
+ * @param outputRight the right output buffer.
1911
+ * @param reverbOutputLeft left output for reverb.
1912
+ * @param reverbOutputRight right output for reverb.
1913
+ * @param chorusOutputLeft left output for chorus.
1914
+ * @param chorusOutputRight right output for chorus.
1915
+ * @param startIndex start index offset.
1916
+ * @param sampleCount sample count to render.
1917
+ */
1918
+ renderAudio(outputLeft: Float32Array, outputRight: Float32Array, reverbOutputLeft: Float32Array, reverbOutputRight: Float32Array, chorusOutputLeft: Float32Array, chorusOutputRight: Float32Array, startIndex: number, sampleCount: number): void;
1919
+ /**
1920
+ * Locks or unlocks the preset from MIDI program changes.
1921
+ * @param locked If the preset should be locked.
1922
+ */
1923
+ setPresetLock(locked: boolean): void;
1924
+ /**
1925
+ * Changes the preset to, or from drums.
1926
+ * Note that this executes a program change.
1927
+ * @param isDrum If the channel should be a drum preset or not.
1928
+ */
1929
+ setDrums(isDrum: boolean): void;
1930
+ /**
1931
+ * Sets the channel to a given MIDI patch.
1932
+ * Note that this executes a program change.
1933
+ * @param patch The MIDI patch to set the channel to.
1934
+ */
1935
+ setPatch(patch: MIDIPatch): void;
1936
+ /**
1937
+ * Sets the GM/GS drum flag.
1938
+ * @param drums
1939
+ */
1940
+ setGSDrums(drums: boolean): void;
1941
+ /**
1942
+ * Sets a custom vibrato.
1943
+ * @param depth In cents.
1944
+ * @param rate In Hertz.
1945
+ * @param delay seconds.
1946
+ */
1947
+ setVibrato(depth: number, rate: number, delay: number): void;
1948
+ /**
1949
+ * Disables and locks all GS NPRN parameters, including the custom vibrato.
1950
+ */
1951
+ disableAndLockGSNRPN(): void;
1952
+ resetGeneratorOverrides(): void;
1953
+ setGeneratorOverride(gen: GeneratorType, value: number, realtime?: boolean): void;
1954
+ resetGeneratorOffsets(): void;
1955
+ setGeneratorOffset(gen: GeneratorType, value: number): void;
1956
+ /**
1957
+ * Stops a note nearly instantly.
1958
+ * @param midiNote The note to stop.
1959
+ * @param releaseTime in timecents, defaults to -12000 (very short release).
1960
+ */
1961
+ killNote(midiNote: number, releaseTime?: number): void;
1962
+ /**
1963
+ * Stops all notes on the channel.
1964
+ * @param force If true, stops all notes immediately, otherwise applies release time.
1965
+ */
1966
+ stopAllNotes(force?: boolean): void;
1967
+ /**
1968
+ * Mutes or unmutes a channel.
1969
+ * @param isMuted If the channel should be muted.
1970
+ */
1971
+ muteChannel(isMuted: boolean): void;
1972
+ /**
1973
+ * Sends this channel's property
1974
+ */
1975
+ sendChannelProperty(): void;
1976
+ protected setBankMSB(bankMSB: number): void;
1977
+ protected setBankLSB(bankLSB: number): void;
1978
+ /**
1979
+ * Sets drums on channel.
1980
+ */
1981
+ protected setDrumFlag(isDrum: boolean): void;
1982
+ }
1983
+
1984
+ /**
1985
+ * Executes a full system reset of all controllers.
1986
+ * This will reset all controllers to their default values,
1987
+ * except for the locked controllers.
1988
+ */
1989
+ declare function resetAllControllersInternal(this: SpessaSynthProcessor, log?: boolean): void;
1990
+ /**
1991
+ * Reset all controllers for channel.
1992
+ * This will reset all controllers to their default values,
1993
+ * except for the locked controllers.
1994
+ */
1995
+ declare function resetControllers(this: MIDIChannel, sendCCEvents?: boolean): void;
1996
+ declare function resetPreset(this: MIDIChannel): void;
1997
+ /**
1998
+ * https://amei.or.jp/midistandardcommittee/Recommended_Practice/e/rp15.pdf
1999
+ * Reset controllers according to RP-15 Recommended Practice.
2000
+ */
2001
+ declare function resetControllersRP15Compliant(this: MIDIChannel): void;
2002
+ /**
2003
+ * Reset all parameters to their default values.
2004
+ * This includes NRPN and RPN controllers, data entry state,
2005
+ * and generator overrides and offsets.
2006
+ */
2007
+ declare function resetParameters(this: MIDIChannel): void;
2008
+
2009
+ /**
2010
+ * Represents a snapshot of a single channel's state in the synthesizer.
2011
+ */
2012
+ declare class ChannelSnapshot {
2013
+ /**
2014
+ * The MIDI patch that the channel is using.
2015
+ */
2016
+ patch: MIDIPatchNamed;
2017
+ /**
2018
+ * Indicates whether the channel's program change is disabled.
2019
+ */
2020
+ lockPreset: boolean;
2021
+ /**
2022
+ * Indicates the MIDI system when the preset was locked
2023
+ */
2024
+ lockedSystem: SynthSystem;
2025
+ /**
2026
+ * The array of all MIDI controllers (in 14-bit values) with the modulator sources at the end.
2027
+ */
2028
+ midiControllers: Int16Array;
2029
+ /**
2030
+ * An array of booleans, indicating if the controller with a current index is locked.
2031
+ */
2032
+ lockedControllers: boolean[];
2033
+ /**
2034
+ * Array of custom (not SF2) control values such as RPN pitch tuning, transpose, modulation depth, etc.
2035
+ */
2036
+ customControllers: Float32Array;
2037
+ /**
2038
+ * Indicates whether the channel vibrato is locked.
2039
+ */
2040
+ lockVibrato: boolean;
2041
+ /**
2042
+ * The channel's vibrato settings.
2043
+ * @property depth Vibrato depth, in gain.
2044
+ * @property delay Vibrato delay from note on in seconds.
2045
+ * @property rate Vibrato rate in Hz.
2046
+ */
2047
+ channelVibrato: {
2048
+ depth: number;
2049
+ delay: number;
2050
+ rate: number;
2051
+ };
2052
+ /**
2053
+ * Key shift for the channel.
2054
+ */
2055
+ channelTransposeKeyShift: number;
2056
+ /**
2057
+ * The channel's octave tuning in cents.
2058
+ */
2059
+ channelOctaveTuning: Int8Array;
2060
+ /**
2061
+ * Indicates whether the channel is muted.
2062
+ */
2063
+ isMuted: boolean;
2064
+ /**
2065
+ * Indicates whether the channel is a drum channel.
2066
+ */
2067
+ drumChannel: boolean;
2068
+ /**
2069
+ * The channel number this snapshot represents.
2070
+ */
2071
+ channelNumber: number;
2072
+ constructor(patch: MIDIPatchNamed, lockPreset: boolean, lockedSystem: SynthSystem, midiControllers: Int16Array, lockedControllers: boolean[], customControllers: Float32Array, lockVibrato: boolean, channelVibrato: {
2073
+ delay: number;
2074
+ depth: number;
2075
+ rate: number;
2076
+ }, channelTransposeKeyShift: number, channelOctaveTuning: Int8Array, isMuted: boolean, drumChannel: boolean, channelNumber: number);
2077
+ /**
2078
+ * Creates a copy of existing snapshot.
2079
+ * @param snapshot The snapshot to create a copy from.
2080
+ */
2081
+ static copyFrom(snapshot: ChannelSnapshot): ChannelSnapshot;
2082
+ /**
2083
+ * Creates a snapshot of the channel's state.
2084
+ * @param spessaSynthProcessor The synthesizer processor containing the channel.
2085
+ * @param channelNumber The channel number to snapshot.
2086
+ */
2087
+ static create(spessaSynthProcessor: SpessaSynthProcessor, channelNumber: number): ChannelSnapshot;
2088
+ /**
2089
+ * Applies the snapshot to the specified channel.
2090
+ * @param spessaSynthProcessor The processor containing the channel.
2091
+ */
2092
+ apply(spessaSynthProcessor: SpessaSynthProcessor): void;
2093
+ }
2094
+
2095
+ /**
2096
+ * A manager for custom key overrides for channels
2097
+ */
2098
+
2099
+ declare class KeyModifier {
2100
+ /**
2101
+ * The new override velocity. -1 means unchanged.
2102
+ */
2103
+ velocity: number;
2104
+ /**
2105
+ * The MIDI patch this key uses. -1 on any property means unchanged.
2106
+ */
2107
+ patch: MIDIPatch;
2108
+ /**
2109
+ * Linear gain override for the voice.
2110
+ */
2111
+ gain: number;
2112
+ }
2113
+ declare class KeyModifierManager {
2114
+ /**
2115
+ * The velocity override mappings for MIDI keys
2116
+ * stored as [channelNumber][midiNote].
2117
+ */
2118
+ private keyMappings;
2119
+ /**
2120
+ * Add a mapping for a MIDI key to a KeyModifier.
2121
+ * @param channel The MIDI channel number.
2122
+ * @param midiNote The MIDI note number (0-127).
2123
+ * @param mapping The KeyModifier to apply for this key.
2124
+ */
2125
+ addMapping(channel: number, midiNote: number, mapping: KeyModifier): void;
2126
+ /**
2127
+ * Delete a mapping for a MIDI key.
2128
+ * @param channel The MIDI channel number.
2129
+ * @param midiNote The MIDI note number (0-127).
2130
+ */
2131
+ deleteMapping(channel: number, midiNote: number): void;
2132
+ /**
2133
+ * Clear all key mappings.
2134
+ */
2135
+ clearMappings(): void;
2136
+ /**
2137
+ * Sets the key mappings to a new array.
2138
+ * @param mappings A 2D array where the first dimension is the channel number and the second dimension is the MIDI note number.
2139
+ */
2140
+ setMappings(mappings: (KeyModifier | undefined)[][]): void;
2141
+ /**
2142
+ * Returns the current key mappings.
2143
+ */
2144
+ getMappings(): (KeyModifier | undefined)[][];
2145
+ /**
2146
+ * Gets the velocity override for a MIDI key.
2147
+ * @param channel The MIDI channel number.
2148
+ * @param midiNote The MIDI note number (0-127).
2149
+ * @returns The velocity override, or -1 if no override is set.
2150
+ */
2151
+ getVelocity(channel: number, midiNote: number): number;
2152
+ /**
2153
+ * Gets the gain override for a MIDI key.
2154
+ * @param channel The MIDI channel number.
2155
+ * @param midiNote The MIDI note number (0-127).
2156
+ * @returns The gain override, or 1 if no override is set.
2157
+ */
2158
+ getGain(channel: number, midiNote: number): number;
2159
+ /**
2160
+ * Checks if a MIDI key has an override for the patch.
2161
+ * @param channel The MIDI channel number.
2162
+ * @param midiNote The MIDI note number (0-127).
2163
+ * @returns True if the key has an override patch, false otherwise.
2164
+ */
2165
+ hasOverridePatch(channel: number, midiNote: number): boolean;
2166
+ /**
2167
+ * Gets the patch override for a MIDI key.
2168
+ * @param channel The MIDI channel number.
2169
+ * @param midiNote The MIDI note number (0-127).
2170
+ * @returns An object containing the bank and program numbers.
2171
+ * @throws Error if no modifier is set for the key.
2172
+ */
2173
+ getPatch(channel: number, midiNote: number): MIDIPatch;
2174
+ }
2175
+
2176
+ /**
2177
+ * Represents a snapshot of the synthesizer's state.
2178
+ */
2179
+ declare class SynthesizerSnapshot {
2180
+ /**
2181
+ * The individual channel snapshots.
2182
+ */
2183
+ channelSnapshots: ChannelSnapshot[];
2184
+ /**
2185
+ * Key modifiers.
2186
+ */
2187
+ keyMappings: (KeyModifier | undefined)[][];
2188
+ masterParameters: MasterParameterType;
2189
+ constructor(channelSnapshots: ChannelSnapshot[], masterParameters: MasterParameterType, keyMappings: (KeyModifier | undefined)[][]);
2190
+ /**
2191
+ * Creates a new synthesizer snapshot from the given SpessaSynthProcessor.
2192
+ * @param processor the processor to take a snapshot of.
2193
+ * @returns The snapshot.
2194
+ */
2195
+ static create(processor: SpessaSynthProcessor): SynthesizerSnapshot;
2196
+ /**
2197
+ * Creates a copy of existing snapshot.
2198
+ * @param snapshot The snapshot to create a copy from.
2199
+ */
2200
+ static copyFrom(snapshot: SynthesizerSnapshot): SynthesizerSnapshot;
2201
+ /**
2202
+ * Applies the snapshot to the synthesizer.
2203
+ * @param processor the processor to apply the snapshot to.
2204
+ */
2205
+ apply(processor: SpessaSynthProcessor): void;
2206
+ }
2207
+
2208
+ /**
2209
+ * Processor.ts
2210
+ * purpose: the core synthesis engine
2211
+ */
2212
+ declare class SpessaSynthProcessor {
2213
+ soundBankManager: SoundBankManager;
2214
+ /**
2215
+ * All MIDI channels of the synthesizer.
2216
+ */
2217
+ midiChannels: MIDIChannel[];
2218
+ /**
2219
+ * Handles the custom key overrides: velocity and preset
2220
+ */
2221
+ keyModifierManager: KeyModifierManager;
2222
+ /**
2223
+ * Current total amount of voices that are currently playing.
2224
+ */
2225
+ totalVoicesAmount: number;
2226
+ /**
2227
+ * Controls if the processor is fully initialized.
2228
+ */
2229
+ readonly processorInitialized: Promise<boolean>;
2230
+ /**
2231
+ * The current time of the synthesizer, in seconds. You probably should not modify this directly.
2232
+ */
2233
+ currentSynthTime: number;
2234
+ /**
2235
+ * Sample rate in Hertz.
2236
+ */
2237
+ readonly sampleRate: number;
2238
+ /**
2239
+ * Are the chorus and reverb effects enabled?
2240
+ */
2241
+ enableEffects: boolean;
2242
+ /**
2243
+ * Is the event system enabled?
2244
+ */
2245
+ enableEventSystem: boolean;
2246
+ /**
2247
+ * Calls when an event occurs.
2248
+ * @param event The event that occurred.
2249
+ */
2250
+ onEventCall?: (event: SynthProcessorEvent) => unknown;
2251
+ /**
2252
+ * Executes a system exclusive message for the synthesizer.
2253
+ * @param syx The system exclusive message as an array of bytes.
2254
+ * @param channelOffset The channel offset to apply (default is 0).
2255
+ */
2256
+ readonly systemExclusive: typeof systemExclusiveInternal;
2257
+ /**
2258
+ * Executes a full system reset of all controllers.
2259
+ * This will reset all controllers to their default values,
2260
+ * except for the locked controllers.
2261
+ */
2262
+ readonly resetAllControllers: typeof resetAllControllersInternal;
2263
+ /**
2264
+ * Sets a master parameter of the synthesizer.
2265
+ * @param type The type of the master parameter to set.
2266
+ * @param value The value to set for the master parameter.
2267
+ */
2268
+ readonly setMasterParameter: typeof setMasterParameterInternal;
2269
+ /**
2270
+ * Gets a master parameter of the synthesizer.
2271
+ * @param type The type of the master parameter to get.
2272
+ * @returns The value of the master parameter.
2273
+ */
2274
+ readonly getMasterParameter: typeof getMasterParameterInternal;
2275
+ /**
2276
+ * Gets all master parameters of the synthesizer.
2277
+ * @returns All the master parameters.
2278
+ */
2279
+ readonly getAllMasterParameters: typeof getAllMasterParametersInternal;
2280
+ /**
2281
+ * Gets voices for a preset.
2282
+ * @param preset The preset to get voices for.
2283
+ * @param bankMSB The bank to cache the voices in.
2284
+ * @param program Program to cache the voices in.
2285
+ * @param midiNote The MIDI note to use.
2286
+ * @param velocity The velocity to use.
2287
+ * @param realKey The real MIDI note if the "midiNote" was changed by MIDI Tuning Standard.
2288
+ * @returns Output is an array of voices.
2289
+ * @remarks
2290
+ * This is a public method, but it is only intended to be used by the sequencer.
2291
+ */
2292
+ readonly getVoicesForPreset: typeof getVoicesForPresetInternal;
2293
+ /**
2294
+ * Kills the specified number of voices based on their priority.
2295
+ * @param amount The number of voices to remove.
2296
+ */
2297
+ readonly killVoices: typeof killVoicesIntenral;
2298
+ protected readonly getVoices: (channel: number, midiNote: number, velocity: number, realKey: number) => VoiceList;
2299
+ protected privateProps: ProtectedSynthValues;
2300
+ /**
2301
+ * Tor applying the snapshot after an override sound bank too.
2302
+ */
2303
+ protected savedSnapshot?: SynthesizerSnapshot;
2304
+ /**
2305
+ * Synth's event queue from the main thread
2306
+ */
2307
+ protected eventQueue: {
2308
+ callback: () => unknown;
2309
+ time: number;
2310
+ }[];
2311
+ private readonly sampleTime;
2312
+ /**
2313
+ * Creates a new synthesizer engine.
2314
+ * @param sampleRate sample rate, in Hertz.
2315
+ * @param opts the processor's options.
2316
+ */
2317
+ constructor(sampleRate: number, opts?: Partial<SynthProcessorOptions>);
2318
+ /**
2319
+ * Applies the snapshot to the synth
2320
+ */
2321
+ applySynthesizerSnapshot(snapshot: SynthesizerSnapshot): void;
2322
+ /**
2323
+ * Gets a synthesizer snapshot from this processor instance.
2324
+ */
2325
+ getSnapshot(): SynthesizerSnapshot;
2326
+ /**
2327
+ * Sets the embedded sound bank.
2328
+ * @param bank The sound bank file to set.
2329
+ * @param offset The bank offset of the embedded sound bank.
2330
+ */
2331
+ setEmbeddedSoundBank(bank: ArrayBuffer, offset: number): void;
2332
+ clearEmbeddedBank(): void;
2333
+ createMIDIChannel(): void;
2334
+ /**
2335
+ * Stops all notes on all channels.
2336
+ * @param force if true, all notes are stopped immediately, otherwise they are stopped gracefully.
2337
+ */
2338
+ stopAllChannels(force?: boolean): void;
2339
+ /**
2340
+ * Renders float32 audio data to stereo outputs; buffer size of 128 is recommended.
2341
+ * All float arrays must have the same length.
2342
+ * @param outputs output stereo channels (L, R).
2343
+ * @param reverb reverb stereo channels (L, R).
2344
+ * @param chorus chorus stereo channels (L, R).
2345
+ * @param startIndex start offset of the passed arrays, rendering starts at this index, defaults to 0.
2346
+ * @param sampleCount the length of the rendered buffer, defaults to float32array length - startOffset.
2347
+ */
2348
+ renderAudio(outputs: Float32Array[], reverb: Float32Array[], chorus: Float32Array[], startIndex?: number, sampleCount?: number): void;
2349
+ /**
2350
+ * Renders the float32 audio data of each channel; buffer size of 128 is recommended.
2351
+ * All float arrays must have the same length.
2352
+ * @param reverbChannels reverb stereo channels (L, R).
2353
+ * @param chorusChannels chorus stereo channels (L, R).
2354
+ * @param separateChannels a total of 16 stereo pairs (L, R) for each MIDI channel.
2355
+ * @param startIndex start offset of the passed arrays, rendering starts at this index, defaults to 0.
2356
+ * @param sampleCount the length of the rendered buffer, defaults to float32array length - startOffset.
2357
+ */
2358
+ renderAudioSplit(reverbChannels: Float32Array[], chorusChannels: Float32Array[], separateChannels: Float32Array[][], startIndex?: number, sampleCount?: number): void;
2359
+ /**
2360
+ * Destroy the synthesizer processor, clearing all channels and voices.
2361
+ * This is irreversible, so use with caution.
2362
+ */
2363
+ destroySynthProcessor(): void;
2364
+ /**
2365
+ * Executes a MIDI controller change message on the specified channel.
2366
+ * @param channel The MIDI channel to change the controller on.
2367
+ * @param controllerNumber The MIDI controller number to change.
2368
+ * @param controllerValue The value to set the controller to.
2369
+ */
2370
+ controllerChange(channel: number, controllerNumber: MIDIController, controllerValue: number): void;
2371
+ /**
2372
+ * Executes a MIDI Note-on message on the specified channel.
2373
+ * @param channel The MIDI channel to send the note on.
2374
+ * @param midiNote The MIDI note number to play.
2375
+ * @param velocity The velocity of the note, from 0 to 127.
2376
+ * @remarks
2377
+ * If the velocity is 0, it will be treated as a Note-off message.
2378
+ */
2379
+ noteOn(channel: number, midiNote: number, velocity: number): void;
2380
+ /**
2381
+ * Executes a MIDI Note-off message on the specified channel.
2382
+ * @param channel The MIDI channel to send the note off.
2383
+ * @param midiNote The MIDI note number to stop playing.
2384
+ */
2385
+ noteOff(channel: number, midiNote: number): void;
2386
+ /**
2387
+ * Executes a MIDI Poly Pressure (Aftertouch) message on the specified channel.
2388
+ * @param channel The MIDI channel to send the poly pressure on.
2389
+ * @param midiNote The MIDI note number to apply the pressure to.
2390
+ * @param pressure The pressure value, from 0 to 127.
2391
+ */
2392
+ polyPressure(channel: number, midiNote: number, pressure: number): void;
2393
+ /**
2394
+ * Executes a MIDI Channel Pressure (Aftertouch) message on the specified channel.
2395
+ * @param channel The MIDI channel to send the channel pressure on.
2396
+ * @param pressure The pressure value, from 0 to 127.
2397
+ */
2398
+ channelPressure(channel: number, pressure: number): void;
2399
+ /**
2400
+ * Executes a MIDI Pitch Wheel message on the specified channel.
2401
+ * @param channel The MIDI channel to send the pitch wheel on.
2402
+ * @param pitch The new pitch value: 0-16384
2403
+ */
2404
+ pitchWheel(channel: number, pitch: number): void;
2405
+ /**
2406
+ * Executes a MIDI Program Change message on the specified channel.
2407
+ * @param channel The MIDI channel to send the program change on.
2408
+ * @param programNumber The program number to change to, from 0 to 127.
2409
+ */
2410
+ programChange(channel: number, programNumber: number): void;
2411
+ /**
2412
+ * Processes a raw MIDI message.
2413
+ * @param message The message to process.
2414
+ * @param channelOffset The channel offset for the message.
2415
+ * @param force If true, forces the message to be processed.
2416
+ * @param options Additional options for scheduling the message.
2417
+ */
2418
+ processMessage(message: Uint8Array | number[], channelOffset?: number, force?: boolean, options?: SynthMethodOptions): void;
2419
+ clearCache(): void;
2420
+ /**
2421
+ * @param volume {number} 0 to 1
2422
+ */
2423
+ protected setMIDIVolume(volume: number): void;
2424
+ /**
2425
+ * Sets the synth's primary tuning.
2426
+ * @param cents
2427
+ */
2428
+ protected setMasterTuning(cents: number): void;
2429
+ /**
2430
+ * Calls synth event
2431
+ * @param eventName the event name
2432
+ * @param eventData the event data
2433
+ */
2434
+ protected callEvent<K extends keyof SynthProcessorEventData>(eventName: K, eventData: SynthProcessorEventData[K]): void;
2435
+ protected getCachedVoice(patch: MIDIPatch, midiNote: number, velocity: number): VoiceList | undefined;
2436
+ protected setCachedVoice(patch: MIDIPatch, midiNote: number, velocity: number, voices: VoiceList): void;
2437
+ private createMIDIChannelInternal;
2438
+ private updatePresetList;
2439
+ private getDefaultPresets;
2440
+ }
2441
+
2442
+ declare class LowpassFilter {
2443
+ /**
2444
+ * Cached coefficient calculations.
2445
+ * stored as cachedCoefficients[resonanceCb][currentInitialFc].
2446
+ */
2447
+ private static cachedCoefficients;
2448
+ /**
2449
+ * Resonance in centibels.
2450
+ */
2451
+ resonanceCb: number;
2452
+ /**
2453
+ * Current cutoff frequency in absolute cents.
2454
+ */
2455
+ currentInitialFc: number;
2456
+ /**
2457
+ * Filter coefficient 1.
2458
+ */
2459
+ private a0;
2460
+ /**
2461
+ * Filter coefficient 2.
2462
+ */
2463
+ private a1;
2464
+ /**
2465
+ * Filter coefficient 3.
2466
+ */
2467
+ private a2;
2468
+ /**
2469
+ * Filter coefficient 4.
2470
+ */
2471
+ private a3;
2472
+ /**
2473
+ * Filter coefficient 5.
2474
+ */
2475
+ private a4;
2476
+ /**
2477
+ * Input history 1.
2478
+ */
2479
+ private x1;
2480
+ /**
2481
+ * Input history 2.
2482
+ */
2483
+ private x2;
2484
+ /**
2485
+ * Output history 1.
2486
+ */
2487
+ private y1;
2488
+ /**
2489
+ * Output history 2.
2490
+ */
2491
+ private y2;
2492
+ /**
2493
+ * For tracking the last cutoff frequency in the apply method, absolute cents.
2494
+ * Set to infinity to force recalculation.
2495
+ */
2496
+ private lastTargetCutoff;
2497
+ /**
2498
+ * Used for tracking if the filter has been initialized.
2499
+ */
2500
+ private initialized;
2501
+ /**
2502
+ * Filter's sample rate in Hz.
2503
+ */
2504
+ private sampleRate;
2505
+ /**
2506
+ * Maximum cutoff frequency in Hz.
2507
+ * This is used to prevent aliasing and ensure the filter operates within the valid frequency range.
2508
+ */
2509
+ private maxCutoff;
2510
+ /**
2511
+ * Initializes a new instance of the filter.
2512
+ * @param sampleRate the sample rate of the audio engine in Hz.
2513
+ */
2514
+ constructor(sampleRate: number);
2515
+ /**
2516
+ * Applies the lowpass filter to the output buffer of a voice.
2517
+ * @param voice The voice to apply the filter to.
2518
+ * @param outputBuffer The output buffer to filter.
2519
+ * @param fcExcursion The frequency excursion in cents to apply to the filter.
2520
+ * @param smoothingFactor The smoothing factor for the filter as determined by the parent synthesizer.
2521
+ */
2522
+ static apply(voice: Voice, outputBuffer: Float32Array, fcExcursion: number, smoothingFactor: number): void;
2523
+ /**
2524
+ * Calculates the filter coefficients based on the current resonance and cutoff frequency and caches them.
2525
+ * @param filter The lowpass filter instance to calculate coefficients for.
2526
+ * @param cutoffCents The cutoff frequency in cents.
2527
+ */
2528
+ static calculateCoefficients(filter: LowpassFilter, cutoffCents: number): void;
2529
+ }
2530
+
2531
+ /**
2532
+ * VOL ENV STATES:
2533
+ * 0 - delay
2534
+ * 1 - attack
2535
+ * 2 - hold/peak
2536
+ * 3 - decay
2537
+ * 4 - sustain
2538
+ * release indicates by isInRelease property
2539
+ */
2540
+ type VolumeEnvelopeState = 0 | 1 | 2 | 3 | 4;
2541
+ declare class VolumeEnvelope {
2542
+ /**
2543
+ * The sample rate in Hz.
2544
+ */
2545
+ sampleRate: number;
2546
+ /**
2547
+ * The current attenuation of the envelope in dB.
2548
+ */
2549
+ currentAttenuationDb: number;
2550
+ /**
2551
+ * The current stage of the volume envelope.
2552
+ */
2553
+ state: VolumeEnvelopeState;
2554
+ /**
2555
+ * The voice's absolute attenuation as linear gain.
2556
+ */
2557
+ attenuation: number;
2558
+ /**
2559
+ * The attenuation target, which the "attenuation" property is linearly interpolated towards (gain).
2560
+ */
2561
+ attenuationTargetGain: number;
2562
+ /**
2563
+ * The envelope's current time in samples.
2564
+ */
2565
+ protected currentSampleTime: number;
2566
+ /**
2567
+ * The dB attenuation of the envelope when it entered the release stage.
2568
+ */
2569
+ protected releaseStartDb: number;
2570
+ /**
2571
+ * The time in samples relative to the start of the envelope.
2572
+ */
2573
+ protected releaseStartTimeSamples: number;
2574
+ /**
2575
+ * The current gain applied to the voice in the release stage.
2576
+ */
2577
+ protected currentReleaseGain: number;
2578
+ /**
2579
+ * The attack duration in samples.
2580
+ */
2581
+ protected attackDuration: number;
2582
+ /**
2583
+ * The decay duration in samples.
2584
+ */
2585
+ protected decayDuration: number;
2586
+ /**
2587
+ * The release duration in samples.
2588
+ */
2589
+ protected releaseDuration: number;
2590
+ /**
2591
+ * The attenuation target, which the "attenuation" property is linearly interpolated towards (dB).
2592
+ */
2593
+ protected attenuationTarget: number;
2594
+ /**
2595
+ * The voice's sustain amount in dB, relative to attenuation.
2596
+ */
2597
+ protected sustainDbRelative: number;
2598
+ /**
2599
+ * The time in samples to the end of delay stage, relative to the start of the envelope.
2600
+ */
2601
+ protected delayEnd: number;
2602
+ /**
2603
+ * The time in samples to the end of attack stage, relative to the start of the envelope.
2604
+ */
2605
+ protected attackEnd: number;
2606
+ /**
2607
+ * The time in samples to the end of hold stage, relative to the start of the envelope.
2608
+ */
2609
+ protected holdEnd: number;
2610
+ /**
2611
+ * The time in samples to the end of decay stage, relative to the start of the envelope.
2612
+ */
2613
+ protected decayEnd: number;
2614
+ /**
2615
+ * If sustain stage is silent,
2616
+ * then we can turn off the voice when it is silent.
2617
+ * We can't do that with modulated as it can silence the volume and then raise it again, and the voice must keep playing.
2618
+ */
2619
+ protected canEndOnSilentSustain: boolean;
2620
+ /**
2621
+ * @param sampleRate Hz
2622
+ * @param initialDecay cb
2623
+ */
2624
+ constructor(sampleRate: number, initialDecay: number);
2625
+ /**
2626
+ * Starts the release phase in the envelope.
2627
+ * @param voice the voice this envelope belongs to.
2628
+ */
2629
+ static startRelease(voice: Voice): void;
2630
+ /**
2631
+ * Recalculates the envelope
2632
+ * @param voice the voice this envelope belongs to
2633
+ */
2634
+ static recalculate(voice: Voice): void;
2635
+ /**
2636
+ * Applies volume envelope gain to the given output buffer.
2637
+ * Essentially we use approach of 100dB is silence, 0dB is peak, and always add attenuation to that (which is interpolated).
2638
+ * @param voice the voice we're working on
2639
+ * @param audioBuffer the audio buffer to modify
2640
+ * @param centibelOffset the centibel offset of volume, for modLFOtoVolume
2641
+ * @param smoothingFactor the adjusted smoothing factor for the envelope
2642
+ */
2643
+ static apply(voice: Voice, audioBuffer: Float32Array, centibelOffset: number, smoothingFactor: number): void;
2644
+ }
2645
+
2646
+ declare class ModulationEnvelope {
2647
+ /**
2648
+ * The attack duration, in seconds.
2649
+ */
2650
+ protected attackDuration: number;
2651
+ /**
2652
+ * The decay duration, in seconds.
2653
+ */
2654
+ protected decayDuration: number;
2655
+ /**
2656
+ * The hold duration, in seconds.
2657
+ */
2658
+ protected holdDuration: number;
2659
+ /**
2660
+ * Release duration, in seconds.
2661
+ */
2662
+ protected releaseDuration: number;
2663
+ /**
2664
+ * The sustain level 0-1.
2665
+ */
2666
+ protected sustainLevel: number;
2667
+ /**
2668
+ * Delay phase end time in seconds, absolute (audio context time).
2669
+ */
2670
+ protected delayEnd: number;
2671
+ /**
2672
+ * Attack phase end time in seconds, absolute (audio context time).
2673
+ */
2674
+ protected attackEnd: number;
2675
+ /**
2676
+ * Hold phase end time in seconds, absolute (audio context time).
2677
+ */
2678
+ protected holdEnd: number;
2679
+ /**
2680
+ * Decay phase end time in seconds, absolute (audio context time).
2681
+ */
2682
+ protected decayEnd: number;
2683
+ /**
2684
+ * The level of the envelope when the release phase starts.
2685
+ */
2686
+ protected releaseStartLevel: number;
2687
+ /**
2688
+ * The current modulation envelope value.
2689
+ */
2690
+ protected currentValue: number;
2691
+ /**
2692
+ * Starts the release phase in the envelope.
2693
+ * @param voice the voice this envelope belongs to.
2694
+ */
2695
+ static startRelease(voice: Voice): void;
2696
+ /**
2697
+ * @param voice the voice to recalculate.
2698
+ */
2699
+ static recalculate(voice: Voice): void;
2700
+ /**
2701
+ * Calculates the current modulation envelope value for the given time and voice.
2702
+ * @param voice the voice we are working on.
2703
+ * @param currentTime in seconds.
2704
+ * @param ignoreRelease if true, it will compute the value as if the voice was not released.
2705
+ * @returns mod env value, from 0 to 1.
2706
+ */
2707
+ static getValue(voice: Voice, currentTime: number, ignoreRelease?: boolean): number;
2708
+ }
2709
+
2710
+ declare class AudioSample {
2711
+ /**
2712
+ * The sample's audio data
2713
+ */
2714
+ readonly sampleData: Float32Array;
2715
+ /**
2716
+ * Current playback step (rate)
2717
+ */
2718
+ readonly playbackStep: number;
2719
+ /**
2720
+ * Current position in the sample
2721
+ */
2722
+ cursor: number;
2723
+ /**
2724
+ * MIDI root key of the sample
2725
+ */
2726
+ readonly rootKey: number;
2727
+ /**
2728
+ * Start position of the loop
2729
+ */
2730
+ loopStart: number;
2731
+ /**
2732
+ * End position of the loop
2733
+ */
2734
+ loopEnd: number;
2735
+ /**
2736
+ * End position of the sample
2737
+ */
2738
+ end: number;
2739
+ /**
2740
+ * Looping mode of the sample:
2741
+ * 0 - no loop
2742
+ * 1 - loop
2743
+ * 2 - UNOFFICIAL: polyphone 2.4 added start on release
2744
+ * 3 - loop then play when released
2745
+ */
2746
+ loopingMode: SampleLoopingMode;
2747
+ /**
2748
+ * Indicates if the sample is currently looping
2749
+ */
2750
+ isLooping: boolean;
2751
+ /**
2752
+ * @param data
2753
+ * @param playbackStep the playback step, a single increment
2754
+ * @param cursorStart the sample id which starts the playback
2755
+ * @param rootKey MIDI root key
2756
+ * @param loopStart loop start index
2757
+ * @param loopEnd loop end index
2758
+ * @param endIndex sample end index (for end offset)
2759
+ * @param loopingMode sample looping mode
2760
+ */
2761
+ constructor(data: Float32Array, playbackStep: number, cursorStart: number, rootKey: number, loopStart: number, loopEnd: number, endIndex: number, loopingMode: SampleLoopingMode);
2762
+ }
2763
+
2764
+ /**
2765
+ * Voice.ts
2766
+ * purpose: prepares Voices from sample and generator data
2767
+ */
2768
+
2769
+ /**
2770
+ * Voice represents a single instance of the
2771
+ * SoundFont2 synthesis model.
2772
+ * That is:
2773
+ * A wavetable oscillator (sample)
2774
+ * A volume envelope (volumeEnvelope)
2775
+ * A modulation envelope (modulationEnvelope)
2776
+ * Generators (generators and modulatedGenerators)
2777
+ * Modulators (modulators)
2778
+ * And MIDI params such as channel, MIDI note, velocity
2779
+ */
2780
+ declare class Voice {
2781
+ /**
2782
+ * The sample of the voice.
2783
+ */
2784
+ sample: AudioSample;
2785
+ /**
2786
+ * Lowpass filter applied to the voice.
2787
+ */
2788
+ filter: LowpassFilter;
2789
+ /**
2790
+ * Linear gain of the voice. Used with Key Modifiers.
2791
+ */
2792
+ gain: number;
2793
+ /**
2794
+ * The unmodulated (copied to) generators of the voice.
2795
+ */
2796
+ generators: Int16Array;
2797
+ /**
2798
+ * The voice's modulators.
2799
+ */
2800
+ modulators: Modulator[];
2801
+ /**
2802
+ * Resonance offset, it is affected by the default resonant modulator
2803
+ */
2804
+ resonanceOffset: number;
2805
+ /**
2806
+ * The generators in real-time, affected by modulators.
2807
+ * This is used during rendering.
2808
+ */
2809
+ modulatedGenerators: Int16Array;
2810
+ /**
2811
+ * Indicates if the voice is finished.
2812
+ */
2813
+ finished: boolean;
2814
+ /**
2815
+ * Indicates if the voice is in the release phase.
2816
+ */
2817
+ isInRelease: boolean;
2818
+ /**
2819
+ * Velocity of the note.
2820
+ */
2821
+ velocity: number;
2822
+ /**
2823
+ * MIDI note number.
2824
+ */
2825
+ midiNote: number;
2826
+ /**
2827
+ * The pressure of the voice
2828
+ */
2829
+ pressure: number;
2830
+ /**
2831
+ * Target key for the note.
2832
+ */
2833
+ targetKey: number;
2834
+ /**
2835
+ * Modulation envelope.
2836
+ */
2837
+ modulationEnvelope: ModulationEnvelope;
2838
+ /**
2839
+ * Volume envelope.
2840
+ */
2841
+ volumeEnvelope: VolumeEnvelope;
2842
+ /**
2843
+ * Start time of the voice, absolute.
2844
+ */
2845
+ startTime: number;
2846
+ /**
2847
+ * Start time of the release phase, absolute.
2848
+ */
2849
+ releaseStartTime: number;
2850
+ /**
2851
+ * Current tuning in cents.
2852
+ */
2853
+ currentTuningCents: number;
2854
+ /**
2855
+ * Current calculated tuning. (as in ratio)
2856
+ */
2857
+ currentTuningCalculated: number;
2858
+ /**
2859
+ * From -500 to 500.
2860
+ */
2861
+ currentPan: number;
2862
+ /**
2863
+ * If MIDI Tuning Standard is already applied (at note-on time),
2864
+ * this will be used to take the values at real-time tuning as "midiNote"
2865
+ * property contains the tuned number.
2866
+ * see SpessaSynth#29 comment by @paulikaro
2867
+ */
2868
+ realKey: number;
2869
+ /**
2870
+ * Initial key to glide from, MIDI Note number. If -1, the portamento is OFF.
2871
+ */
2872
+ portamentoFromKey: number;
2873
+ /**
2874
+ * Duration of the linear glide, in seconds.
2875
+ */
2876
+ portamentoDuration: number;
2877
+ /**
2878
+ * From -500 to 500, where zero means disabled (use the channel pan). Used for random pan.
2879
+ */
2880
+ overridePan: number;
2881
+ /**
2882
+ * Exclusive class number for hi-hats etc.
2883
+ */
2884
+ exclusiveClass: number;
2885
+ /**
2886
+ * Creates a Voice.
2887
+ */
2888
+ constructor(sampleRate: number, audioSample: AudioSample, midiNote: number, velocity: number, currentTime: number, targetKey: number, realKey: number, generators: Int16Array, modulators: Modulator[]);
2889
+ /**
2890
+ * Copies a voice.
2891
+ */
2892
+ static copyFrom(voice: Voice, currentTime: number, realKey: number): Voice;
2893
+ /**
2894
+ * Releases the voice as exclusiveClass.
2895
+ */
2896
+ exclusiveRelease(currentTime: number): void;
2897
+ /**
2898
+ * Stops the voice
2899
+ * @param currentTime
2900
+ * @param minNoteLength minimum note length in seconds
2901
+ */
2902
+ release(currentTime: number, minNoteLength?: number): void;
2903
+ }
2904
+ /**
2905
+ * @param preset the preset to get voices for
2906
+ * @param midiNote the MIDI note to use
2907
+ * @param velocity the velocity to use
2908
+ * @param realKey the real MIDI note if the "midiNote" was changed by MIDI Tuning Standard
2909
+ * @returns output is an array of Voices
2910
+ */
2911
+ declare function getVoicesForPresetInternal(this: SpessaSynthProcessor, preset: BasicPreset, midiNote: number, velocity: number, realKey: number): VoiceList;
2912
+
2913
+ declare class ModulatorSource {
2914
+ /**
2915
+ * If this field is set to false, the controller should be mapped with a minimum value of 0 and a maximum value of 1. This is also
2916
+ * called Unipolar. Thus, it behaves similar to the Modulation Wheel controller of the MIDI specification.
2917
+ *
2918
+ * If this field is set to true, the controller sound be mapped with a minimum value of -1 and a maximum value of 1. This is also
2919
+ * called Bipolar. Thus, it behaves similar to the Pitch Wheel controller of the MIDI specification.
2920
+ */
2921
+ isBipolar: boolean;
2922
+ /**
2923
+ * If this field is set true, the direction of the controller should be from the maximum value to the minimum value. So, for
2924
+ * example, if the controller source is Key Number, then a Key Number value of 0 corresponds to the maximum possible
2925
+ * controller output, and the Key Number value of 127 corresponds to the minimum possible controller input.
2926
+ */
2927
+ isNegative: boolean;
2928
+ /**
2929
+ * The index of the source.
2930
+ * It can point to one of the MIDI controllers or one of the predefined sources, depending on the 'isCC' flag.
2931
+ */
2932
+ index: ModulatorSourceIndex;
2933
+ /**
2934
+ * If this field is set to true, the MIDI Controller Palette is selected. The ‘index’ field value corresponds to one of the 128
2935
+ * MIDI Continuous Controller messages as defined in the MIDI specification.
2936
+ */
2937
+ isCC: boolean;
2938
+ /**
2939
+ * This field specifies how the minimum value approaches the maximum value.
2940
+ */
2941
+ curveType: ModulatorCurveType;
2942
+ constructor(index?: ModulatorSourceIndex, curveType?: ModulatorCurveType, isCC?: boolean, isBipolar?: boolean, isNegative?: boolean);
2943
+ private get sourceName();
2944
+ private get curveTypeName();
2945
+ static fromSourceEnum(sourceEnum: number): ModulatorSource;
2946
+ /**
2947
+ * Copies the modulator source.
2948
+ * @param source The source to copy from.
2949
+ * @returns the copied source.
2950
+ */
2951
+ static copyFrom(source: ModulatorSource): ModulatorSource;
2952
+ toString(): string;
2953
+ toSourceEnum(): number;
2954
+ isIdentical(source: ModulatorSource): boolean;
2955
+ /**
2956
+ * Gets the current value from this source.
2957
+ * @param midiControllers The MIDI controller + modulator source array.
2958
+ * @param voice The voice to get the data for.
2959
+ */
2960
+ getValue(midiControllers: Int16Array, voice: Voice): number;
2961
+ }
2962
+
2963
+ declare class Modulator {
2964
+ /**
2965
+ * The current computed value of this modulator. Only used in the synthesis engine for local voices.
2966
+ */
2967
+ currentValue: number;
2968
+ /**
2969
+ * The generator destination of this modulator.
2970
+ */
2971
+ destination: GeneratorType;
2972
+ /**
2973
+ * The transform amount for this modulator.
2974
+ */
2975
+ transformAmount: number;
2976
+ /**
2977
+ * The transform type for this modulator.
2978
+ */
2979
+ transformType: ModulatorTransformType;
2980
+ /**
2981
+ * Indicates if the given modulator is chorus or reverb effects modulator.
2982
+ * This is done to simulate BASSMIDI effects behavior:
2983
+ * - defaults to 1000 transform amount rather than 200
2984
+ * - values can be changed, but anything above 200 is 1000
2985
+ * (except for values above 1000, they are copied directly)
2986
+ * - all values below are multiplied by 5 (200 * 5 = 1000)
2987
+ * - still can be disabled if the soundfont has its own modulator curve
2988
+ * - this fixes the very low amount of reverb by default and doesn't break soundfonts
2989
+ */
2990
+ readonly isEffectModulator: boolean;
2991
+ /**
2992
+ * The default resonant modulator does not affect the filter gain.
2993
+ * Neither XG nor GS responded to cc #74 in that way.
2994
+ */
2995
+ readonly isDefaultResonantModulator: boolean;
2996
+ /**
2997
+ * The primary source of this modulator.
2998
+ */
2999
+ readonly primarySource: ModulatorSource;
3000
+ /**
3001
+ * The secondary source of this modulator.
3002
+ */
3003
+ readonly secondarySource: ModulatorSource;
3004
+ /**
3005
+ * Creates a new SF2 Modulator
3006
+ */
3007
+ constructor(primarySource?: ModulatorSource, secondarySource?: ModulatorSource, destination?: GeneratorType, amount?: number, transformType?: ModulatorTransformType, isEffectModulator?: boolean, isDefaultResonantModulator?: boolean);
3008
+ private get destinationName();
3009
+ /**
3010
+ * Checks if the pair of modulators is identical (in SF2 terms)
3011
+ * @param mod1 modulator 1
3012
+ * @param mod2 modulator 2
3013
+ * @param checkAmount if the amount should be checked too.
3014
+ * @returns if they are identical
3015
+ */
3016
+ static isIdentical(mod1: Modulator, mod2: Modulator, checkAmount?: boolean): boolean;
3017
+ /**
3018
+ * Copies a modulator.
3019
+ * @param mod The modulator to copy.
3020
+ * @returns The copied modulator.
3021
+ */
3022
+ static copyFrom(mod: Modulator): Modulator;
3023
+ toString(): string;
3024
+ write(modData: IndexedByteArray, indexes?: SoundFontWriteIndexes): void;
3025
+ /**
3026
+ * Sums transform and create a NEW modulator
3027
+ * @param modulator the modulator to sum with
3028
+ * @returns the new modulator
3029
+ */
3030
+ sumTransform(modulator: Modulator): Modulator;
3031
+ }
3032
+
3033
+ /**
3034
+ * Midi_message.ts
3035
+ * purpose: contains enums for midi events and controllers and functions to parse them
3036
+ */
3037
+
3038
+ declare class MIDIMessage {
3039
+ /**
3040
+ * Absolute number of MIDI ticks from the start of the track.
3041
+ */
3042
+ ticks: number;
3043
+ /**
3044
+ * The MIDI message status byte. Note that for meta events, it is the second byte. (not 0xFF)
3045
+ */
3046
+ statusByte: MIDIMessageType;
3047
+ /**
3048
+ * Message's binary data
3049
+ */
3050
+ data: Uint8Array<ArrayBuffer>;
3051
+ /**
3052
+ * Creates a new MIDI message
3053
+ * @param ticks time of this message in absolute MIDI ticks
3054
+ * @param byte the message status byte
3055
+ * @param data the message's binary data
3056
+ */
3057
+ constructor(ticks: number, byte: MIDIMessageType, data: Uint8Array<ArrayBuffer>);
3058
+ }
3059
+
3060
+ declare class MIDITrack {
3061
+ /**
3062
+ * The name of this track.
3063
+ */
3064
+ name: string;
3065
+ /**
3066
+ * The MIDI port number used by the track.
3067
+ */
3068
+ port: number;
3069
+ /**
3070
+ * A set that contains the MIDI channels used by the track in the sequence.
3071
+ */
3072
+ channels: Set<number>;
3073
+ /**
3074
+ * All the MIDI messages of this track.
3075
+ */
3076
+ events: Omit<MIDIMessage[], "push" | "splice">;
3077
+ static copyFrom(track: MIDITrack): MIDITrack;
3078
+ copyFrom(track: MIDITrack): void;
3079
+ /**
3080
+ * Adds an event to the track.
3081
+ * @param event The event to add.
3082
+ * @param index The index at which to add this event.
3083
+ */
3084
+ addEvent(event: MIDIMessage, index: number): void;
3085
+ /**
3086
+ * Removes an event from the track.
3087
+ * @param index The index of the event to remove.
3088
+ */
3089
+ deleteEvent(index: number): void;
3090
+ /**
3091
+ * Appends an event to the end of the track.
3092
+ * @param event The event to add.
3093
+ */
3094
+ pushEvent(event: MIDIMessage): void;
3095
+ }
3096
+
3097
+ /**
3098
+ * BasicMIDI is the base of a complete MIDI file.
3099
+ */
3100
+ declare class BasicMIDI {
3101
+ /**
3102
+ * The tracks in the sequence.
3103
+ */
3104
+ tracks: MIDITrack[];
3105
+ /**
3106
+ * The time division of the sequence, representing the number of ticks per beat.
3107
+ */
3108
+ timeDivision: number;
3109
+ /**
3110
+ * The duration of the sequence, in seconds.
3111
+ */
3112
+ duration: number;
3113
+ /**
3114
+ * The tempo changes in the sequence, ordered from the last change to the first.
3115
+ * Each change is represented by an object with a tick position and a tempo value in beats per minute.
3116
+ */
3117
+ tempoChanges: TempoChange[];
3118
+ /**
3119
+ * Any extra metadata found in the file.
3120
+ * These messages were deemed "interesting" by the parsing algorithm
3121
+ */
3122
+ extraMetadata: MIDIMessage[];
3123
+ /**
3124
+ * An array containing the lyrics of the sequence.
3125
+ */
3126
+ lyrics: MIDIMessage[];
3127
+ /**
3128
+ * The tick position of the first note-on event in the MIDI sequence.
3129
+ */
3130
+ firstNoteOn: number;
3131
+ /**
3132
+ * The MIDI key range used in the sequence, represented by a minimum and maximum note value.
3133
+ */
3134
+ keyRange: GenericRange;
3135
+ /**
3136
+ * The tick position of the last voice event (such as note-on, note-off, or control change) in the sequence.
3137
+ */
3138
+ lastVoiceEventTick: number;
3139
+ /**
3140
+ * An array of channel offsets for each MIDI port, using the SpessaSynth method.
3141
+ * The index is the port number and the value is the channel offset.
3142
+ */
3143
+ portChannelOffsetMap: number[];
3144
+ /**
3145
+ * The loop points (in ticks) of the sequence, including both start and end points.
3146
+ */
3147
+ loop: MIDILoop;
3148
+ /**
3149
+ * The file name of the MIDI sequence, if provided during parsing.
3150
+ */
3151
+ fileName?: string;
3152
+ /**
3153
+ * The format of the MIDI file, which can be 0, 1, or 2, indicating the type of the MIDI file.
3154
+ */
3155
+ format: MIDIFormat;
3156
+ /**
3157
+ * The RMID (Resource-Interchangeable MIDI) info data, if the file is RMID formatted.
3158
+ * Otherwise, this object is empty.
3159
+ * Info type: Chunk data as a binary array.
3160
+ * Note that text chunks contain a terminal zero byte.
3161
+ */
3162
+ rmidiInfo: Partial<Record<keyof RMIDInfoData, Uint8Array<ArrayBuffer>>>;
3163
+ /**
3164
+ * The bank offset used for RMID files.
3165
+ */
3166
+ bankOffset: number;
3167
+ /**
3168
+ * If the MIDI file is a Soft Karaoke file (.kar), this is set to true.
3169
+ * https://www.mixagesoftware.com/en/midikit/help/HTML/karaoke_formats.html
3170
+ */
3171
+ isKaraokeFile: boolean;
3172
+ /**
3173
+ * Indicates if this file is a Multi-Port MIDI file.
3174
+ */
3175
+ isMultiPort: boolean;
3176
+ /**
3177
+ * If the MIDI file is a DLS RMIDI file.
3178
+ */
3179
+ isDLSRMIDI: boolean;
3180
+ /**
3181
+ * The embedded sound bank in the MIDI file, represented as an ArrayBuffer, if available.
3182
+ */
3183
+ embeddedSoundBank?: ArrayBuffer;
3184
+ /**
3185
+ * The raw, encoded MIDI name, represented as a Uint8Array.
3186
+ * Useful when the MIDI file uses a different code page.
3187
+ * Undefined if no MIDI name could be found.
3188
+ */
3189
+ protected binaryName?: Uint8Array;
3190
+ /**
3191
+ * The encoding of the RMIDI info in file, if specified.
3192
+ */
3193
+ get infoEncoding(): string | undefined;
3194
+ /**
3195
+ * Loads a MIDI file (SMF, RMIDI, XMF) from a given ArrayBuffer.
3196
+ * @param arrayBuffer The ArrayBuffer containing the binary file data.
3197
+ * @param fileName The optional name of the file, will be used if the MIDI file does not have a name.
3198
+ */
3199
+ static fromArrayBuffer(arrayBuffer: ArrayBuffer, fileName?: string): BasicMIDI;
3200
+ /**
3201
+ * Loads a MIDI file (SMF, RMIDI, XMF) from a given file.
3202
+ * @param file The file to load.
3203
+ */
3204
+ static fromFile(file: File): Promise<BasicMIDI>;
3205
+ /**
3206
+ * Copies a MIDI.
3207
+ * @param mid The MIDI to copy.
3208
+ * @returns The copied MIDI.
3209
+ */
3210
+ static copyFrom(mid: BasicMIDI): BasicMIDI;
3211
+ /**
3212
+ * Copies a MIDI.
3213
+ * @param mid The MIDI to copy.
3214
+ */
3215
+ copyFrom(mid: BasicMIDI): void;
3216
+ /**
3217
+ * Converts MIDI ticks to time in seconds.
3218
+ * @param ticks The time in MIDI ticks.
3219
+ * @returns The time in seconds.
3220
+ */
3221
+ midiTicksToSeconds(ticks: number): number;
3222
+ /**
3223
+ * Gets the used programs and keys for this MIDI file with a given sound bank.
3224
+ * @param soundbank the sound bank.
3225
+ * @returns The output data is a key-value pair: preset -> Set<"key-velocity">
3226
+ */
3227
+ getUsedProgramsAndKeys(soundbank: BasicSoundBank | SoundBankManager): Map<BasicPreset, Set<string>>;
3228
+ /**
3229
+ * Updates all internal values of the MIDI.
3230
+ * @param sortEvents if the events should be sorted by ticks. Recommended to be true.
3231
+ */
3232
+ flush(sortEvents?: boolean): void;
3233
+ /**
3234
+ * Calculates all note times in seconds.
3235
+ * @param minDrumLength the shortest a drum note (channel 10) can be, in seconds.
3236
+ * @returns an array of 16 channels, each channel containing its notes,
3237
+ * with their key number, velocity, absolute start time and length in seconds.
3238
+ */
3239
+ getNoteTimes(minDrumLength?: number): NoteTime[][];
3240
+ /**
3241
+ * Exports the midi as a standard MIDI file.
3242
+ * @returns the binary file data.
3243
+ */
3244
+ writeMIDI(): ArrayBuffer;
3245
+ /**
3246
+ * Writes an RMIDI file. Note that this method modifies the MIDI file in-place.
3247
+ * @param soundBankBinary the binary sound bank to embed into the file.
3248
+ * @param configuration Extra options for writing the file.
3249
+ * @returns the binary file data.
3250
+ */
3251
+ writeRMIDI(soundBankBinary: ArrayBuffer, configuration?: Partial<RMIDIWriteOptions>): ArrayBuffer;
3252
+ /**
3253
+ * Allows easy editing of the file by removing channels, changing programs,
3254
+ * changing controllers and transposing channels. Note that this modifies the MIDI *in-place*.
3255
+ * @param desiredProgramChanges - The programs to set on given channels.
3256
+ * @param desiredControllerChanges - The controllers to set on given channels.
3257
+ * @param desiredChannelsToClear - The channels to remove from the sequence.
3258
+ * @param desiredChannelsToTranspose - The channels to transpose.
3259
+ */
3260
+ modify(desiredProgramChanges?: DesiredProgramChange[], desiredControllerChanges?: DesiredControllerChange[], desiredChannelsToClear?: number[], desiredChannelsToTranspose?: DesiredChannelTranspose[]): void;
3261
+ /**
3262
+ * Modifies the sequence *in-place* according to the locked presets and controllers in the given snapshot.
3263
+ * @param snapshot the snapshot to apply.
3264
+ */
3265
+ applySnapshot(snapshot: SynthesizerSnapshot): void;
3266
+ /**
3267
+ * Gets the MIDI's decoded name.
3268
+ * @param encoding The encoding to use if the MIDI uses an extended code page.
3269
+ * @remarks
3270
+ * Do not call in audioWorkletGlobalScope as it uses TextDecoder.
3271
+ * RMIDI encoding overrides the provided encoding.
3272
+ */
3273
+ getName(encoding?: string): string | undefined;
3274
+ /**
3275
+ * Gets the decoded extra metadata as text and removes any unneeded characters (such as "@T" for karaoke files)
3276
+ * @param encoding The encoding to use if the MIDI uses an extended code page.
3277
+ * @remarks
3278
+ * Do not call in audioWorkletGlobalScope as it uses TextDecoder.
3279
+ * RMIDI encoding overrides the provided encoding.
3280
+ */
3281
+ getExtraMetadata(encoding?: string): string[];
3282
+ /**
3283
+ * Sets a given RMIDI info value.
3284
+ * @param infoType The type to set.
3285
+ * @param infoData The value to set it to.
3286
+ * @remarks
3287
+ * This sets the Info encoding to utf-8.
3288
+ */
3289
+ setRMIDInfo<K extends keyof RMIDInfoData>(infoType: K, infoData: RMIDInfoData[K]): void;
3290
+ /**
3291
+ * Gets a given chunk from the RMIDI information, undefined if it does not exist.
3292
+ * @param infoType The metadata type.
3293
+ * @returns String, Date, ArrayBuffer or undefined.
3294
+ */
3295
+ getRMIDInfo<K extends keyof RMIDInfoData>(infoType: K): RMIDInfoData[K] | undefined;
3296
+ /**
3297
+ * INTERNAL USE ONLY!
3298
+ */
3299
+ protected copyMetadataFrom(mid: BasicMIDI): void;
3300
+ /**
3301
+ * Parses internal MIDI values
3302
+ */
3303
+ protected parseInternal(): void;
3304
+ }
3305
+
3306
+ /**
3307
+ * Represents a single sound bank, be it DLS or SF2.
3308
+ */
3309
+ declare class BasicSoundBank {
3310
+ /**
3311
+ * Indicates if the SF3/SF2Pack decoder is ready.
3312
+ */
3313
+ static isSF3DecoderReady: Promise<boolean>;
3314
+ /**
3315
+ * Sound bank's info.
3316
+ */
3317
+ soundBankInfo: SoundBankInfoData;
3318
+ /**
3319
+ * The sound bank's presets.
3320
+ */
3321
+ presets: BasicPreset[];
3322
+ /**
3323
+ * The sound bank's samples.
3324
+ */
3325
+ samples: BasicSample[];
3326
+ /**
3327
+ * The sound bank's instruments.
3328
+ */
3329
+ instruments: BasicInstrument[];
3330
+ /**
3331
+ * Sound bank's default modulators.
3332
+ */
3333
+ defaultModulators: Modulator[];
3334
+ /**
3335
+ * If the sound bank has custom default modulators (DMOD).
3336
+ */
3337
+ customDefaultModulators: boolean;
3338
+ private _isXGBank;
3339
+ /**
3340
+ * Checks for XG drum sets and considers if this sound bank is XG.
3341
+ */
3342
+ get isXGBank(): boolean;
3343
+ /**
3344
+ * Merges sound banks with the given order. Keep in mind that the info read is copied from the first one
3345
+ * @param soundBanks the sound banks to merge, the first overwrites the last
3346
+ */
3347
+ static mergeSoundBanks(...soundBanks: BasicSoundBank[]): BasicSoundBank;
3348
+ /**
3349
+ * Creates a simple sound bank with one saw wave preset.
3350
+ */
3351
+ static getSampleSoundBankFile(): Promise<ArrayBuffer>;
3352
+ /**
3353
+ * Copies a given sound bank.
3354
+ * @param bank The sound bank to copy.
3355
+ */
3356
+ static copyFrom(bank: BasicSoundBank): BasicSoundBank;
3357
+ /**
3358
+ * Adds complete presets along with their instruments and samples.
3359
+ * @param presets The presets to add.
3360
+ */
3361
+ addCompletePresets(presets: BasicPreset[]): void;
3362
+ /**
3363
+ * Write the sound bank as a .dls file. This may not be 100% accurate.
3364
+ * @param options - options for writing the file.
3365
+ * @returns the binary file.
3366
+ */
3367
+ writeDLS(options?: Partial<DLSWriteOptions>): Promise<ArrayBuffer>;
3368
+ /**
3369
+ * Writes the sound bank as an SF2 file.
3370
+ * @param writeOptions the options for writing.
3371
+ * @returns the binary file data.
3372
+ */
3373
+ writeSF2(writeOptions?: Partial<SoundFont2WriteOptions>): Promise<ArrayBuffer>;
3374
+ addPresets(...presets: BasicPreset[]): void;
3375
+ addInstruments(...instruments: BasicInstrument[]): void;
3376
+ addSamples(...samples: BasicSample[]): void;
3377
+ /**
3378
+ * Clones a sample into this bank.
3379
+ * @param sample The sample to copy.
3380
+ * @returns the copied sample, if a sample exists with that name, it is returned instead
3381
+ */
3382
+ cloneSample(sample: BasicSample): BasicSample;
3383
+ /**
3384
+ * Recursively clones an instrument into this sound bank, as well as its samples.
3385
+ * @returns the copied instrument, if an instrument exists with that name, it is returned instead.
3386
+ */
3387
+ cloneInstrument(instrument: BasicInstrument): BasicInstrument;
3388
+ /**
3389
+ * Recursively clones a preset into this sound bank, as well as its instruments and samples.
3390
+ * @returns the copied preset, if a preset exists with that name, it is returned instead.
3391
+ */
3392
+ clonePreset(preset: BasicPreset): BasicPreset;
3393
+ /**
3394
+ * Updates internal values.
3395
+ */
3396
+ flush(): void;
3397
+ /**
3398
+ * Trims a sound bank to only contain samples in a given MIDI file.
3399
+ * @param mid - the MIDI file
3400
+ */
3401
+ trimSoundBank(mid: BasicMIDI): void;
3402
+ removeUnusedElements(): void;
3403
+ deleteInstrument(instrument: BasicInstrument): void;
3404
+ deletePreset(preset: BasicPreset): void;
3405
+ deleteSample(sample: BasicSample): void;
3406
+ /**
3407
+ * Get the appropriate preset.
3408
+ */
3409
+ getPreset(patch: MIDIPatch, system: SynthSystem): BasicPreset;
3410
+ destroySoundBank(): void;
3411
+ protected parsingError(error: string): void;
3412
+ /**
3413
+ * Parses the bank after loading is done
3414
+ * @protected
3415
+ */
3416
+ protected parseInternal(): void;
3417
+ protected printInfo(): void;
3418
+ }
3419
+
3420
+ /**
3421
+ * RMIDInfoData type represents metadata for an RMIDI file.
3422
+ */
3423
+ interface RMIDInfoData {
3424
+ /**
3425
+ * The name of the song.
3426
+ */
3427
+ name: string;
3428
+ /**
3429
+ * The engineer who worked on the sound bank file.
3430
+ */
3431
+ engineer: string;
3432
+ /**
3433
+ * The artist of the MIDI file.
3434
+ */
3435
+ artist: string;
3436
+ /**
3437
+ * The album of the song.
3438
+ */
3439
+ album: string;
3440
+ /**
3441
+ * The genre of the song.
3442
+ */
3443
+ genre: string;
3444
+ /**
3445
+ * The image for the file (album cover).
3446
+ */
3447
+ picture: ArrayBuffer;
3448
+ /**
3449
+ * The comment of the file.
3450
+ */
3451
+ comment: string;
3452
+ /**
3453
+ * The creation date of the file.
3454
+ */
3455
+ creationDate: Date;
3456
+ /**
3457
+ * The copyright of the file.
3458
+ */
3459
+ copyright: string;
3460
+ /**
3461
+ * The encoding of the RMIDI info.
3462
+ */
3463
+ infoEncoding: string;
3464
+ /**
3465
+ * The encoding of the MIDI file's text messages.
3466
+ */
3467
+ midiEncoding: string;
3468
+ /**
3469
+ * The software used to write the file.
3470
+ */
3471
+ software: string;
3472
+ /**
3473
+ * The subject of the file.
3474
+ */
3475
+ subject: string;
3476
+ }
3477
+ interface TempoChange {
3478
+ /**
3479
+ * MIDI ticks of the change.
3480
+ */
3481
+ ticks: number;
3482
+ /**
3483
+ * New tempo in BPM.
3484
+ */
3485
+ tempo: number;
3486
+ }
3487
+ interface MIDILoop {
3488
+ /**
3489
+ * Start of the loop, in MIDI ticks.
3490
+ */
3491
+ start: number;
3492
+ /**
3493
+ * End of the loop, in MIDI ticks.
3494
+ */
3495
+ end: number;
3496
+ }
3497
+ type MIDIFormat = 0 | 1 | 2;
3498
+ interface NoteTime {
3499
+ /**
3500
+ * The MIDI key number.
3501
+ */
3502
+ midiNote: number;
3503
+ /**
3504
+ * Start of the note, in seconds.
3505
+ */
3506
+ start: number;
3507
+ /**
3508
+ * Length of the note, in seconds.
3509
+ */
3510
+ length: number;
3511
+ /**
3512
+ * The MIDI velocity of the note.
3513
+ */
3514
+ velocity: number;
3515
+ }
3516
+ /**
3517
+ * Represents a desired program change for a MIDI channel.
3518
+ */
3519
+ interface DesiredProgramChange extends MIDIPatch {
3520
+ /**
3521
+ * The channel number.
3522
+ */
3523
+ channel: number;
3524
+ }
3525
+ /**
3526
+ * Represents a desired controller change for a MIDI channel.
3527
+ */
3528
+ interface DesiredControllerChange {
3529
+ /**
3530
+ * The channel number.
3531
+ */
3532
+ channel: number;
3533
+ /**
3534
+ * The MIDI controller number.
3535
+ */
3536
+ controllerNumber: number;
3537
+ /**
3538
+ * The new controller value.
3539
+ */
3540
+ controllerValue: number;
3541
+ }
3542
+ /**
3543
+ * Represents a desired channel transpose change.
3544
+ */
3545
+ interface DesiredChannelTranspose {
3546
+ /**
3547
+ * The channel number.
3548
+ */
3549
+ channel: number;
3550
+ /**
3551
+ * The number of semitones to transpose.
3552
+ * This can use floating point numbers, which will be used to fine-tune the pitch in cents using RPN.
3553
+ */
3554
+ keyShift: number;
3555
+ }
3556
+ interface RMIDIWriteOptions {
3557
+ /**
3558
+ * The bank offset for RMIDI.
3559
+ */
3560
+ bankOffset: number;
3561
+ /**
3562
+ * The metadata of the file. Optional.
3563
+ */
3564
+ metadata: Partial<Omit<RMIDInfoData, "infoEncoding">>;
3565
+ /**
3566
+ * If the MIDI file should internally be corrected to work with the set bank offset.
3567
+ */
3568
+ correctBankOffset: boolean;
3569
+ /**
3570
+ * The optional sound bank instance used to correct bank offset.
3571
+ */
3572
+ soundBank?: BasicSoundBank;
3573
+ }
3574
+ type RMIDInfoFourCC = "INAM" | "IPRD" | "IALB" | "IART" | "IGNR" | "IPIC" | "ICOP" | "ICRD" | "ICRT" | "ICMT" | "IENG" | "ISFT" | "ISBJ" | "IENC" | "MENC" | "DBNK";
3575
+
3576
+ declare const SpessaSynthCoreUtils: {
3577
+ consoleColors: {
3578
+ warn: string;
3579
+ unrecognized: string;
3580
+ info: string;
3581
+ recognized: string;
3582
+ value: string;
3583
+ };
3584
+ SpessaSynthInfo: typeof SpessaSynthInfo;
3585
+ SpessaSynthWarn: typeof SpessaSynthWarn;
3586
+ SpessaSynthGroupCollapsed: typeof SpessaSynthGroupCollapsed;
3587
+ SpessaSynthGroup: typeof SpessaSynthGroup;
3588
+ SpessaSynthGroupEnd: typeof SpessaSynthGroupEnd;
3589
+ readBytesAsUintBigEndian: typeof readBigEndian;
3590
+ readLittleEndian: typeof readLittleEndianIndexed;
3591
+ readBytesAsString: typeof readBinaryStringIndexed;
3592
+ readVariableLengthQuantity: typeof readVariableLengthQuantity;
3593
+ inflateSync: (input: Uint8Array) => Uint8Array<ArrayBuffer>;
3594
+ };
3595
+
3596
+ declare const DEFAULT_WAV_WRITE_OPTIONS: WaveWriteOptions;
3597
+ interface WaveWriteOptions {
3598
+ /**
3599
+ * This will find the max sample point and set it to 1, and scale others with it. Recommended
3600
+ */
3601
+ normalizeAudio: boolean;
3602
+ /**
3603
+ * The loop start and end points in seconds. Undefined if no loop should be written.
3604
+ */
3605
+ loop?: MIDILoop;
3606
+ /**
3607
+ * The metadata to write into the file.
3608
+ */
3609
+ metadata: Partial<WaveMetadata>;
3610
+ }
3611
+ interface WaveMetadata {
3612
+ /**
3613
+ * The song's title.
3614
+ */
3615
+ title: string;
3616
+ /**
3617
+ * The song's artist.
3618
+ */
3619
+ artist: string;
3620
+ /**
3621
+ * The song's album.
3622
+ */
3623
+ album: string;
3624
+ /**
3625
+ * The song's genre.
3626
+ */
3627
+ genre: string;
3628
+ }
3629
+
3630
+ interface MIDIBuilderOptions {
3631
+ /**
3632
+ * The MIDI file's tick precision (how many ticks fit in a quarter note).
3633
+ */
3634
+ timeDivision: number;
3635
+ /**
3636
+ * The MIDI file's initial tempo in BPM.
3637
+ */
3638
+ initialTempo: number;
3639
+ /**
3640
+ * The MIDI file's MIDI track format.
3641
+ */
3642
+ format: MIDIFormat;
3643
+ /**
3644
+ * The MIDI file's name. Will be appended to the conductor track.
3645
+ */
3646
+ name: string;
3647
+ }
3648
+ /**
3649
+ * A class that helps to build a MIDI file from scratch.
3650
+ */
3651
+ declare class MIDIBuilder extends BasicMIDI {
3652
+ private encoder;
3653
+ /**
3654
+ * Creates a new MIDI file.
3655
+ * @param options The options for writing the file.
3656
+ */
3657
+ constructor(options?: Partial<MIDIBuilderOptions>);
3658
+ /**
3659
+ * Adds a new Set Tempo event.
3660
+ * @param ticks the tick number of the event.
3661
+ * @param tempo the tempo in beats per minute (BPM).
3662
+ */
3663
+ addSetTempo(ticks: number, tempo: number): void;
3664
+ /**
3665
+ * Adds a new MIDI track.
3666
+ * @param name the new track's name.
3667
+ * @param port the new track's port.
3668
+ */
3669
+ addNewTrack(name: string, port?: number): void;
3670
+ /**
3671
+ * Adds a new MIDI Event.
3672
+ * @param ticks the tick time of the event (absolute).
3673
+ * @param track the track number to use.
3674
+ * @param event the MIDI event number.
3675
+ * @param eventData {Uint8Array|Iterable<number>} the raw event data.
3676
+ */
3677
+ addEvent(ticks: number, track: number, event: MIDIMessageType, eventData: Uint8Array | Iterable<number>): void;
3678
+ /**
3679
+ * Adds a new Note On event.
3680
+ * @param ticks the tick time of the event.
3681
+ * @param track the track number to use.
3682
+ * @param channel the channel to use.
3683
+ * @param midiNote the midi note of the keypress.
3684
+ * @param velocity the velocity of the keypress.
3685
+ */
3686
+ addNoteOn(ticks: number, track: number, channel: number, midiNote: number, velocity: number): void;
3687
+ /**
3688
+ * Adds a new Note Off event.
3689
+ * @param ticks the tick time of the event.
3690
+ * @param track the track number to use.
3691
+ * @param channel the channel to use.
3692
+ * @param midiNote the midi note of the key release.
3693
+ * @param velocity optional and unsupported by spessasynth.
3694
+ */
3695
+ addNoteOff(ticks: number, track: number, channel: number, midiNote: number, velocity?: number): void;
3696
+ /**
3697
+ * Adds a new Program Change event.
3698
+ * @param ticks the tick time of the event.
3699
+ * @param track the track number to use.
3700
+ * @param channel the channel to use.
3701
+ * @param programNumber the MIDI program to use.
3702
+ */
3703
+ addProgramChange(ticks: number, track: number, channel: number, programNumber: number): void;
3704
+ /**
3705
+ * Adds a new Controller Change event.
3706
+ * @param ticks the tick time of the event.
3707
+ * @param track the track number to use.
3708
+ * @param channel the channel to use.
3709
+ * @param controllerNumber the MIDI CC to use.
3710
+ * @param controllerValue the new CC value.
3711
+ */
3712
+ addControllerChange(ticks: number, track: number, channel: number, controllerNumber: number, controllerValue: number): void;
3713
+ /**
3714
+ * Adds a new Pitch Wheel event.
3715
+ * @param ticks the tick time of the event.
3716
+ * @param track the track to use.
3717
+ * @param channel the channel to use.
3718
+ * @param MSB SECOND byte of the MIDI pitchWheel message.
3719
+ * @param LSB FIRST byte of the MIDI pitchWheel message.
3720
+ */
3721
+ addPitchWheel(ticks: number, track: number, channel: number, MSB: number, LSB: number): void;
3722
+ }
3723
+
3724
+ /**
3725
+ * Processes a single MIDI tick.
3726
+ * Call this every rendering quantum to process the sequencer events in real-time.
3727
+ */
3728
+ declare function processTick(this: SpessaSynthSequencer): void;
3729
+
3730
+ /**
3731
+ * Plays the MIDI file to a specific time or ticks.
3732
+ * @param time in seconds.
3733
+ * @param ticks optional MIDI ticks, when given is used instead of time.
3734
+ * @returns true if the MIDI file is not finished.
3735
+ */
3736
+ declare function setTimeToInternal(this: SpessaSynthSequencer, time: number, ticks?: number | undefined): boolean;
3737
+
3738
+ interface SequencerEventData {
3739
+ /**
3740
+ * Called when a MIDI message is sent and externalMIDIPlayback is true.
3741
+ */
3742
+ midiMessage: {
3743
+ /**
3744
+ * The binary MIDI message.
3745
+ */
3746
+ message: Iterable<number>;
3747
+ };
3748
+ /**
3749
+ * Called when the time is changed.
3750
+ * It also gets called when a song gets changed.
3751
+ */
3752
+ timeChange: {
3753
+ /**
3754
+ * The new time in seconds.
3755
+ */
3756
+ newTime: number;
3757
+ };
3758
+ /**
3759
+ * Called when the playback stops.
3760
+ */
3761
+ pause: {
3762
+ /**
3763
+ * True if the playback stopped because it finished playing the song, false if it was stopped manually.
3764
+ */
3765
+ isFinished: boolean;
3766
+ };
3767
+ /**
3768
+ * Called when the song changes.
3769
+ */
3770
+ songChange: {
3771
+ /**
3772
+ * The index of the new song in the song list.
3773
+ */
3774
+ songIndex: number;
3775
+ };
3776
+ /**
3777
+ * Called when the song list changes.
3778
+ */
3779
+ songListChange: {
3780
+ /**
3781
+ * The new song list.
3782
+ */
3783
+ newSongList: BasicMIDI[];
3784
+ };
3785
+ /**
3786
+ * Called when a MIDI Meta event is encountered.
3787
+ */
3788
+ metaEvent: {
3789
+ /**
3790
+ * The MIDI message of the meta event.
3791
+ */
3792
+ event: MIDIMessage;
3793
+ /**
3794
+ * The index of the track where the meta event was encountered.
3795
+ */
3796
+ trackIndex: number;
3797
+ };
3798
+ /**
3799
+ * Called when the loop count changes (decreases).
3800
+ */
3801
+ loopCountChange: {
3802
+ /**
3803
+ * The new loop count.
3804
+ */
3805
+ newCount: number;
3806
+ };
3807
+ }
3808
+ type SequencerEvent = {
3809
+ [K in keyof SequencerEventData]: {
3810
+ type: K;
3811
+ data: SequencerEventData[K];
3812
+ };
3813
+ }[keyof SequencerEventData];
3814
+
3815
+ declare class SpessaSynthSequencer {
3816
+ /**
3817
+ * Sequencer's song list.
3818
+ */
3819
+ songs: BasicMIDI[];
3820
+ /**
3821
+ * The shuffled song indexes.
3822
+ * This is used when shuffleMode is enabled.
3823
+ */
3824
+ shuffledSongIndexes: number[];
3825
+ /**
3826
+ * The synthesizer connected to the sequencer.
3827
+ */
3828
+ readonly synth: SpessaSynthProcessor;
3829
+ /**
3830
+ * If the MIDI messages should be sent to an event instead of the synth.
3831
+ * This is used by spessasynth_lib to pass them over to Web MIDI API.
3832
+ */
3833
+ externalMIDIPlayback: boolean;
3834
+ /**
3835
+ * The loop count of the sequencer.
3836
+ * If infinite, it will loop forever.
3837
+ * If zero, the loop is disabled.
3838
+ */
3839
+ loopCount: number;
3840
+ /**
3841
+ * Indicates if the sequencer should skip to the first note on event.
3842
+ * Defaults to true.
3843
+ */
3844
+ skipToFirstNoteOn: boolean;
3845
+ /**
3846
+ * Called when the sequencer calls an event.
3847
+ * @param event The event
3848
+ */
3849
+ onEventCall?: (event: SequencerEvent) => unknown;
3850
+ /**
3851
+ * Processes a single MIDI tick.
3852
+ * You should call this every rendering quantum to process the sequencer events in real-time.
3853
+ */
3854
+ processTick: typeof processTick;
3855
+ /**
3856
+ * The time of the first note in seconds.
3857
+ */
3858
+ protected firstNoteTime: number;
3859
+ /**
3860
+ * How long a single MIDI tick currently lasts in seconds.
3861
+ */
3862
+ protected oneTickToSeconds: number;
3863
+ /**
3864
+ * The current event index for each track.
3865
+ * This is used to track which event is currently being processed for each track.
3866
+ */
3867
+ protected eventIndexes: number[];
3868
+ /**
3869
+ * The time that has already been played in the current song.
3870
+ */
3871
+ protected playedTime: number;
3872
+ /**
3873
+ * The paused time of the sequencer.
3874
+ * If the sequencer is not paused, this is undefined.
3875
+ */
3876
+ protected pausedTime?: number;
3877
+ /**
3878
+ * Absolute time of the sequencer when it started playing.
3879
+ * It is based on the synth's current time.
3880
+ */
3881
+ protected absoluteStartTime: number;
3882
+ /**
3883
+ * Currently playing notes (for pausing and resuming)
3884
+ */
3885
+ protected playingNotes: {
3886
+ midiNote: number;
3887
+ channel: number;
3888
+ velocity: number;
3889
+ }[];
3890
+ /**
3891
+ * MIDI Port number for each of the MIDI tracks in the current sequence.
3892
+ */
3893
+ protected currentMIDIPorts: number[];
3894
+ /**
3895
+ * This is used to assign new MIDI port offsets to new ports.
3896
+ */
3897
+ protected midiPortChannelOffset: number;
3898
+ /**
3899
+ * Channel offsets for each MIDI port.
3900
+ * Stored as:
3901
+ * Record<midi port, channel offset>
3902
+ */
3903
+ protected midiPortChannelOffsets: Record<number, number>;
3904
+ protected assignMIDIPort: (trackNum: number, port: number) => void;
3905
+ protected loadNewSequence: (parsedMidi: BasicMIDI) => void;
3906
+ protected processEvent: (event: MIDIMessage, trackIndex: number) => void;
3907
+ protected setTimeTo: typeof setTimeToInternal;
3908
+ /**
3909
+ * Initializes a new Sequencer without any songs loaded.
3910
+ * @param spessasynthProcessor the synthesizer processor to use with this sequencer.
3911
+ */
3912
+ constructor(spessasynthProcessor: SpessaSynthProcessor);
3913
+ protected _midiData?: BasicMIDI;
3914
+ /**
3915
+ * The currently loaded MIDI data.
3916
+ */
3917
+ get midiData(): BasicMIDI | undefined;
3918
+ /**
3919
+ * The length of the current sequence in seconds.
3920
+ */
3921
+ get duration(): number;
3922
+ protected _songIndex: number;
3923
+ /**
3924
+ * The current song index in the song list.
3925
+ * If shuffleMode is enabled, this is the index of the shuffled song list.
3926
+ */
3927
+ get songIndex(): number;
3928
+ /**
3929
+ * The current song index in the song list.
3930
+ * If shuffleMode is enabled, this is the index of the shuffled song list.
3931
+ */
3932
+ set songIndex(value: number);
3933
+ protected _shuffleMode: boolean;
3934
+ /**
3935
+ * Controls if the sequencer should shuffle the songs in the song list.
3936
+ * If true, the sequencer will play the songs in a random order.
3937
+ */
3938
+ get shuffleMode(): boolean;
3939
+ /**
3940
+ * Controls if the sequencer should shuffle the songs in the song list.
3941
+ * If true, the sequencer will play the songs in a random order.
3942
+ */
3943
+ set shuffleMode(on: boolean);
3944
+ /**
3945
+ * Internal playback rate.
3946
+ */
3947
+ protected _playbackRate: number;
3948
+ /**
3949
+ * The sequencer's playback rate.
3950
+ * This is the rate at which the sequencer plays back the MIDI data.
3951
+ */
3952
+ get playbackRate(): number;
3953
+ /**
3954
+ * The sequencer's playback rate.
3955
+ * This is the rate at which the sequencer plays back the MIDI data.
3956
+ * @param value the playback rate to set.
3957
+ */
3958
+ set playbackRate(value: number);
3959
+ /**
3960
+ * The current time of the sequencer.
3961
+ * This is the time in seconds since the sequencer started playing.
3962
+ */
3963
+ get currentTime(): number;
3964
+ /**
3965
+ * The current time of the sequencer.
3966
+ * This is the time in seconds since the sequencer started playing.
3967
+ * @param time the time to set in seconds.
3968
+ */
3969
+ set currentTime(time: number);
3970
+ /**
3971
+ * True if paused, false if playing or stopped
3972
+ */
3973
+ get paused(): boolean;
3974
+ /**
3975
+ * Starts or resumes the playback of the sequencer.
3976
+ * If the sequencer is paused, it will resume from the paused time.
3977
+ */
3978
+ play(): void;
3979
+ /**
3980
+ * Pauses the playback.
3981
+ */
3982
+ pause(): void;
3983
+ /**
3984
+ * Loads a new song list into the sequencer.
3985
+ * @param midiBuffers the list of songs to load.
3986
+ */
3987
+ loadNewSongList(midiBuffers: BasicMIDI[]): void;
3988
+ protected callEvent<K extends keyof SequencerEventData>(type: K, data: SequencerEventData[K]): void;
3989
+ protected pauseInternal(isFinished: boolean): void;
3990
+ protected songIsFinished(): void;
3991
+ /**
3992
+ * Stops the playback
3993
+ */
3994
+ protected stop(): void;
3995
+ /**
3996
+ * @returns the index of the first to the current played time
3997
+ */
3998
+ protected findFirstEventIndex(): number;
3999
+ /**
4000
+ * Adds a new port (16 channels) to the synth.
4001
+ */
4002
+ protected addNewMIDIPort(): void;
4003
+ protected sendMIDIMessage(message: number[]): void;
4004
+ protected sendMIDIReset(): void;
4005
+ protected loadCurrentSong(): void;
4006
+ protected shuffleSongIndexes(): void;
4007
+ protected sendMIDICC(channel: number, type: number, value: number): void;
4008
+ protected sendMIDIProgramChange(channel: number, program: number): void;
4009
+ /**
4010
+ * Sets the pitch of the given channel
4011
+ * @param channel usually 0-15: the channel to change pitch
4012
+ * @param MSB SECOND byte of the MIDI pitchWheel message
4013
+ * @param LSB FIRST byte of the MIDI pitchWheel message
4014
+ */
4015
+ protected sendMIDIPitchWheel(channel: number, MSB: number, LSB: number): void;
4016
+ /**
4017
+ * Sets the time in MIDI ticks.
4018
+ * @param ticks the MIDI ticks to set the time to.
4019
+ */
4020
+ protected setTimeTicks(ticks: number): void;
4021
+ /**
4022
+ * Recalculates the absolute start time of the sequencer.
4023
+ * @param time the time in seconds to recalculate the start time for.
4024
+ */
4025
+ protected recalculateStartTime(time: number): void;
4026
+ }
4027
+
4028
+ declare const DEFAULT_MASTER_PARAMETERS: MasterParameterType;
4029
+
4030
+ /**
4031
+ * Default MIDI drum channel.
4032
+ */
4033
+ declare const DEFAULT_PERCUSSION = 9;
4034
+ declare const ALL_CHANNELS_OR_DIFFERENT_ACTION = -1;
4035
+
4036
+ declare const NON_CC_INDEX_OFFSET = 128;
4037
+ declare const CONTROLLER_TABLE_SIZE = 147;
4038
+ /**
4039
+ * An array with the default MIDI controller values. Note that these are 14-bit, not 7-bit.
4040
+ */
4041
+ declare const defaultMIDIControllerValues: Int16Array<ArrayBuffer>;
4042
+ declare const setResetValue: (i: MIDIController, v: number) => number;
4043
+ declare const PORTAMENTO_CONTROL_UNSET = 1;
4044
+ declare const CUSTOM_CONTROLLER_TABLE_SIZE: number;
4045
+ declare const customResetArray: Float32Array<ArrayBuffer>;
4046
+
4047
+ declare class SoundBankLoader {
4048
+ /**
4049
+ * Loads a sound bank from a file buffer.
4050
+ * @param buffer The binary file buffer to load.
4051
+ * @returns The loaded sound bank, a BasicSoundBank instance.
4052
+ */
4053
+ static fromArrayBuffer(buffer: ArrayBuffer): BasicSoundBank;
4054
+ private static loadDLS;
4055
+ }
4056
+
4057
+ export { ALL_CHANNELS_OR_DIFFERENT_ACTION, BasicGlobalZone, BasicInstrument, BasicInstrumentZone, BasicMIDI, BasicPreset, BasicPresetZone, BasicSample, BasicSoundBank, BasicZone, CONTROLLER_TABLE_SIZE, CUSTOM_CONTROLLER_TABLE_SIZE, type ChannelPressureCallback, type ChannelProperty, type ChannelPropertyChangeCallback, ChannelSnapshot, type ControllerChangeCallback, type CustomController, DEFAULT_MASTER_PARAMETERS, DEFAULT_PERCUSSION, DEFAULT_WAV_WRITE_OPTIONS, type DLSChunkFourCC, type DLSDestination, type DLSInfoFourCC, type DLSLoop, type DLSLoopType, DLSLoopTypes, type DLSSource, type DLSTransform, type DLSWriteOptions, type DataEntryState, type DesiredChannelTranspose, type DesiredControllerChange, type DesiredProgramChange, type DrumChangeCallback, EmptySample, type FourCC, GENERATORS_AMOUNT, Generator, type GeneratorType, type GenericBankInfoFourCC, type GenericRIFFFourCC, type GenericRange, IndexedByteArray, type InterpolationType, KeyModifier, MAX_GENERATOR, MIDIBuilder, type MIDIController, type MIDIFormat, type MIDILoop, MIDIMessage, type MIDIMessageType, type MIDIPatch, type MIDIPatchNamed, MIDIPatchTools, MIDITrack, type MTSNoteTuning, type MTSProgramTuning, type MasterParameterChangeCallback, type MasterParameterType, Modulator, type ModulatorCurveType, ModulatorSource, type ModulatorSourceEnum, type ModulatorSourceIndex, type ModulatorTransformType, type MuteChannelCallback, NON_CC_INDEX_OFFSET, type NoteOffCallback, type NoteOnCallback, type NoteTime, PORTAMENTO_CONTROL_UNSET, type PitchWheelCallback, type PolyPressureCallback, type PresetList, type PresetListEntry, type ProgramChangeCallback, type ProgressFunction, type RMIDIWriteOptions, type RMIDInfoData, type RMIDInfoFourCC, type SF2ChunkFourCC, type SF2InfoFourCC, type SF2VersionTag, type SampleEncodingFunction, type SampleLoopingMode, type SampleType, type SequencerEvent, type SequencerEventData, type SoundBankErrorCallback, type SoundBankInfoData, type SoundBankInfoFourCC, SoundBankLoader, type SoundBankManagerListEntry, type SoundFont2WriteOptions, SpessaSynthCoreUtils, SpessaSynthLogging, SpessaSynthProcessor, SpessaSynthSequencer, type StopAllCallback, type SynthDisplayCallback, type SynthDisplayType, type SynthMethodOptions, type SynthProcessorEvent, type SynthProcessorEventData, type SynthProcessorOptions, type SynthSystem, SynthesizerSnapshot, type TempoChange, type VoiceList, type VoiceSynthesisData, type WaveMetadata, type WaveWriteOptions, audioToWav, customControllers, customResetArray, dataEntryStates, defaultMIDIControllerValues, dlsDestinations, dlsSources, generatorLimits, generatorTypes, interpolationTypes, midiControllers, midiMessageTypes, modulatorCurveTypes, modulatorSources, modulatorTransformTypes, sampleTypes, setResetValue, synthDisplayTypes };