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
@@ -1,115 +0,0 @@
1
- import { BasicGlobalZone } from "./basic_global_zone.js";
2
- import { BasicInstrumentZone } from "./basic_instrument_zone.js";
3
- import { SpessaSynthWarn } from "../../utils/loggin.js";
4
-
5
- export class BasicInstrument
6
- {
7
- /**
8
- * The instrument's name
9
- * @type {string}
10
- */
11
- instrumentName = "";
12
-
13
- /**
14
- * The instrument's zones
15
- * @type {BasicInstrumentZone[]}
16
- * @readonly
17
- */
18
- instrumentZones = [];
19
-
20
- /**
21
- * Instrument's global zone
22
- * @type {BasicGlobalZone}
23
- */
24
- globalZone = new BasicGlobalZone();
25
-
26
- /**
27
- * Instrument's linked presets (the presets that use it)
28
- * note that duplicates are allowed since one preset can use the same instrument multople times
29
- * @type {BasicPreset[]}
30
- */
31
- linkedPresets = [];
32
-
33
- /**
34
- * @returns {number}
35
- */
36
- get useCount()
37
- {
38
- return this.linkedPresets.length;
39
- }
40
-
41
- /**
42
- * @returns {BasicInstrumentZone}
43
- */
44
- createZone()
45
- {
46
- const zone = new BasicInstrumentZone(this);
47
- this.instrumentZones.push(zone);
48
- return zone;
49
- }
50
-
51
- /**
52
- * @param preset {BasicPreset}
53
- */
54
- linkTo(preset)
55
- {
56
- this.linkedPresets.push(preset);
57
- this.instrumentZones.forEach(z => z.useCount++);
58
- }
59
-
60
- /**
61
- * @param preset {BasicPreset}
62
- */
63
- unlinkFrom(preset)
64
- {
65
- const index = this.linkedPresets.indexOf(preset);
66
- if (index < 0)
67
- {
68
- SpessaSynthWarn(`Cannot unlink ${preset.presetName} from ${this.instrumentName}: not linked.`);
69
- return;
70
- }
71
- this.linkedPresets.splice(index, 1);
72
- this.instrumentZones.forEach(z => z.useCount--);
73
- }
74
-
75
- deleteUnusedZones()
76
- {
77
- this.instrumentZones = this.instrumentZones.filter(z =>
78
- {
79
- const stays = z.useCount > 0;
80
- if (!stays)
81
- {
82
- z.deleteZone();
83
- }
84
- return stays;
85
- });
86
- }
87
-
88
- // unlinks everything from this instrument
89
- deleteInstrument()
90
- {
91
- if (this.useCount > 0)
92
- {
93
- throw new Error(`Cannot delete an instrument that is used by: ${this.linkedPresets.map(p => p.presetName)}.`);
94
- }
95
- this.instrumentZones.forEach(z => z.deleteZone());
96
- }
97
-
98
- /**
99
- * @param index {number}
100
- * @param force {boolean} ignore use count
101
- * @returns {boolean} if deleted
102
- */
103
- deleteZone(index, force = false)
104
- {
105
- const zone = this.instrumentZones[index];
106
- zone.useCount -= 1;
107
- if (zone.useCount < 1 || force)
108
- {
109
- zone.deleteZone();
110
- this.instrumentZones.splice(index, 1);
111
- return true;
112
- }
113
- return false;
114
- }
115
- }
@@ -1,45 +0,0 @@
1
- import { BasicZone } from "./basic_zone.js";
2
-
3
- export class BasicInstrumentZone extends BasicZone
4
- {
5
- /**
6
- * The parent instrument.
7
- * @type {BasicInstrument}
8
- */
9
- parentInstrument;
10
-
11
- /**
12
- * Zone's sample.
13
- * @type {BasicSample}
14
- */
15
- sample;
16
- /**
17
- * For tracking on the individual zone level, since multiple presets can refer to the same instrument.
18
- * @type {number}
19
- */
20
- useCount;
21
-
22
- /**
23
- * @param instrument {BasicInstrument}
24
- */
25
- constructor(instrument)
26
- {
27
- super();
28
- this.parentInstrument = instrument;
29
- this.useCount = instrument.useCount;
30
- }
31
-
32
- /**
33
- * @param sample {BasicSample}
34
- */
35
- setSample(sample)
36
- {
37
- this.sample = sample;
38
- sample.linkTo(this.parentInstrument);
39
- }
40
-
41
- deleteZone()
42
- {
43
- this.sample.unlinkFrom(this.parentInstrument);
44
- }
45
- }
@@ -1,313 +0,0 @@
1
- /**
2
- * @typedef {{
3
- * instrumentGenerators: Generator[],
4
- * presetGenerators: Generator[],
5
- * modulators: Modulator[],
6
- * sample: BasicSample,
7
- * }} SampleAndGenerators
8
- */
9
- import { Modulator } from "./modulator.js";
10
- import { isXGDrums } from "../../utils/xg_hacks.js";
11
-
12
- import { BasicGlobalZone } from "./basic_global_zone.js";
13
- import { BasicPresetZone } from "./basic_preset_zone.js";
14
-
15
- export class BasicPreset
16
- {
17
- /**
18
- * The parent soundbank instance
19
- * Currently used for determining default modulators and XG status
20
- * @type {BasicSoundBank}
21
- */
22
- parentSoundBank;
23
-
24
- /**
25
- * The preset's name
26
- * @type {string}
27
- */
28
- presetName = "";
29
-
30
- /**
31
- * The preset's MIDI program number
32
- * @type {number}
33
- */
34
- program = 0;
35
-
36
- /**
37
- * The preset's MIDI bank number
38
- * @type {number}
39
- */
40
- bank = 0;
41
-
42
- /**
43
- * The preset's zones
44
- * @type {BasicPresetZone[]}
45
- */
46
- presetZones = [];
47
-
48
- /**
49
- * Preset's global zone
50
- * @type {BasicGlobalZone}
51
- */
52
- globalZone = new BasicGlobalZone();
53
-
54
- /**
55
- * unused metadata
56
- * @type {number}
57
- */
58
- library = 0;
59
- /**
60
- * unused metadata
61
- * @type {number}
62
- */
63
- genre = 0;
64
- /**
65
- * unused metadata
66
- * @type {number}
67
- */
68
- morphology = 0;
69
-
70
- /**
71
- * Creates a new preset representation
72
- * @param parentSoundBank {BasicSoundBank}
73
- */
74
- constructor(parentSoundBank)
75
- {
76
- this.parentSoundBank = parentSoundBank;
77
- }
78
-
79
- /**
80
- * @param allowXG {boolean}
81
- * @param allowSFX {boolean}
82
- * @returns {boolean}
83
- */
84
- isDrumPreset(allowXG, allowSFX = false)
85
- {
86
- const xg = allowXG && this.parentSoundBank.isXGBank;
87
- // sfx is not cool
88
- return this.bank === 128 || (
89
- xg &&
90
- (isXGDrums(this.bank) && (this.bank !== 126 || allowSFX))
91
- );
92
- }
93
-
94
- // unlinks everything from this preset
95
- deletePreset()
96
- {
97
- this.presetZones.forEach(z => z.deleteZone());
98
- }
99
-
100
- /**
101
- * @param index {number}
102
- */
103
- deleteZone(index)
104
- {
105
- this.presetZones[index].deleteZone();
106
- this.presetZones.splice(index, 1);
107
- }
108
-
109
- /**
110
- * @returns {BasicPresetZone}
111
- */
112
- createZone()
113
- {
114
- const z = new BasicPresetZone(this);
115
- this.presetZones.push(z);
116
- return z;
117
- }
118
-
119
- // noinspection JSUnusedGlobalSymbols
120
- /**
121
- * Preloads all samples (async)
122
- */
123
- preload(keyMin, keyMax)
124
- {
125
- for (let key = keyMin; key < keyMax + 1; key++)
126
- {
127
- for (let velocity = 0; velocity < 128; velocity++)
128
- {
129
- this.getSamplesAndGenerators(key, velocity).forEach(samandgen =>
130
- {
131
- samandgen.sample.getAudioData();
132
- });
133
- }
134
- }
135
- }
136
-
137
- /**
138
- * Returns samples and generators for given note
139
- * @param midiNote {number}
140
- * @param velocity {number}
141
- * @returns {SampleAndGenerators[]}
142
- */
143
- getSamplesAndGenerators(midiNote, velocity)
144
- {
145
-
146
- if (this.presetZones.length < 1)
147
- {
148
- return [];
149
- }
150
-
151
- /**
152
- * @param range {SoundFontRange}
153
- * @param number {number}
154
- * @returns {boolean}
155
- */
156
- function isInRange(range, number)
157
- {
158
- return number >= range.min && number <= range.max;
159
- }
160
-
161
- /**
162
- * @param main {Generator[]}
163
- * @param adder {Generator[]}
164
- */
165
- function addUnique(main, adder)
166
- {
167
- main.push(...adder.filter(g => !main.find(mg => mg.generatorType === g.generatorType)));
168
- }
169
-
170
- /**
171
- * @param main {Modulator[]}
172
- * @param adder {Modulator[]}
173
- */
174
- function addUniqueMods(main, adder)
175
- {
176
- main.push(...adder.filter(m => !main.find(mm => Modulator.isIdentical(m, mm))));
177
- }
178
-
179
- /**
180
- * @type {SampleAndGenerators[]}
181
- */
182
- let parsedGeneratorsAndSamples = [];
183
-
184
- /**
185
- * global zone is always first, so it or nothing
186
- * @type {Generator[]}
187
- */
188
- let globalPresetGenerators = [...this.globalZone.generators];
189
-
190
- /**
191
- * @type {Modulator[]}
192
- */
193
- let globalPresetModulators = [...this.globalZone.modulators];
194
- const globalKeyRange = this.globalZone.keyRange;
195
- const globalVelRange = this.globalZone.velRange;
196
-
197
- // find the preset zones in range
198
- let presetZonesInRange = this.presetZones.filter(currentZone =>
199
- isInRange(
200
- currentZone.hasKeyRange ? currentZone.keyRange : globalKeyRange,
201
- midiNote
202
- )
203
- &&
204
- isInRange(
205
- currentZone.hasVelRange ? currentZone.velRange : globalVelRange,
206
- velocity
207
- )
208
- );
209
-
210
- presetZonesInRange.forEach(presetZone =>
211
- {
212
- const instrument = presetZone.instrument;
213
- // the global zone is already taken into account earlier
214
- if (instrument.instrumentZones.length < 1)
215
- {
216
- return;
217
- }
218
- let presetGenerators = presetZone.generators;
219
- let presetModulators = presetZone.modulators;
220
- /**
221
- * global zone is always first, so it or nothing
222
- * @type {Generator[]}
223
- */
224
- let globalInstrumentGenerators = [...instrument.globalZone.generators];
225
- let globalInstrumentModulators = [...instrument.globalZone.modulators];
226
- const globalKeyRange = instrument.globalZone.keyRange;
227
- const globalVelRange = instrument.globalZone.velRange;
228
-
229
-
230
- let instrumentZonesInRange = instrument.instrumentZones
231
- .filter(currentZone =>
232
-
233
- isInRange(
234
- currentZone.hasKeyRange ? currentZone.keyRange : globalKeyRange,
235
- midiNote
236
- )
237
- &&
238
- isInRange(
239
- currentZone.hasVelRange ? currentZone.velRange : globalVelRange,
240
- velocity
241
- )
242
- );
243
-
244
- instrumentZonesInRange.forEach(instrumentZone =>
245
- {
246
- let instrumentGenerators = [...instrumentZone.generators];
247
- let instrumentModulators = [...instrumentZone.modulators];
248
-
249
- addUnique(
250
- presetGenerators,
251
- globalPresetGenerators
252
- );
253
- // add the unique global preset generators (local replace global(
254
-
255
-
256
- // add the unique global instrument generators (local replace global)
257
- addUnique(
258
- instrumentGenerators,
259
- globalInstrumentGenerators
260
- );
261
-
262
- addUniqueMods(
263
- presetModulators,
264
- globalPresetModulators
265
- );
266
- addUniqueMods(
267
- instrumentModulators,
268
- globalInstrumentModulators
269
- );
270
-
271
- // default mods
272
- addUniqueMods(
273
- instrumentModulators,
274
- this.parentSoundBank.defaultModulators
275
- );
276
-
277
- /**
278
- * sum preset modulators to instruments (amount) sf spec page 54
279
- * @type {Modulator[]}
280
- */
281
- const finalModulatorList = [...instrumentModulators];
282
- for (let i = 0; i < presetModulators.length; i++)
283
- {
284
- let mod = presetModulators[i];
285
- const identicalInstrumentModulator = finalModulatorList.findIndex(
286
- m => Modulator.isIdentical(mod, m));
287
- if (identicalInstrumentModulator !== -1)
288
- {
289
- // sum the amounts
290
- // this makes a new modulator
291
- // because otherwise it would overwrite the one in the soundfont!
292
- finalModulatorList[identicalInstrumentModulator] = finalModulatorList[identicalInstrumentModulator].sumTransform(
293
- mod);
294
- }
295
- else
296
- {
297
- finalModulatorList.push(mod);
298
- }
299
- }
300
-
301
-
302
- // combine both generators and add to the final result
303
- parsedGeneratorsAndSamples.push({
304
- instrumentGenerators: instrumentGenerators,
305
- presetGenerators: presetGenerators,
306
- modulators: finalModulatorList,
307
- sample: instrumentZone.sample
308
- });
309
- });
310
- });
311
- return parsedGeneratorsAndSamples;
312
- }
313
- }
@@ -1,39 +0,0 @@
1
- import { BasicZone } from "./basic_zone.js";
2
-
3
- export class BasicPresetZone extends BasicZone
4
- {
5
- /**
6
- * The parent preset.
7
- * @type {BasicPreset}
8
- */
9
- parentPreset;
10
-
11
- /**
12
- * Zone's instrument.
13
- * @type {BasicInstrument}
14
- */
15
- instrument;
16
-
17
- /**
18
- * @param preset {BasicPreset}
19
- */
20
- constructor(preset)
21
- {
22
- super();
23
- this.parentPreset = preset;
24
- }
25
-
26
- deleteZone()
27
- {
28
- this.instrument.unlinkFrom(this.parentPreset);
29
- }
30
-
31
- /**
32
- * @param instrument {BasicInstrument}
33
- */
34
- setInstrument(instrument)
35
- {
36
- this.instrument = instrument;
37
- this.instrument.linkTo(this.parentPreset);
38
- }
39
- }