spessasynth_core 3.27.8 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -51
- package/dist/index.d.ts +4057 -0
- package/dist/index.js +17178 -0
- package/dist/index.js.map +1 -0
- package/package.json +24 -6
- package/index.js +0 -132
- package/src/externals/README.md +0 -6
- package/src/externals/fflate/LICENSE +0 -21
- package/src/externals/fflate/fflate.min.js +0 -1
- package/src/externals/stbvorbis_sync/@types/stbvorbis_sync.d.ts +0 -12
- package/src/externals/stbvorbis_sync/LICENSE +0 -202
- package/src/externals/stbvorbis_sync/NOTICE +0 -6
- package/src/externals/stbvorbis_sync/stbvorbis_sync.min.js +0 -1
- package/src/midi/README.md +0 -32
- package/src/midi/basic_midi.js +0 -587
- package/src/midi/midi_builder.js +0 -203
- package/src/midi/midi_loader.js +0 -321
- package/src/midi/midi_message.js +0 -254
- package/src/midi/midi_sequence.js +0 -230
- package/src/midi/midi_tools/get_note_times.js +0 -154
- package/src/midi/midi_tools/midi_editor.js +0 -611
- package/src/midi/midi_tools/midi_writer.js +0 -105
- package/src/midi/midi_tools/rmidi_writer.js +0 -566
- package/src/midi/midi_tools/used_keys_loaded.js +0 -256
- package/src/midi/xmf_loader.js +0 -454
- package/src/sequencer/README.md +0 -9
- package/src/sequencer/events.js +0 -81
- package/src/sequencer/play.js +0 -362
- package/src/sequencer/process_event.js +0 -165
- package/src/sequencer/process_tick.js +0 -104
- package/src/sequencer/sequencer_engine.js +0 -372
- package/src/sequencer/song_control.js +0 -196
- package/src/soundfont/README.md +0 -11
- package/src/soundfont/basic_soundfont/basic_global_zone.js +0 -6
- package/src/soundfont/basic_soundfont/basic_instrument.js +0 -115
- package/src/soundfont/basic_soundfont/basic_instrument_zone.js +0 -45
- package/src/soundfont/basic_soundfont/basic_preset.js +0 -313
- package/src/soundfont/basic_soundfont/basic_preset_zone.js +0 -39
- package/src/soundfont/basic_soundfont/basic_sample.js +0 -477
- package/src/soundfont/basic_soundfont/basic_soundbank.js +0 -740
- package/src/soundfont/basic_soundfont/basic_zone.js +0 -145
- package/src/soundfont/basic_soundfont/generator.js +0 -76
- package/src/soundfont/basic_soundfont/generator_types.js +0 -151
- package/src/soundfont/basic_soundfont/modulator.js +0 -581
- package/src/soundfont/basic_soundfont/riff_chunk.js +0 -195
- package/src/soundfont/basic_soundfont/write_dls/art2.js +0 -174
- package/src/soundfont/basic_soundfont/write_dls/articulator.js +0 -49
- package/src/soundfont/basic_soundfont/write_dls/combine_zones.js +0 -374
- package/src/soundfont/basic_soundfont/write_dls/ins.js +0 -85
- package/src/soundfont/basic_soundfont/write_dls/lins.js +0 -15
- package/src/soundfont/basic_soundfont/write_dls/modulator_converter.js +0 -330
- package/src/soundfont/basic_soundfont/write_dls/rgn2.js +0 -120
- package/src/soundfont/basic_soundfont/write_dls/wave.js +0 -71
- package/src/soundfont/basic_soundfont/write_dls/write_dls.js +0 -124
- package/src/soundfont/basic_soundfont/write_dls/wsmp.js +0 -78
- package/src/soundfont/basic_soundfont/write_dls/wvpl.js +0 -35
- package/src/soundfont/basic_soundfont/write_sf2/ibag.js +0 -60
- package/src/soundfont/basic_soundfont/write_sf2/igen.js +0 -91
- package/src/soundfont/basic_soundfont/write_sf2/imod.js +0 -62
- package/src/soundfont/basic_soundfont/write_sf2/inst.js +0 -42
- package/src/soundfont/basic_soundfont/write_sf2/pbag.js +0 -57
- package/src/soundfont/basic_soundfont/write_sf2/pgen.js +0 -92
- package/src/soundfont/basic_soundfont/write_sf2/phdr.js +0 -61
- package/src/soundfont/basic_soundfont/write_sf2/pmod.js +0 -62
- package/src/soundfont/basic_soundfont/write_sf2/sdta.js +0 -131
- package/src/soundfont/basic_soundfont/write_sf2/shdr.js +0 -77
- package/src/soundfont/basic_soundfont/write_sf2/write.js +0 -287
- package/src/soundfont/dls/articulator_converter.js +0 -402
- package/src/soundfont/dls/dls_destinations.js +0 -38
- package/src/soundfont/dls/dls_instrument.js +0 -20
- package/src/soundfont/dls/dls_preset.js +0 -43
- package/src/soundfont/dls/dls_sample.js +0 -238
- package/src/soundfont/dls/dls_soundfont.js +0 -183
- package/src/soundfont/dls/dls_sources.js +0 -63
- package/src/soundfont/dls/dls_zone.js +0 -89
- package/src/soundfont/dls/read_articulation.js +0 -300
- package/src/soundfont/dls/read_instrument.js +0 -118
- package/src/soundfont/dls/read_instrument_list.js +0 -17
- package/src/soundfont/dls/read_lart.js +0 -35
- package/src/soundfont/dls/read_region.js +0 -157
- package/src/soundfont/dls/read_samples.js +0 -154
- package/src/soundfont/load_soundfont.js +0 -21
- package/src/soundfont/read_sf2/generators.js +0 -43
- package/src/soundfont/read_sf2/instrument_zones.js +0 -75
- package/src/soundfont/read_sf2/instruments.js +0 -71
- package/src/soundfont/read_sf2/modulators.js +0 -25
- package/src/soundfont/read_sf2/preset_zones.js +0 -79
- package/src/soundfont/read_sf2/presets.js +0 -80
- package/src/soundfont/read_sf2/samples.js +0 -317
- package/src/soundfont/read_sf2/soundfont.js +0 -452
- package/src/soundfont/read_sf2/zones.js +0 -28
- package/src/synthetizer/README.md +0 -7
- package/src/synthetizer/audio_engine/README.md +0 -9
- package/src/synthetizer/audio_engine/engine_components/compute_modulator.js +0 -289
- package/src/synthetizer/audio_engine/engine_components/controller_tables.js +0 -90
- package/src/synthetizer/audio_engine/engine_components/dynamic_modulator_system.js +0 -95
- package/src/synthetizer/audio_engine/engine_components/enums.js +0 -18
- package/src/synthetizer/audio_engine/engine_components/key_modifier_manager.js +0 -151
- package/src/synthetizer/audio_engine/engine_components/lfo.js +0 -26
- package/src/synthetizer/audio_engine/engine_components/lowpass_filter.js +0 -282
- package/src/synthetizer/audio_engine/engine_components/midi_audio_channel.js +0 -551
- package/src/synthetizer/audio_engine/engine_components/modulation_envelope.js +0 -181
- package/src/synthetizer/audio_engine/engine_components/modulator_curves.js +0 -89
- package/src/synthetizer/audio_engine/engine_components/soundfont_manager.js +0 -265
- package/src/synthetizer/audio_engine/engine_components/stereo_panner.js +0 -124
- package/src/synthetizer/audio_engine/engine_components/unit_converter.js +0 -73
- package/src/synthetizer/audio_engine/engine_components/voice.js +0 -525
- package/src/synthetizer/audio_engine/engine_components/volume_envelope.js +0 -402
- package/src/synthetizer/audio_engine/engine_components/wavetable_oscillator.js +0 -274
- package/src/synthetizer/audio_engine/engine_methods/controller_control/controller_change.js +0 -159
- package/src/synthetizer/audio_engine/engine_methods/controller_control/master_parameters.js +0 -53
- package/src/synthetizer/audio_engine/engine_methods/controller_control/reset_controllers.js +0 -254
- package/src/synthetizer/audio_engine/engine_methods/create_midi_channel.js +0 -20
- package/src/synthetizer/audio_engine/engine_methods/data_entry/awe32.js +0 -198
- package/src/synthetizer/audio_engine/engine_methods/data_entry/data_entry_coarse.js +0 -281
- package/src/synthetizer/audio_engine/engine_methods/data_entry/data_entry_fine.js +0 -109
- package/src/synthetizer/audio_engine/engine_methods/mute_channel.js +0 -17
- package/src/synthetizer/audio_engine/engine_methods/note_on.js +0 -220
- package/src/synthetizer/audio_engine/engine_methods/portamento_time.js +0 -92
- package/src/synthetizer/audio_engine/engine_methods/program_change.js +0 -35
- package/src/synthetizer/audio_engine/engine_methods/render_voice.js +0 -214
- package/src/synthetizer/audio_engine/engine_methods/soundfont_management/embedded_sound_bank.js +0 -42
- package/src/synthetizer/audio_engine/engine_methods/soundfont_management/get_preset.js +0 -0
- package/src/synthetizer/audio_engine/engine_methods/soundfont_management/update_preset_list.js +0 -19
- package/src/synthetizer/audio_engine/engine_methods/stopping_notes/kill_note.js +0 -23
- package/src/synthetizer/audio_engine/engine_methods/stopping_notes/note_off.js +0 -56
- package/src/synthetizer/audio_engine/engine_methods/stopping_notes/stop_all_channels.js +0 -16
- package/src/synthetizer/audio_engine/engine_methods/stopping_notes/stop_all_notes.js +0 -30
- package/src/synthetizer/audio_engine/engine_methods/stopping_notes/voice_killing.js +0 -63
- package/src/synthetizer/audio_engine/engine_methods/system_exclusive.js +0 -1058
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/channel_pressure.js +0 -23
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/pitch_wheel.js +0 -31
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/poly_pressure.js +0 -29
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/set_master_tuning.js +0 -15
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/set_modulation_depth.js +0 -26
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/set_octave_tuning.js +0 -19
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/set_tuning.js +0 -27
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/transpose_all_channels.js +0 -15
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/transpose_channel.js +0 -34
- package/src/synthetizer/audio_engine/main_processor.js +0 -817
- package/src/synthetizer/audio_engine/snapshot/apply_synthesizer_snapshot.js +0 -16
- package/src/synthetizer/audio_engine/snapshot/channel_snapshot.js +0 -175
- package/src/synthetizer/audio_engine/snapshot/synthesizer_snapshot.js +0 -116
- package/src/synthetizer/audio_engine/synth_processor_options.js +0 -18
- package/src/synthetizer/synth_constants.js +0 -26
- package/src/utils/README.md +0 -8
- package/src/utils/buffer_to_wav.js +0 -197
- package/src/utils/byte_functions/big_endian.js +0 -32
- package/src/utils/byte_functions/little_endian.js +0 -77
- package/src/utils/byte_functions/string.js +0 -92
- package/src/utils/byte_functions/variable_length_quantity.js +0 -42
- package/src/utils/fill_with_defaults.js +0 -21
- package/src/utils/indexed_array.js +0 -34
- package/src/utils/loggin.js +0 -71
- package/src/utils/other.js +0 -92
- package/src/utils/sysex_detector.js +0 -58
- package/src/utils/xg_hacks.js +0 -193
|
@@ -1,581 +0,0 @@
|
|
|
1
|
-
import { midiControllers } from "../../midi/midi_message.js";
|
|
2
|
-
import { generatorTypes, MAX_GENERATOR } from "./generator_types.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* modulators.js
|
|
6
|
-
* purpose: parses soundfont modulators and the source enums, also includes the default modulators list
|
|
7
|
-
**/
|
|
8
|
-
|
|
9
|
-
export const MOD_BYTE_SIZE = 10;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @enum {number}
|
|
13
|
-
*/
|
|
14
|
-
export const modulatorSources = {
|
|
15
|
-
noController: 0,
|
|
16
|
-
noteOnVelocity: 2,
|
|
17
|
-
noteOnKeyNum: 3,
|
|
18
|
-
polyPressure: 10,
|
|
19
|
-
channelPressure: 13,
|
|
20
|
-
pitchWheel: 14,
|
|
21
|
-
pitchWheelRange: 16,
|
|
22
|
-
link: 127
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* @enum {number}
|
|
29
|
-
*/
|
|
30
|
-
export const modulatorCurveTypes = {
|
|
31
|
-
linear: 0,
|
|
32
|
-
concave: 1,
|
|
33
|
-
convex: 2,
|
|
34
|
-
switch: 3
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export function getModSourceEnum(curveType, polarity, direction, isCC, index)
|
|
39
|
-
{
|
|
40
|
-
return (curveType << 10) | (polarity << 9) | (direction << 8) | (isCC << 7) | index;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const defaultResonantModSource = getModSourceEnum(
|
|
44
|
-
modulatorCurveTypes.linear,
|
|
45
|
-
1,
|
|
46
|
-
0,
|
|
47
|
-
1,
|
|
48
|
-
midiControllers.filterResonance
|
|
49
|
-
); // linear forwards bipolar cc 74
|
|
50
|
-
|
|
51
|
-
export class Modulator
|
|
52
|
-
{
|
|
53
|
-
/**
|
|
54
|
-
* The current computed value of this modulator. Only used in the synthesis engine for local voices
|
|
55
|
-
* @type {number}
|
|
56
|
-
*/
|
|
57
|
-
currentValue = 0;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* The generator destination of this modulator
|
|
61
|
-
* @type {generatorTypes}
|
|
62
|
-
*/
|
|
63
|
-
modulatorDestination;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* The transform amount for this modulator
|
|
67
|
-
* @type {number}
|
|
68
|
-
*/
|
|
69
|
-
transformAmount;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* The transform type for this modulator
|
|
73
|
-
* @type {0|2}
|
|
74
|
-
*/
|
|
75
|
-
transformType;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Indicates if the given modulator is chorus or reverb effects modulator.
|
|
79
|
-
* This is done to simulate BASSMIDI effects behavior:
|
|
80
|
-
* - defaults to 1000 transform amount rather than 200
|
|
81
|
-
* - values can be changed, but anything above 200 is 1000
|
|
82
|
-
* (except for values above 1000, they are copied directly)
|
|
83
|
-
* - all values below are multiplied by 5 (200 * 5 = 1000)
|
|
84
|
-
* - still can be disabled if the soundfont has its own modulator curve
|
|
85
|
-
* - this fixes the very low amount of reverb by default and doesn't break soundfonts
|
|
86
|
-
* @type {boolean}
|
|
87
|
-
* @readonly
|
|
88
|
-
*/
|
|
89
|
-
isEffectModulator = false;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* The default resonant modulator does not affect the filter gain.
|
|
93
|
-
* Neither XG nor GS responded to cc #74 in that way.
|
|
94
|
-
* @type {boolean}
|
|
95
|
-
* @readonly
|
|
96
|
-
*/
|
|
97
|
-
isDefaultResonantModulator = false;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* 1 if the source is bipolar (min is -1, max is 1)
|
|
101
|
-
* otherwise min is 0 and max is 1
|
|
102
|
-
* @type {0|1}
|
|
103
|
-
*/
|
|
104
|
-
sourcePolarity;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* 1 if the source is negative (from 1 to 0)
|
|
108
|
-
* @type {0|1}
|
|
109
|
-
*/
|
|
110
|
-
sourceDirection;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* 1 if the source uses a MIDI CC
|
|
114
|
-
* @type {0|1}
|
|
115
|
-
*/
|
|
116
|
-
sourceUsesCC;
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* source index/CC number
|
|
120
|
-
* @type {modulatorSources|midiControllers}
|
|
121
|
-
*/
|
|
122
|
-
sourceIndex;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* source curve type
|
|
126
|
-
* @type {modulatorCurveTypes}
|
|
127
|
-
*/
|
|
128
|
-
sourceCurveType;
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* 1 if the source is bipolar (min is -1, max is 1)
|
|
132
|
-
* otherwise min is 0 and max is 1
|
|
133
|
-
* @type {0|1}
|
|
134
|
-
*/
|
|
135
|
-
secSrcPolarity;
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* 1 if the source is negative (from 1 to 0)
|
|
139
|
-
* @type {0|1}
|
|
140
|
-
*/
|
|
141
|
-
secSrcDirection;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* 1 if the source uses a MIDI CC
|
|
145
|
-
* @type {0|1}
|
|
146
|
-
*/
|
|
147
|
-
secSrcUsesCC;
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* source index/CC number
|
|
151
|
-
* @type {modulatorSources|midiControllers}
|
|
152
|
-
*/
|
|
153
|
-
secSrcIndex;
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* source curve type
|
|
157
|
-
* @type {modulatorCurveTypes}
|
|
158
|
-
*/
|
|
159
|
-
secSrcCurveType;
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Creates a new SF2 Modulator
|
|
163
|
-
* @param sourceIndex {modulatorSources|midiControllers}
|
|
164
|
-
* @param sourceCurveType {modulatorCurveTypes}
|
|
165
|
-
* @param sourceUsesCC {0|1}
|
|
166
|
-
* @param sourcePolarity {0|1}
|
|
167
|
-
* @param sourceDirection {0|1}
|
|
168
|
-
* @param secSrcIndex {modulatorSources|midiControllers}
|
|
169
|
-
* @param secSrcCurveType {modulatorCurveTypes}
|
|
170
|
-
* @param secSrcUsesCC {0|1}
|
|
171
|
-
* @param secSrcPolarity {0|1}
|
|
172
|
-
* @param secSrcDirection {0|1}
|
|
173
|
-
* @param destination {generatorTypes}
|
|
174
|
-
* @param amount {number}
|
|
175
|
-
* @param transformType {0|2}
|
|
176
|
-
* @param isEffectModulator {boolean}
|
|
177
|
-
* @param isDefaultResonantModulator {boolean}
|
|
178
|
-
*/
|
|
179
|
-
constructor(sourceIndex,
|
|
180
|
-
sourceCurveType,
|
|
181
|
-
sourceUsesCC,
|
|
182
|
-
sourcePolarity,
|
|
183
|
-
sourceDirection,
|
|
184
|
-
secSrcIndex,
|
|
185
|
-
secSrcCurveType,
|
|
186
|
-
secSrcUsesCC,
|
|
187
|
-
secSrcPolarity,
|
|
188
|
-
secSrcDirection,
|
|
189
|
-
destination,
|
|
190
|
-
amount,
|
|
191
|
-
transformType,
|
|
192
|
-
isEffectModulator = false,
|
|
193
|
-
isDefaultResonantModulator = false)
|
|
194
|
-
{
|
|
195
|
-
this.sourcePolarity = sourcePolarity;
|
|
196
|
-
this.sourceDirection = sourceDirection;
|
|
197
|
-
this.sourceUsesCC = sourceUsesCC;
|
|
198
|
-
this.sourceIndex = sourceIndex;
|
|
199
|
-
this.sourceCurveType = sourceCurveType;
|
|
200
|
-
|
|
201
|
-
this.secSrcPolarity = secSrcPolarity;
|
|
202
|
-
this.secSrcDirection = secSrcDirection;
|
|
203
|
-
this.secSrcUsesCC = secSrcUsesCC;
|
|
204
|
-
this.secSrcIndex = secSrcIndex;
|
|
205
|
-
this.secSrcCurveType = secSrcCurveType;
|
|
206
|
-
|
|
207
|
-
this.modulatorDestination = destination;
|
|
208
|
-
this.transformAmount = amount;
|
|
209
|
-
this.transformType = transformType;
|
|
210
|
-
this.isEffectModulator = isEffectModulator;
|
|
211
|
-
this.isDefaultResonantModulator = isDefaultResonantModulator;
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (this.modulatorDestination > MAX_GENERATOR)
|
|
215
|
-
{
|
|
216
|
-
this.modulatorDestination = generatorTypes.INVALID; // flag as invalid (for linked ones)
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* @param modulator {Modulator}
|
|
223
|
-
* @returns {Modulator}
|
|
224
|
-
*/
|
|
225
|
-
static copy(modulator)
|
|
226
|
-
{
|
|
227
|
-
return new Modulator(
|
|
228
|
-
modulator.sourceIndex,
|
|
229
|
-
modulator.sourceCurveType,
|
|
230
|
-
modulator.sourceUsesCC,
|
|
231
|
-
modulator.sourcePolarity,
|
|
232
|
-
modulator.sourceDirection,
|
|
233
|
-
modulator.secSrcIndex,
|
|
234
|
-
modulator.secSrcCurveType,
|
|
235
|
-
modulator.secSrcUsesCC,
|
|
236
|
-
modulator.secSrcPolarity,
|
|
237
|
-
modulator.secSrcDirection,
|
|
238
|
-
modulator.modulatorDestination,
|
|
239
|
-
modulator.transformAmount,
|
|
240
|
-
modulator.transformType,
|
|
241
|
-
modulator.isEffectModulator,
|
|
242
|
-
modulator.isDefaultResonantModulator
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* @param mod1 {Modulator}
|
|
248
|
-
* @param mod2 {Modulator}
|
|
249
|
-
* @param checkAmount {boolean}
|
|
250
|
-
* @returns {boolean}
|
|
251
|
-
*/
|
|
252
|
-
static isIdentical(mod1, mod2, checkAmount = false)
|
|
253
|
-
{
|
|
254
|
-
return (mod1.sourceIndex === mod2.sourceIndex)
|
|
255
|
-
&& (mod1.sourceUsesCC === mod2.sourceUsesCC)
|
|
256
|
-
&& (mod1.sourcePolarity === mod2.sourcePolarity)
|
|
257
|
-
&& (mod1.sourceDirection === mod2.sourceDirection)
|
|
258
|
-
&& (mod1.sourceCurveType === mod2.sourceCurveType)
|
|
259
|
-
|
|
260
|
-
&& (mod1.secSrcIndex === mod2.secSrcIndex)
|
|
261
|
-
&& (mod1.secSrcUsesCC === mod2.secSrcUsesCC)
|
|
262
|
-
&& (mod1.secSrcPolarity === mod2.secSrcPolarity)
|
|
263
|
-
&& (mod1.secSrcDirection === mod2.secSrcDirection)
|
|
264
|
-
&& (mod1.secSrcCurveType === mod2.secSrcCurveType)
|
|
265
|
-
|
|
266
|
-
&& (mod1.modulatorDestination === mod2.modulatorDestination)
|
|
267
|
-
&& (mod1.transformType === mod2.transformType)
|
|
268
|
-
&& (!checkAmount || (mod1.transformAmount === mod2.transformAmount));
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* @param mod {Modulator}
|
|
273
|
-
* @returns {string}
|
|
274
|
-
*/
|
|
275
|
-
static debugString(mod)
|
|
276
|
-
{
|
|
277
|
-
function getKeyByValue(object, value)
|
|
278
|
-
{
|
|
279
|
-
return Object.keys(object).find(key => object[key] === value);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
let sourceString = getKeyByValue(modulatorCurveTypes, mod.sourceCurveType);
|
|
283
|
-
sourceString += mod.sourcePolarity === 0 ? " unipolar " : " bipolar ";
|
|
284
|
-
sourceString += mod.sourceDirection === 0 ? "forwards " : "backwards ";
|
|
285
|
-
if (mod.sourceUsesCC)
|
|
286
|
-
{
|
|
287
|
-
sourceString += getKeyByValue(midiControllers, mod.sourceIndex);
|
|
288
|
-
}
|
|
289
|
-
else
|
|
290
|
-
{
|
|
291
|
-
sourceString += getKeyByValue(modulatorSources, mod.sourceIndex);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
let secSrcString = getKeyByValue(modulatorCurveTypes, mod.secSrcCurveType);
|
|
295
|
-
secSrcString += mod.secSrcPolarity === 0 ? " unipolar " : " bipolar ";
|
|
296
|
-
secSrcString += mod.secSrcDirection === 0 ? "forwards " : "backwards ";
|
|
297
|
-
if (mod.secSrcUsesCC)
|
|
298
|
-
{
|
|
299
|
-
secSrcString += getKeyByValue(midiControllers, mod.secSrcIndex);
|
|
300
|
-
}
|
|
301
|
-
else
|
|
302
|
-
{
|
|
303
|
-
secSrcString += getKeyByValue(modulatorSources, mod.secSrcIndex);
|
|
304
|
-
}
|
|
305
|
-
return `Modulator:
|
|
306
|
-
Source: ${sourceString}
|
|
307
|
-
Secondary source: ${secSrcString}
|
|
308
|
-
Destination: ${getKeyByValue(generatorTypes, mod.modulatorDestination)}
|
|
309
|
-
Trasform amount: ${mod.transformAmount}
|
|
310
|
-
Transform type: ${mod.transformType}
|
|
311
|
-
\n\n`;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
getSourceEnum()
|
|
315
|
-
{
|
|
316
|
-
return getModSourceEnum(
|
|
317
|
-
this.sourceCurveType,
|
|
318
|
-
this.sourcePolarity,
|
|
319
|
-
this.sourceDirection,
|
|
320
|
-
this.sourceUsesCC,
|
|
321
|
-
this.sourceIndex
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
getSecSrcEnum()
|
|
326
|
-
{
|
|
327
|
-
return getModSourceEnum(
|
|
328
|
-
this.secSrcCurveType,
|
|
329
|
-
this.secSrcPolarity,
|
|
330
|
-
this.secSrcDirection,
|
|
331
|
-
this.secSrcUsesCC,
|
|
332
|
-
this.secSrcIndex
|
|
333
|
-
);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Sum transform and create a NEW modulator
|
|
338
|
-
* @param modulator {Modulator}
|
|
339
|
-
* @returns {Modulator}
|
|
340
|
-
*/
|
|
341
|
-
sumTransform(modulator)
|
|
342
|
-
{
|
|
343
|
-
return new Modulator(
|
|
344
|
-
this.sourceIndex,
|
|
345
|
-
this.sourceCurveType,
|
|
346
|
-
this.sourceUsesCC,
|
|
347
|
-
this.sourcePolarity,
|
|
348
|
-
this.sourceDirection,
|
|
349
|
-
this.secSrcIndex,
|
|
350
|
-
this.secSrcCurveType,
|
|
351
|
-
this.secSrcUsesCC,
|
|
352
|
-
this.secSrcPolarity,
|
|
353
|
-
this.secSrcDirection,
|
|
354
|
-
this.modulatorDestination,
|
|
355
|
-
this.transformAmount + modulator.transformAmount,
|
|
356
|
-
this.transformType,
|
|
357
|
-
this.isEffectModulator,
|
|
358
|
-
this.isDefaultResonantModulator
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
export class DecodedModulator extends Modulator
|
|
364
|
-
{
|
|
365
|
-
/**
|
|
366
|
-
* reads an SF2 modulator
|
|
367
|
-
* @param sourceEnum {number} SF2 source enum
|
|
368
|
-
* @param secondarySourceEnum {number} SF2 secondary source enum
|
|
369
|
-
* @param destination {generatorTypes|number} destination
|
|
370
|
-
* @param amount {number} amount
|
|
371
|
-
* @param transformType {number} transform type
|
|
372
|
-
*/
|
|
373
|
-
constructor(sourceEnum, secondarySourceEnum, destination, amount, transformType)
|
|
374
|
-
{
|
|
375
|
-
// decode the source
|
|
376
|
-
const sourcePolarity = sourceEnum >> 9 & 1;
|
|
377
|
-
const sourceDirection = sourceEnum >> 8 & 1;
|
|
378
|
-
const sourceUsesCC = sourceEnum >> 7 & 1;
|
|
379
|
-
const sourceIndex = /** @type {modulatorSources} **/ sourceEnum & 127;
|
|
380
|
-
const sourceCurveType = /** @type {modulatorCurveTypes} **/ sourceEnum >> 10 & 3;
|
|
381
|
-
|
|
382
|
-
// decode the secondary source
|
|
383
|
-
const secSrcPolarity = secondarySourceEnum >> 9 & 1;
|
|
384
|
-
const secSrcDirection = secondarySourceEnum >> 8 & 1;
|
|
385
|
-
const secSrcUsesCC = secondarySourceEnum >> 7 & 1;
|
|
386
|
-
const secSrcIndex = /** @type {modulatorSources} **/ secondarySourceEnum & 127;
|
|
387
|
-
const secSrcCurveType = /** @type {modulatorCurveTypes} **/ secondarySourceEnum >> 10 & 3;
|
|
388
|
-
|
|
389
|
-
super(
|
|
390
|
-
sourceIndex,
|
|
391
|
-
sourceCurveType,
|
|
392
|
-
sourceUsesCC,
|
|
393
|
-
sourcePolarity,
|
|
394
|
-
sourceDirection,
|
|
395
|
-
secSrcIndex,
|
|
396
|
-
secSrcCurveType,
|
|
397
|
-
secSrcUsesCC,
|
|
398
|
-
secSrcPolarity,
|
|
399
|
-
secSrcDirection,
|
|
400
|
-
destination,
|
|
401
|
-
amount,
|
|
402
|
-
transformType
|
|
403
|
-
);
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
this.isEffectModulator =
|
|
407
|
-
(
|
|
408
|
-
sourceEnum === 0x00DB
|
|
409
|
-
|| sourceEnum === 0x00DD
|
|
410
|
-
)
|
|
411
|
-
&& secondarySourceEnum === 0x0
|
|
412
|
-
&& (
|
|
413
|
-
this.modulatorDestination === generatorTypes.reverbEffectsSend
|
|
414
|
-
|| this.modulatorDestination === generatorTypes.chorusEffectsSend
|
|
415
|
-
);
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
this.isDefaultResonantModulator = (
|
|
419
|
-
sourceEnum === defaultResonantModSource
|
|
420
|
-
&& secondarySourceEnum === 0x0
|
|
421
|
-
&& this.modulatorDestination === generatorTypes.initialFilterQ
|
|
422
|
-
);
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
export const DEFAULT_ATTENUATION_MOD_AMOUNT = 960;
|
|
427
|
-
export const DEFAULT_ATTENUATION_MOD_CURVE_TYPE = modulatorCurveTypes.concave;
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
const soundFontModulators = [
|
|
431
|
-
// vel to attenuation
|
|
432
|
-
new DecodedModulator(
|
|
433
|
-
getModSourceEnum(
|
|
434
|
-
DEFAULT_ATTENUATION_MOD_CURVE_TYPE,
|
|
435
|
-
0,
|
|
436
|
-
1,
|
|
437
|
-
0,
|
|
438
|
-
modulatorSources.noteOnVelocity
|
|
439
|
-
),
|
|
440
|
-
0x0,
|
|
441
|
-
generatorTypes.initialAttenuation,
|
|
442
|
-
DEFAULT_ATTENUATION_MOD_AMOUNT,
|
|
443
|
-
0
|
|
444
|
-
),
|
|
445
|
-
|
|
446
|
-
// mod wheel to vibrato
|
|
447
|
-
new DecodedModulator(0x0081, 0x0, generatorTypes.vibLfoToPitch, 50, 0),
|
|
448
|
-
|
|
449
|
-
// vol to attenuation
|
|
450
|
-
new DecodedModulator(
|
|
451
|
-
getModSourceEnum(
|
|
452
|
-
DEFAULT_ATTENUATION_MOD_CURVE_TYPE,
|
|
453
|
-
0,
|
|
454
|
-
1,
|
|
455
|
-
1,
|
|
456
|
-
midiControllers.mainVolume
|
|
457
|
-
),
|
|
458
|
-
0x0,
|
|
459
|
-
generatorTypes.initialAttenuation,
|
|
460
|
-
DEFAULT_ATTENUATION_MOD_AMOUNT,
|
|
461
|
-
0
|
|
462
|
-
),
|
|
463
|
-
|
|
464
|
-
// channel pressure to vibrato
|
|
465
|
-
new DecodedModulator(0x000D, 0x0, generatorTypes.vibLfoToPitch, 50, 0),
|
|
466
|
-
|
|
467
|
-
// pitch wheel to tuning
|
|
468
|
-
new DecodedModulator(0x020E, 0x0010, generatorTypes.fineTune, 12700, 0),
|
|
469
|
-
|
|
470
|
-
// pan to uhh, pan
|
|
471
|
-
// amount is 500 instead of 1000, see #59
|
|
472
|
-
new DecodedModulator(0x028A, 0x0, generatorTypes.pan, 500, 0),
|
|
473
|
-
|
|
474
|
-
// expression to attenuation
|
|
475
|
-
new DecodedModulator(
|
|
476
|
-
getModSourceEnum(
|
|
477
|
-
DEFAULT_ATTENUATION_MOD_CURVE_TYPE,
|
|
478
|
-
0,
|
|
479
|
-
1,
|
|
480
|
-
1,
|
|
481
|
-
midiControllers.expressionController
|
|
482
|
-
),
|
|
483
|
-
0x0,
|
|
484
|
-
generatorTypes.initialAttenuation,
|
|
485
|
-
DEFAULT_ATTENUATION_MOD_AMOUNT,
|
|
486
|
-
0
|
|
487
|
-
),
|
|
488
|
-
|
|
489
|
-
// reverb effects to send
|
|
490
|
-
new DecodedModulator(0x00DB, 0x0, generatorTypes.reverbEffectsSend, 200, 0),
|
|
491
|
-
|
|
492
|
-
// chorus effects to send
|
|
493
|
-
new DecodedModulator(0x00DD, 0x0, generatorTypes.chorusEffectsSend, 200, 0)
|
|
494
|
-
];
|
|
495
|
-
|
|
496
|
-
const customModulators = [
|
|
497
|
-
// custom modulators heck yeah
|
|
498
|
-
// poly pressure to vibrato
|
|
499
|
-
new DecodedModulator(
|
|
500
|
-
getModSourceEnum(modulatorCurveTypes.linear, 0, 0, 0, modulatorSources.polyPressure),
|
|
501
|
-
0x0,
|
|
502
|
-
generatorTypes.vibLfoToPitch,
|
|
503
|
-
50,
|
|
504
|
-
0
|
|
505
|
-
),
|
|
506
|
-
|
|
507
|
-
// cc 92 (tremolo) to modLFO volume
|
|
508
|
-
new DecodedModulator(
|
|
509
|
-
getModSourceEnum(
|
|
510
|
-
modulatorCurveTypes.linear,
|
|
511
|
-
0,
|
|
512
|
-
0,
|
|
513
|
-
1,
|
|
514
|
-
midiControllers.tremoloDepth
|
|
515
|
-
), /*linear forward unipolar cc 92 */
|
|
516
|
-
0x0, // no controller
|
|
517
|
-
generatorTypes.modLfoToVolume,
|
|
518
|
-
24,
|
|
519
|
-
0
|
|
520
|
-
),
|
|
521
|
-
|
|
522
|
-
// cc 73 (attack time) to volEnv attack
|
|
523
|
-
new DecodedModulator(
|
|
524
|
-
getModSourceEnum(
|
|
525
|
-
modulatorCurveTypes.convex,
|
|
526
|
-
1,
|
|
527
|
-
0,
|
|
528
|
-
1,
|
|
529
|
-
midiControllers.attackTime
|
|
530
|
-
), // linear forward bipolar cc 72
|
|
531
|
-
0x0, // no controller
|
|
532
|
-
generatorTypes.attackVolEnv,
|
|
533
|
-
6000,
|
|
534
|
-
0
|
|
535
|
-
),
|
|
536
|
-
|
|
537
|
-
// cc 72 (release time) to volEnv release
|
|
538
|
-
new DecodedModulator(
|
|
539
|
-
getModSourceEnum(
|
|
540
|
-
modulatorCurveTypes.linear,
|
|
541
|
-
1,
|
|
542
|
-
0,
|
|
543
|
-
1,
|
|
544
|
-
midiControllers.releaseTime
|
|
545
|
-
), // linear forward bipolar cc 72
|
|
546
|
-
0x0, // no controller
|
|
547
|
-
generatorTypes.releaseVolEnv,
|
|
548
|
-
3600,
|
|
549
|
-
0
|
|
550
|
-
),
|
|
551
|
-
|
|
552
|
-
// cc 74 (brightness) to filterFc
|
|
553
|
-
new DecodedModulator(
|
|
554
|
-
getModSourceEnum(
|
|
555
|
-
modulatorCurveTypes.linear,
|
|
556
|
-
1,
|
|
557
|
-
0,
|
|
558
|
-
1,
|
|
559
|
-
midiControllers.brightness
|
|
560
|
-
), // linear forwards bipolar cc 74
|
|
561
|
-
0x0, // no controller
|
|
562
|
-
generatorTypes.initialFilterFc,
|
|
563
|
-
6000,
|
|
564
|
-
0
|
|
565
|
-
),
|
|
566
|
-
|
|
567
|
-
// cc 71 (filter Q) to filter Q (default resonant modulator)
|
|
568
|
-
new DecodedModulator(
|
|
569
|
-
defaultResonantModSource,
|
|
570
|
-
0x0, // no controller
|
|
571
|
-
generatorTypes.initialFilterQ,
|
|
572
|
-
250,
|
|
573
|
-
0
|
|
574
|
-
)
|
|
575
|
-
|
|
576
|
-
];
|
|
577
|
-
|
|
578
|
-
/**
|
|
579
|
-
* @type {Modulator[]}
|
|
580
|
-
*/
|
|
581
|
-
export const defaultModulators = soundFontModulators.concat(customModulators);
|