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.
- package/README.md +85 -51
- package/dist/index.d.ts +4057 -0
- package/dist/index.js +17188 -0
- package/dist/index.js.map +1 -0
- package/package.json +23 -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,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
|
-
}
|