spessasynth_lib 3.25.23 → 3.26.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 +29 -114
- package/external_midi/midi_handler.js +14 -14
- package/external_midi/web_midi_link.js +3 -3
- package/index.js +33 -33
- package/package.json +19 -6
- package/{midi → sequencer}/midi_data.js +1 -1
- package/sequencer/{worklet_wrapper/sequencer.js → sequencer.js} +13 -12
- package/sequencer/{worklet_wrapper/sequencer_message.js → sequencer_message.js} +1 -1
- package/synthetizer/README.md +29 -1
- package/synthetizer/audio_effects/reverb_as_binary.js +2 -2
- package/synthetizer/{worklet_wrapper/key_modifier_manager.js → key_modifier_manager.js} +11 -2
- package/synthetizer/{worklet_wrapper/synth_event_handler.js → synth_event_handler.js} +16 -13
- package/synthetizer/{worklet_wrapper/synth_soundfont_manager.js → synth_soundfont_manager.js} +8 -5
- package/synthetizer/{worklet_wrapper/synthetizer.js → synthetizer.js} +29 -23
- package/synthetizer/{audio_engine/message_protocol/worklet_message.js → worklet_message.js} +15 -2
- package/synthetizer/{worklet_wrapper/worklet_processor.js → worklet_processor.js} +214 -31
- package/synthetizer/worklet_processor.min.js +13 -12
- package/synthetizer/worklet_processor.min.js.map +7 -0
- package/synthetizer/{worklet_wrapper/worklet_url.js → worklet_url.js} +2 -0
- package/utils/buffer_to_wav.js +7 -165
- package/utils/other.js +3 -84
- package/externals/fflate/LICENSE +0 -21
- package/externals/fflate/fflate.min.js +0 -1
- package/externals/stbvorbis_sync/@types/stbvorbis_sync.d.ts +0 -12
- package/externals/stbvorbis_sync/LICENSE +0 -202
- package/externals/stbvorbis_sync/NOTICE +0 -6
- package/externals/stbvorbis_sync/stbvorbis_sync.min.js +0 -1
- package/midi/README.md +0 -32
- package/midi/basic_midi.js +0 -565
- package/midi/midi_builder.js +0 -202
- package/midi/midi_loader.js +0 -324
- package/midi/midi_message.js +0 -254
- package/midi/midi_sequence.js +0 -225
- package/midi/midi_tools/get_note_times.js +0 -154
- package/midi/midi_tools/midi_editor.js +0 -611
- package/midi/midi_tools/midi_writer.js +0 -99
- package/midi/midi_tools/rmidi_writer.js +0 -567
- package/midi/midi_tools/used_keys_loaded.js +0 -238
- package/midi/xmf_loader.js +0 -454
- package/sequencer/sequencer_engine/events.js +0 -104
- package/sequencer/sequencer_engine/play.js +0 -353
- package/sequencer/sequencer_engine/process_event.js +0 -169
- package/sequencer/sequencer_engine/process_tick.js +0 -106
- package/sequencer/sequencer_engine/sequencer_engine.js +0 -335
- package/sequencer/sequencer_engine/song_control.js +0 -229
- package/soundfont/README.md +0 -13
- package/soundfont/basic_soundfont/basic_instrument.js +0 -77
- package/soundfont/basic_soundfont/basic_preset.js +0 -336
- package/soundfont/basic_soundfont/basic_sample.js +0 -197
- package/soundfont/basic_soundfont/basic_soundfont.js +0 -565
- package/soundfont/basic_soundfont/basic_zone.js +0 -64
- package/soundfont/basic_soundfont/basic_zones.js +0 -43
- package/soundfont/basic_soundfont/generator.js +0 -220
- package/soundfont/basic_soundfont/modulator.js +0 -378
- package/soundfont/basic_soundfont/riff_chunk.js +0 -149
- package/soundfont/basic_soundfont/write_dls/art2.js +0 -173
- package/soundfont/basic_soundfont/write_dls/articulator.js +0 -49
- package/soundfont/basic_soundfont/write_dls/combine_zones.js +0 -400
- package/soundfont/basic_soundfont/write_dls/ins.js +0 -103
- package/soundfont/basic_soundfont/write_dls/lins.js +0 -18
- package/soundfont/basic_soundfont/write_dls/modulator_converter.js +0 -330
- package/soundfont/basic_soundfont/write_dls/rgn2.js +0 -121
- package/soundfont/basic_soundfont/write_dls/wave.js +0 -94
- package/soundfont/basic_soundfont/write_dls/write_dls.js +0 -119
- package/soundfont/basic_soundfont/write_dls/wsmp.js +0 -78
- package/soundfont/basic_soundfont/write_dls/wvpl.js +0 -32
- package/soundfont/basic_soundfont/write_sf2/ibag.js +0 -39
- package/soundfont/basic_soundfont/write_sf2/igen.js +0 -80
- package/soundfont/basic_soundfont/write_sf2/imod.js +0 -46
- package/soundfont/basic_soundfont/write_sf2/inst.js +0 -34
- package/soundfont/basic_soundfont/write_sf2/pbag.js +0 -39
- package/soundfont/basic_soundfont/write_sf2/pgen.js +0 -82
- package/soundfont/basic_soundfont/write_sf2/phdr.js +0 -42
- package/soundfont/basic_soundfont/write_sf2/pmod.js +0 -46
- package/soundfont/basic_soundfont/write_sf2/sdta.js +0 -80
- package/soundfont/basic_soundfont/write_sf2/shdr.js +0 -55
- package/soundfont/basic_soundfont/write_sf2/write.js +0 -222
- package/soundfont/dls/articulator_converter.js +0 -396
- package/soundfont/dls/dls_destinations.js +0 -38
- package/soundfont/dls/dls_preset.js +0 -44
- package/soundfont/dls/dls_sample.js +0 -75
- package/soundfont/dls/dls_soundfont.js +0 -186
- package/soundfont/dls/dls_sources.js +0 -62
- package/soundfont/dls/dls_zone.js +0 -95
- package/soundfont/dls/read_articulation.js +0 -299
- package/soundfont/dls/read_instrument.js +0 -121
- package/soundfont/dls/read_instrument_list.js +0 -17
- package/soundfont/dls/read_lart.js +0 -35
- package/soundfont/dls/read_region.js +0 -152
- package/soundfont/dls/read_samples.js +0 -270
- package/soundfont/load_soundfont.js +0 -21
- package/soundfont/read_sf2/generators.js +0 -46
- package/soundfont/read_sf2/instruments.js +0 -66
- package/soundfont/read_sf2/modulators.js +0 -36
- package/soundfont/read_sf2/presets.js +0 -80
- package/soundfont/read_sf2/samples.js +0 -304
- package/soundfont/read_sf2/soundfont.js +0 -305
- package/soundfont/read_sf2/zones.js +0 -263
- package/synthetizer/audio_engine/README.md +0 -25
- package/synthetizer/audio_engine/engine_components/compute_modulator.js +0 -266
- package/synthetizer/audio_engine/engine_components/controller_tables.js +0 -88
- package/synthetizer/audio_engine/engine_components/key_modifier_manager.js +0 -149
- package/synthetizer/audio_engine/engine_components/lfo.js +0 -26
- package/synthetizer/audio_engine/engine_components/lowpass_filter.js +0 -282
- package/synthetizer/audio_engine/engine_components/midi_audio_channel.js +0 -471
- package/synthetizer/audio_engine/engine_components/modulation_envelope.js +0 -181
- package/synthetizer/audio_engine/engine_components/modulator_curves.js +0 -89
- package/synthetizer/audio_engine/engine_components/soundfont_manager.js +0 -228
- package/synthetizer/audio_engine/engine_components/stereo_panner.js +0 -120
- package/synthetizer/audio_engine/engine_components/unit_converter.js +0 -73
- package/synthetizer/audio_engine/engine_components/voice.js +0 -519
- package/synthetizer/audio_engine/engine_components/volume_envelope.js +0 -401
- package/synthetizer/audio_engine/engine_components/wavetable_oscillator.js +0 -263
- package/synthetizer/audio_engine/engine_methods/controller_control/controller_change.js +0 -132
- package/synthetizer/audio_engine/engine_methods/controller_control/master_parameters.js +0 -48
- package/synthetizer/audio_engine/engine_methods/controller_control/reset_controllers.js +0 -241
- package/synthetizer/audio_engine/engine_methods/create_midi_channel.js +0 -27
- package/synthetizer/audio_engine/engine_methods/data_entry/data_entry_coarse.js +0 -253
- package/synthetizer/audio_engine/engine_methods/data_entry/data_entry_fine.js +0 -66
- package/synthetizer/audio_engine/engine_methods/mute_channel.js +0 -17
- package/synthetizer/audio_engine/engine_methods/note_on.js +0 -175
- package/synthetizer/audio_engine/engine_methods/portamento_time.js +0 -92
- package/synthetizer/audio_engine/engine_methods/program_change.js +0 -61
- package/synthetizer/audio_engine/engine_methods/render_voice.js +0 -196
- package/synthetizer/audio_engine/engine_methods/soundfont_management/clear_sound_font.js +0 -30
- package/synthetizer/audio_engine/engine_methods/soundfont_management/get_preset.js +0 -22
- package/synthetizer/audio_engine/engine_methods/soundfont_management/reload_sound_font.js +0 -40
- package/synthetizer/audio_engine/engine_methods/soundfont_management/send_preset_list.js +0 -34
- package/synthetizer/audio_engine/engine_methods/soundfont_management/set_embedded_sound_font.js +0 -21
- package/synthetizer/audio_engine/engine_methods/stopping_notes/kill_note.js +0 -20
- package/synthetizer/audio_engine/engine_methods/stopping_notes/note_off.js +0 -55
- package/synthetizer/audio_engine/engine_methods/stopping_notes/stop_all_channels.js +0 -16
- package/synthetizer/audio_engine/engine_methods/stopping_notes/stop_all_notes.js +0 -30
- package/synthetizer/audio_engine/engine_methods/stopping_notes/voice_killing.js +0 -63
- package/synthetizer/audio_engine/engine_methods/system_exclusive.js +0 -776
- package/synthetizer/audio_engine/engine_methods/tuning_control/channel_pressure.js +0 -24
- package/synthetizer/audio_engine/engine_methods/tuning_control/pitch_wheel.js +0 -33
- package/synthetizer/audio_engine/engine_methods/tuning_control/poly_pressure.js +0 -31
- package/synthetizer/audio_engine/engine_methods/tuning_control/set_master_tuning.js +0 -15
- package/synthetizer/audio_engine/engine_methods/tuning_control/set_modulation_depth.js +0 -27
- package/synthetizer/audio_engine/engine_methods/tuning_control/set_octave_tuning.js +0 -19
- package/synthetizer/audio_engine/engine_methods/tuning_control/set_tuning.js +0 -27
- package/synthetizer/audio_engine/engine_methods/tuning_control/transpose_all_channels.js +0 -15
- package/synthetizer/audio_engine/engine_methods/tuning_control/transpose_channel.js +0 -34
- package/synthetizer/audio_engine/main_processor.js +0 -765
- package/synthetizer/audio_engine/message_protocol/README.md +0 -13
- package/synthetizer/audio_engine/message_protocol/message_sending.js +0 -22
- package/synthetizer/audio_engine/snapshot/apply_synthesizer_snapshot.js +0 -14
- package/synthetizer/audio_engine/snapshot/channel_snapshot.js +0 -175
- package/synthetizer/audio_engine/snapshot/synthesizer_snapshot.js +0 -122
- package/synthetizer/synth_constants.js +0 -20
- package/utils/README.md +0 -5
- package/utils/byte_functions/big_endian.js +0 -32
- package/utils/byte_functions/little_endian.js +0 -77
- package/utils/byte_functions/string.js +0 -107
- package/utils/byte_functions/variable_length_quantity.js +0 -42
- package/utils/indexed_array.js +0 -52
- package/utils/loggin.js +0 -79
- package/utils/sysex_detector.js +0 -58
- package/utils/xg_hacks.js +0 -193
- /package/sequencer/{worklet_wrapper/default_sequencer_options.js → default_sequencer_options.js} +0 -0
- /package/synthetizer/{worklet_wrapper/sfman_message.js → sfman_message.js} +0 -0
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { IndexedByteArray } from "../../utils/indexed_array.js";
|
|
2
|
-
import { readLittleEndian, writeDword } from "../../utils/byte_functions/little_endian.js";
|
|
3
|
-
import { readBytesAsString, writeStringAsBytes } from "../../utils/byte_functions/string.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* riff_chunk.js
|
|
7
|
-
* reads a riff read and stores it as a class
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export class RiffChunk
|
|
11
|
-
{
|
|
12
|
-
/**
|
|
13
|
-
* Creates a new riff read
|
|
14
|
-
* @constructor
|
|
15
|
-
* @param header {string}
|
|
16
|
-
* @param size {number}
|
|
17
|
-
* @param data {IndexedByteArray}
|
|
18
|
-
*/
|
|
19
|
-
constructor(header, size, data)
|
|
20
|
-
{
|
|
21
|
-
this.header = header;
|
|
22
|
-
this.size = size;
|
|
23
|
-
this.chunkData = data;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @param dataArray {IndexedByteArray}
|
|
30
|
-
* @param readData {boolean}
|
|
31
|
-
* @param forceShift {boolean}
|
|
32
|
-
* @returns {RiffChunk}
|
|
33
|
-
*/
|
|
34
|
-
export function readRIFFChunk(dataArray, readData = true, forceShift = false)
|
|
35
|
-
{
|
|
36
|
-
let header = readBytesAsString(dataArray, 4);
|
|
37
|
-
|
|
38
|
-
let size = readLittleEndian(dataArray, 4);
|
|
39
|
-
let chunkData = undefined;
|
|
40
|
-
if (readData)
|
|
41
|
-
{
|
|
42
|
-
chunkData = new IndexedByteArray(dataArray.buffer.slice(dataArray.currentIndex, dataArray.currentIndex + size));
|
|
43
|
-
}
|
|
44
|
-
if (readData || forceShift)
|
|
45
|
-
{
|
|
46
|
-
dataArray.currentIndex += size;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (size % 2 !== 0)
|
|
50
|
-
{
|
|
51
|
-
if (dataArray[dataArray.currentIndex] === 0)
|
|
52
|
-
{
|
|
53
|
-
dataArray.currentIndex++;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return new RiffChunk(header, size, chunkData);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @param chunk {RiffChunk}
|
|
62
|
-
* @param prepend {IndexedByteArray}
|
|
63
|
-
* @returns {IndexedByteArray}
|
|
64
|
-
*/
|
|
65
|
-
export function writeRIFFChunk(chunk, prepend = undefined)
|
|
66
|
-
{
|
|
67
|
-
let size = 8 + chunk.size;
|
|
68
|
-
if (chunk.size % 2 !== 0)
|
|
69
|
-
{
|
|
70
|
-
size++;
|
|
71
|
-
}
|
|
72
|
-
if (prepend)
|
|
73
|
-
{
|
|
74
|
-
size += prepend.length;
|
|
75
|
-
}
|
|
76
|
-
const array = new IndexedByteArray(size);
|
|
77
|
-
// prepend data (for example, type before the read)
|
|
78
|
-
if (prepend)
|
|
79
|
-
{
|
|
80
|
-
array.set(prepend, array.currentIndex);
|
|
81
|
-
array.currentIndex += prepend.length;
|
|
82
|
-
}
|
|
83
|
-
// write header
|
|
84
|
-
writeStringAsBytes(array, chunk.header);
|
|
85
|
-
// write size (excluding header and the size itself) and then prepend if specified
|
|
86
|
-
writeDword(array, size - 8 - (prepend?.length || 0));
|
|
87
|
-
// write data
|
|
88
|
-
array.set(chunk.chunkData, array.currentIndex);
|
|
89
|
-
return array;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* @param header {string}
|
|
94
|
-
* @param data {Uint8Array}
|
|
95
|
-
* @param addZeroByte {Boolean}
|
|
96
|
-
* @param isList {boolean}
|
|
97
|
-
* @returns {IndexedByteArray}
|
|
98
|
-
*/
|
|
99
|
-
export function writeRIFFOddSize(header, data, addZeroByte = false, isList = false)
|
|
100
|
-
{
|
|
101
|
-
if (addZeroByte)
|
|
102
|
-
{
|
|
103
|
-
const tempData = new Uint8Array(data.length + 1);
|
|
104
|
-
tempData.set(data);
|
|
105
|
-
data = tempData;
|
|
106
|
-
}
|
|
107
|
-
let offset = 8;
|
|
108
|
-
let finalSize = offset + data.length;
|
|
109
|
-
let writtenSize = data.length;
|
|
110
|
-
if (finalSize % 2 !== 0)
|
|
111
|
-
{
|
|
112
|
-
finalSize++;
|
|
113
|
-
}
|
|
114
|
-
let headerWritten = header;
|
|
115
|
-
if (isList)
|
|
116
|
-
{
|
|
117
|
-
finalSize += 4;
|
|
118
|
-
writtenSize += 4;
|
|
119
|
-
offset += 4;
|
|
120
|
-
headerWritten = "LIST";
|
|
121
|
-
}
|
|
122
|
-
const outArray = new IndexedByteArray(finalSize);
|
|
123
|
-
writeStringAsBytes(outArray, headerWritten);
|
|
124
|
-
writeDword(outArray, writtenSize);
|
|
125
|
-
if (isList)
|
|
126
|
-
{
|
|
127
|
-
writeStringAsBytes(outArray, header);
|
|
128
|
-
}
|
|
129
|
-
outArray.set(data, offset);
|
|
130
|
-
return outArray;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* @param collection {RiffChunk[]}
|
|
135
|
-
* @param type {string}
|
|
136
|
-
* @returns {RiffChunk|undefined}
|
|
137
|
-
*/
|
|
138
|
-
export function findRIFFListType(collection, type)
|
|
139
|
-
{
|
|
140
|
-
return collection.find(c =>
|
|
141
|
-
{
|
|
142
|
-
if (c.header !== "LIST")
|
|
143
|
-
{
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
c.chunkData.currentIndex = 0;
|
|
147
|
-
return readBytesAsString(c.chunkData, 4) === type;
|
|
148
|
-
});
|
|
149
|
-
}
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { getDLSArticulatorFromSf2Generator, getDLSArticulatorFromSf2Modulator } from "./modulator_converter.js";
|
|
2
|
-
import { writeRIFFOddSize } from "../riff_chunk.js";
|
|
3
|
-
import { combineArrays, IndexedByteArray } from "../../../utils/indexed_array.js";
|
|
4
|
-
import { Generator, generatorTypes } from "../generator.js";
|
|
5
|
-
import { writeDword } from "../../../utils/byte_functions/little_endian.js";
|
|
6
|
-
import { consoleColors } from "../../../utils/other.js";
|
|
7
|
-
import { SpessaSynthInfo, SpessaSynthWarn } from "../../../utils/loggin.js";
|
|
8
|
-
import { Modulator } from "../modulator.js";
|
|
9
|
-
import {
|
|
10
|
-
DEFAULT_DLS_CHORUS,
|
|
11
|
-
DEFAULT_DLS_REVERB,
|
|
12
|
-
DLS_1_NO_VIBRATO_MOD,
|
|
13
|
-
DLS_1_NO_VIBRATO_PRESSURE
|
|
14
|
-
} from "../../dls/dls_sources.js";
|
|
15
|
-
|
|
16
|
-
const invalidGeneratorTypes = new Set([
|
|
17
|
-
generatorTypes.sampleModes,
|
|
18
|
-
generatorTypes.initialAttenuation,
|
|
19
|
-
generatorTypes.keyRange,
|
|
20
|
-
generatorTypes.velRange,
|
|
21
|
-
generatorTypes.sampleID,
|
|
22
|
-
generatorTypes.fineTune,
|
|
23
|
-
generatorTypes.coarseTune,
|
|
24
|
-
generatorTypes.startAddrsOffset,
|
|
25
|
-
generatorTypes.startAddrsCoarseOffset,
|
|
26
|
-
generatorTypes.endAddrOffset,
|
|
27
|
-
generatorTypes.endAddrsCoarseOffset,
|
|
28
|
-
generatorTypes.startloopAddrsOffset,
|
|
29
|
-
generatorTypes.startloopAddrsCoarseOffset,
|
|
30
|
-
generatorTypes.endloopAddrsOffset,
|
|
31
|
-
generatorTypes.endloopAddrsCoarseOffset,
|
|
32
|
-
generatorTypes.overridingRootKey,
|
|
33
|
-
generatorTypes.exclusiveClass
|
|
34
|
-
]);
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @param zone {BasicInstrumentZone}
|
|
38
|
-
* @returns {IndexedByteArray}
|
|
39
|
-
*/
|
|
40
|
-
export function writeArticulator(zone)
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// envelope generators are limited to 40 seconds
|
|
45
|
-
// in timecents, this is 1200 * log2(10) = 6386
|
|
46
|
-
|
|
47
|
-
for (let i = 0; i < zone.generators.length; i++)
|
|
48
|
-
{
|
|
49
|
-
const g = zone.generators[i];
|
|
50
|
-
if (
|
|
51
|
-
g.generatorType === generatorTypes.delayVolEnv ||
|
|
52
|
-
g.generatorType === generatorTypes.attackVolEnv ||
|
|
53
|
-
g.generatorType === generatorTypes.holdVolEnv ||
|
|
54
|
-
g.generatorType === generatorTypes.decayVolEnv ||
|
|
55
|
-
g.generatorType === generatorTypes.releaseVolEnv ||
|
|
56
|
-
g.generatorType === generatorTypes.delayModEnv ||
|
|
57
|
-
g.generatorType === generatorTypes.attackModEnv ||
|
|
58
|
-
g.generatorType === generatorTypes.holdModEnv ||
|
|
59
|
-
g.generatorType === generatorTypes.decayModEnv
|
|
60
|
-
)
|
|
61
|
-
{
|
|
62
|
-
zone.generators[i] = new Generator(g.generatorType, Math.min(g.generatorValue, 6386), false);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// read_articulation.js:
|
|
68
|
-
// according to viena and another strange (with modulators) rendition of gm.dls in sf2,
|
|
69
|
-
// it shall be divided by -128,
|
|
70
|
-
// and a strange correction needs to be applied to the real value:
|
|
71
|
-
// real + (60 / 128) * scale
|
|
72
|
-
// we invert this here
|
|
73
|
-
for (let i = 0; i < zone.generators.length; i++)
|
|
74
|
-
{
|
|
75
|
-
const relativeGenerator = zone.generators[i];
|
|
76
|
-
let absoluteCounterpart = undefined;
|
|
77
|
-
switch (relativeGenerator.generatorType)
|
|
78
|
-
{
|
|
79
|
-
default:
|
|
80
|
-
continue;
|
|
81
|
-
|
|
82
|
-
case generatorTypes.keyNumToVolEnvDecay:
|
|
83
|
-
absoluteCounterpart = generatorTypes.decayVolEnv;
|
|
84
|
-
break;
|
|
85
|
-
case generatorTypes.keyNumToVolEnvHold:
|
|
86
|
-
absoluteCounterpart = generatorTypes.holdVolEnv;
|
|
87
|
-
break;
|
|
88
|
-
case generatorTypes.keyNumToModEnvDecay:
|
|
89
|
-
absoluteCounterpart = generatorTypes.decayModEnv;
|
|
90
|
-
break;
|
|
91
|
-
case generatorTypes.keyNumToModEnvHold:
|
|
92
|
-
absoluteCounterpart = generatorTypes.holdModEnv;
|
|
93
|
-
}
|
|
94
|
-
let absoluteGenerator = zone.generators.find(g => g.generatorType === absoluteCounterpart);
|
|
95
|
-
if (absoluteGenerator === undefined)
|
|
96
|
-
{
|
|
97
|
-
// there's no absolute generator here.
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
const dlsRelative = relativeGenerator.generatorValue * -128;
|
|
101
|
-
const subtraction = (60 / 128) * dlsRelative;
|
|
102
|
-
const newAbsolute = absoluteGenerator.generatorValue - subtraction;
|
|
103
|
-
|
|
104
|
-
const iR = zone.generators.indexOf(relativeGenerator);
|
|
105
|
-
const iA = zone.generators.indexOf(absoluteGenerator);
|
|
106
|
-
zone.generators[iA] =
|
|
107
|
-
new Generator(absoluteCounterpart, newAbsolute, false);
|
|
108
|
-
zone.generators[iR] =
|
|
109
|
-
new Generator(relativeGenerator.generatorType, dlsRelative, false);
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* @type {Articulator[]}
|
|
113
|
-
*/
|
|
114
|
-
const generators = zone.generators.reduce((arrs, g) =>
|
|
115
|
-
{
|
|
116
|
-
if (invalidGeneratorTypes.has(g.generatorType))
|
|
117
|
-
{
|
|
118
|
-
return arrs;
|
|
119
|
-
}
|
|
120
|
-
const art = getDLSArticulatorFromSf2Generator(g);
|
|
121
|
-
if (art !== undefined)
|
|
122
|
-
{
|
|
123
|
-
arrs.push(art);
|
|
124
|
-
SpessaSynthInfo("%cSucceeded converting to DLS Articulator!", consoleColors.recognized);
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
else
|
|
128
|
-
{
|
|
129
|
-
SpessaSynthWarn("Failed converting to DLS Articulator!");
|
|
130
|
-
}
|
|
131
|
-
return arrs;
|
|
132
|
-
}, []);
|
|
133
|
-
/**
|
|
134
|
-
* @type {Articulator[]}
|
|
135
|
-
*/
|
|
136
|
-
const modulators = zone.modulators.reduce((arrs, m) =>
|
|
137
|
-
{
|
|
138
|
-
// do not write the default DLS modulators
|
|
139
|
-
if (
|
|
140
|
-
Modulator.isIdentical(m, DEFAULT_DLS_CHORUS, true) ||
|
|
141
|
-
Modulator.isIdentical(m, DEFAULT_DLS_REVERB, true) ||
|
|
142
|
-
Modulator.isIdentical(m, DLS_1_NO_VIBRATO_MOD, true) ||
|
|
143
|
-
Modulator.isIdentical(m, DLS_1_NO_VIBRATO_PRESSURE, true)
|
|
144
|
-
)
|
|
145
|
-
{
|
|
146
|
-
return arrs;
|
|
147
|
-
}
|
|
148
|
-
const art = getDLSArticulatorFromSf2Modulator(m);
|
|
149
|
-
if (art !== undefined)
|
|
150
|
-
{
|
|
151
|
-
arrs.push(art);
|
|
152
|
-
SpessaSynthInfo("%cSucceeded converting to DLS Articulator!", consoleColors.recognized);
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
else
|
|
156
|
-
{
|
|
157
|
-
SpessaSynthWarn("Failed converting to DLS Articulator!");
|
|
158
|
-
}
|
|
159
|
-
return arrs;
|
|
160
|
-
}, []);
|
|
161
|
-
generators.push(...modulators);
|
|
162
|
-
|
|
163
|
-
const art2Data = new IndexedByteArray(8);
|
|
164
|
-
writeDword(art2Data, 8); // cbSize
|
|
165
|
-
writeDword(art2Data, generators.length); // cbConnectionBlocks
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const out = generators.map(a => a.writeArticulator());
|
|
169
|
-
return writeRIFFOddSize(
|
|
170
|
-
"art2",
|
|
171
|
-
combineArrays([art2Data, ...out])
|
|
172
|
-
);
|
|
173
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { IndexedByteArray } from "../../../utils/indexed_array.js";
|
|
2
|
-
import { writeDword, writeWord } from "../../../utils/byte_functions/little_endian.js";
|
|
3
|
-
|
|
4
|
-
export class Articulator
|
|
5
|
-
{
|
|
6
|
-
/**
|
|
7
|
-
* @type {DLSSources}
|
|
8
|
-
*/
|
|
9
|
-
source;
|
|
10
|
-
/**
|
|
11
|
-
* @type {DLSSources}
|
|
12
|
-
*/
|
|
13
|
-
control;
|
|
14
|
-
/**
|
|
15
|
-
* @type {DLSDestinations}
|
|
16
|
-
*/
|
|
17
|
-
destination;
|
|
18
|
-
/**
|
|
19
|
-
* @type {number}
|
|
20
|
-
*/
|
|
21
|
-
scale;
|
|
22
|
-
/**
|
|
23
|
-
* @type {number}
|
|
24
|
-
*/
|
|
25
|
-
transform;
|
|
26
|
-
|
|
27
|
-
constructor(source, control, destination, scale, transform)
|
|
28
|
-
{
|
|
29
|
-
this.source = source;
|
|
30
|
-
this.control = control;
|
|
31
|
-
this.destination = destination;
|
|
32
|
-
this.scale = scale;
|
|
33
|
-
this.transform = transform;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @returns {IndexedByteArray}
|
|
38
|
-
*/
|
|
39
|
-
writeArticulator()
|
|
40
|
-
{
|
|
41
|
-
const out = new IndexedByteArray(12);
|
|
42
|
-
writeWord(out, this.source);
|
|
43
|
-
writeWord(out, this.control);
|
|
44
|
-
writeWord(out, this.destination);
|
|
45
|
-
writeWord(out, this.transform);
|
|
46
|
-
writeDword(out, this.scale << 16);
|
|
47
|
-
return out;
|
|
48
|
-
}
|
|
49
|
-
}
|