spessasynth_core 1.1.3 → 1.1.4
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/LICENSE +3 -26
- package/README.md +156 -474
- package/index.js +73 -8
- package/package.json +21 -8
- package/src/externals/fflate/LICENSE +21 -0
- package/src/externals/fflate/fflate.min.js +1 -0
- package/src/externals/stbvorbis_sync/@types/stbvorbis_sync.d.ts +12 -0
- package/src/externals/stbvorbis_sync/LICENSE +202 -0
- package/src/externals/stbvorbis_sync/NOTICE +6 -0
- package/src/externals/stbvorbis_sync/stbvorbis_sync.min.js +1 -0
- package/src/midi/README.md +32 -0
- package/src/midi/basic_midi.js +567 -0
- package/src/midi/midi_builder.js +202 -0
- package/src/midi/midi_loader.js +324 -0
- package/{spessasynth_core/midi_parser → src/midi}/midi_message.js +58 -35
- package/src/midi/midi_sequence.js +224 -0
- package/src/midi/midi_tools/get_note_times.js +154 -0
- package/src/midi/midi_tools/midi_editor.js +611 -0
- package/src/midi/midi_tools/midi_writer.js +99 -0
- package/src/midi/midi_tools/rmidi_writer.js +567 -0
- package/src/midi/midi_tools/used_keys_loaded.js +238 -0
- package/src/midi/xmf_loader.js +454 -0
- package/src/sequencer/README.md +5 -0
- package/src/sequencer/events.js +81 -0
- package/src/sequencer/play.js +349 -0
- package/src/sequencer/process_event.js +165 -0
- package/{spessasynth_core/sequencer/worklet_sequencer → src/sequencer}/process_tick.js +103 -84
- package/src/sequencer/sequencer_engine.js +367 -0
- package/src/sequencer/song_control.js +201 -0
- package/src/soundfont/README.md +13 -0
- package/src/soundfont/basic_soundfont/basic_instrument.js +77 -0
- package/src/soundfont/basic_soundfont/basic_preset.js +336 -0
- package/src/soundfont/basic_soundfont/basic_sample.js +206 -0
- package/src/soundfont/basic_soundfont/basic_soundfont.js +565 -0
- package/src/soundfont/basic_soundfont/basic_zone.js +64 -0
- package/src/soundfont/basic_soundfont/basic_zones.js +43 -0
- package/src/soundfont/basic_soundfont/generator.js +220 -0
- package/src/soundfont/basic_soundfont/modulator.js +378 -0
- package/src/soundfont/basic_soundfont/riff_chunk.js +149 -0
- package/src/soundfont/basic_soundfont/write_dls/art2.js +173 -0
- package/src/soundfont/basic_soundfont/write_dls/articulator.js +49 -0
- package/src/soundfont/basic_soundfont/write_dls/combine_zones.js +400 -0
- package/src/soundfont/basic_soundfont/write_dls/ins.js +103 -0
- package/src/soundfont/basic_soundfont/write_dls/lins.js +18 -0
- package/src/soundfont/basic_soundfont/write_dls/modulator_converter.js +330 -0
- package/src/soundfont/basic_soundfont/write_dls/rgn2.js +121 -0
- package/src/soundfont/basic_soundfont/write_dls/wave.js +94 -0
- package/src/soundfont/basic_soundfont/write_dls/write_dls.js +119 -0
- package/src/soundfont/basic_soundfont/write_dls/wsmp.js +78 -0
- package/src/soundfont/basic_soundfont/write_dls/wvpl.js +32 -0
- package/src/soundfont/basic_soundfont/write_sf2/ibag.js +39 -0
- package/src/soundfont/basic_soundfont/write_sf2/igen.js +80 -0
- package/src/soundfont/basic_soundfont/write_sf2/imod.js +46 -0
- package/src/soundfont/basic_soundfont/write_sf2/inst.js +34 -0
- package/src/soundfont/basic_soundfont/write_sf2/pbag.js +39 -0
- package/src/soundfont/basic_soundfont/write_sf2/pgen.js +82 -0
- package/src/soundfont/basic_soundfont/write_sf2/phdr.js +42 -0
- package/src/soundfont/basic_soundfont/write_sf2/pmod.js +46 -0
- package/src/soundfont/basic_soundfont/write_sf2/sdta.js +80 -0
- package/src/soundfont/basic_soundfont/write_sf2/shdr.js +55 -0
- package/src/soundfont/basic_soundfont/write_sf2/write.js +222 -0
- package/src/soundfont/dls/articulator_converter.js +396 -0
- package/src/soundfont/dls/dls_destinations.js +38 -0
- package/src/soundfont/dls/dls_preset.js +44 -0
- package/src/soundfont/dls/dls_sample.js +75 -0
- package/src/soundfont/dls/dls_soundfont.js +186 -0
- package/src/soundfont/dls/dls_sources.js +62 -0
- package/src/soundfont/dls/dls_zone.js +95 -0
- package/src/soundfont/dls/read_articulation.js +299 -0
- package/src/soundfont/dls/read_instrument.js +121 -0
- package/src/soundfont/dls/read_instrument_list.js +17 -0
- package/src/soundfont/dls/read_lart.js +35 -0
- package/src/soundfont/dls/read_region.js +152 -0
- package/src/soundfont/dls/read_samples.js +270 -0
- package/src/soundfont/load_soundfont.js +21 -0
- package/src/soundfont/read_sf2/generators.js +46 -0
- package/{spessasynth_core/soundfont/chunk → src/soundfont/read_sf2}/instruments.js +20 -14
- package/src/soundfont/read_sf2/modulators.js +36 -0
- package/src/soundfont/read_sf2/presets.js +80 -0
- package/src/soundfont/read_sf2/samples.js +304 -0
- package/src/soundfont/read_sf2/soundfont.js +305 -0
- package/{spessasynth_core/soundfont/chunk → src/soundfont/read_sf2}/zones.js +68 -69
- package/src/synthetizer/README.md +7 -0
- package/src/synthetizer/audio_engine/README.md +9 -0
- package/src/synthetizer/audio_engine/engine_components/compute_modulator.js +266 -0
- package/src/synthetizer/audio_engine/engine_components/controller_tables.js +88 -0
- package/src/synthetizer/audio_engine/engine_components/key_modifier_manager.js +150 -0
- package/{spessasynth_core/synthetizer/worklet_system/worklet_utilities → src/synthetizer/audio_engine/engine_components}/lfo.js +9 -6
- package/src/synthetizer/audio_engine/engine_components/lowpass_filter.js +282 -0
- package/src/synthetizer/audio_engine/engine_components/midi_audio_channel.js +467 -0
- package/src/synthetizer/audio_engine/engine_components/modulation_envelope.js +181 -0
- package/{spessasynth_core/synthetizer/worklet_system/worklet_utilities → src/synthetizer/audio_engine/engine_components}/modulator_curves.js +33 -30
- package/src/synthetizer/audio_engine/engine_components/soundfont_manager.js +221 -0
- package/src/synthetizer/audio_engine/engine_components/stereo_panner.js +120 -0
- package/{spessasynth_core/synthetizer/worklet_system/worklet_utilities → src/synthetizer/audio_engine/engine_components}/unit_converter.js +11 -4
- package/src/synthetizer/audio_engine/engine_components/voice.js +519 -0
- package/src/synthetizer/audio_engine/engine_components/volume_envelope.js +401 -0
- package/src/synthetizer/audio_engine/engine_components/wavetable_oscillator.js +263 -0
- package/src/synthetizer/audio_engine/engine_methods/controller_control/controller_change.js +132 -0
- package/src/synthetizer/audio_engine/engine_methods/controller_control/master_parameters.js +48 -0
- package/src/synthetizer/audio_engine/engine_methods/controller_control/reset_controllers.js +241 -0
- package/src/synthetizer/audio_engine/engine_methods/create_midi_channel.js +27 -0
- package/src/synthetizer/audio_engine/engine_methods/data_entry/data_entry_coarse.js +253 -0
- package/src/synthetizer/audio_engine/engine_methods/data_entry/data_entry_fine.js +66 -0
- package/src/synthetizer/audio_engine/engine_methods/mute_channel.js +17 -0
- package/src/synthetizer/audio_engine/engine_methods/note_on.js +175 -0
- package/src/synthetizer/audio_engine/engine_methods/portamento_time.js +92 -0
- package/src/synthetizer/audio_engine/engine_methods/program_change.js +61 -0
- package/src/synthetizer/audio_engine/engine_methods/render_voice.js +196 -0
- package/src/synthetizer/audio_engine/engine_methods/soundfont_management/clear_sound_font.js +30 -0
- package/src/synthetizer/audio_engine/engine_methods/soundfont_management/get_preset.js +22 -0
- package/src/synthetizer/audio_engine/engine_methods/soundfont_management/reload_sound_font.js +28 -0
- package/src/synthetizer/audio_engine/engine_methods/soundfont_management/send_preset_list.js +31 -0
- package/src/synthetizer/audio_engine/engine_methods/soundfont_management/set_embedded_sound_font.js +21 -0
- package/src/synthetizer/audio_engine/engine_methods/stopping_notes/kill_note.js +20 -0
- package/src/synthetizer/audio_engine/engine_methods/stopping_notes/note_off.js +55 -0
- package/src/synthetizer/audio_engine/engine_methods/stopping_notes/stop_all_channels.js +16 -0
- package/src/synthetizer/audio_engine/engine_methods/stopping_notes/stop_all_notes.js +30 -0
- package/src/synthetizer/audio_engine/engine_methods/stopping_notes/voice_killing.js +63 -0
- package/src/synthetizer/audio_engine/engine_methods/system_exclusive.js +776 -0
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/channel_pressure.js +24 -0
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/pitch_wheel.js +33 -0
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/poly_pressure.js +31 -0
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/set_master_tuning.js +15 -0
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/set_modulation_depth.js +27 -0
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/set_octave_tuning.js +19 -0
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/set_tuning.js +27 -0
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/transpose_all_channels.js +15 -0
- package/src/synthetizer/audio_engine/engine_methods/tuning_control/transpose_channel.js +34 -0
- package/src/synthetizer/audio_engine/main_processor.js +804 -0
- package/src/synthetizer/audio_engine/snapshot/apply_synthesizer_snapshot.js +15 -0
- package/src/synthetizer/audio_engine/snapshot/channel_snapshot.js +175 -0
- package/src/synthetizer/audio_engine/snapshot/synthesizer_snapshot.js +116 -0
- package/src/synthetizer/synth_constants.js +22 -0
- package/{spessasynth_core → src}/utils/README.md +1 -0
- package/src/utils/buffer_to_wav.js +185 -0
- package/src/utils/byte_functions/big_endian.js +32 -0
- package/src/utils/byte_functions/little_endian.js +77 -0
- package/src/utils/byte_functions/string.js +107 -0
- package/src/utils/byte_functions/variable_length_quantity.js +42 -0
- package/src/utils/fill_with_defaults.js +21 -0
- package/src/utils/indexed_array.js +52 -0
- package/{spessasynth_core → src}/utils/loggin.js +70 -78
- package/src/utils/other.js +92 -0
- package/src/utils/sysex_detector.js +58 -0
- package/src/utils/xg_hacks.js +193 -0
- package/.idea/inspectionProfiles/Project_Default.xml +0 -10
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/spessasynth_core.iml +0 -12
- package/.idea/vcs.xml +0 -6
- package/spessasynth_core/midi_parser/README.md +0 -3
- package/spessasynth_core/midi_parser/midi_loader.js +0 -386
- package/spessasynth_core/sequencer/sequencer.js +0 -202
- package/spessasynth_core/sequencer/worklet_sequencer/play.js +0 -209
- package/spessasynth_core/sequencer/worklet_sequencer/process_event.js +0 -120
- package/spessasynth_core/sequencer/worklet_sequencer/song_control.js +0 -112
- package/spessasynth_core/soundfont/README.md +0 -4
- package/spessasynth_core/soundfont/chunk/generators.js +0 -205
- package/spessasynth_core/soundfont/chunk/modulators.js +0 -232
- package/spessasynth_core/soundfont/chunk/presets.js +0 -264
- package/spessasynth_core/soundfont/chunk/riff_chunk.js +0 -46
- package/spessasynth_core/soundfont/chunk/samples.js +0 -250
- package/spessasynth_core/soundfont/soundfont_parser.js +0 -301
- package/spessasynth_core/synthetizer/README.md +0 -6
- package/spessasynth_core/synthetizer/synthesizer.js +0 -313
- package/spessasynth_core/synthetizer/worklet_system/README.md +0 -3
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/controller_control.js +0 -290
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/data_entry.js +0 -280
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/note_off.js +0 -102
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/note_on.js +0 -77
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/program_control.js +0 -140
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/system_exclusive.js +0 -266
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/tuning_control.js +0 -104
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/vibrato_control.js +0 -29
- package/spessasynth_core/synthetizer/worklet_system/worklet_methods/voice_control.js +0 -223
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/lowpass_filter.js +0 -133
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/modulation_envelope.js +0 -73
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/stereo_panner.js +0 -76
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/volume_envelope.js +0 -272
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/wavetable_oscillator.js +0 -83
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/worklet_modulator.js +0 -175
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.js +0 -106
- package/spessasynth_core/synthetizer/worklet_system/worklet_utilities/worklet_voice.js +0 -285
- package/spessasynth_core/utils/buffer_to_wav.js +0 -70
- package/spessasynth_core/utils/byte_functions.js +0 -141
- package/spessasynth_core/utils/other.js +0 -49
- package/spessasynth_core/utils/shiftable_array.js +0 -26
- package/spessasynth_core/utils/stbvorbis_sync.js +0 -1877
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { BasicSample } from "../basic_soundfont/basic_sample.js";
|
|
2
|
+
|
|
3
|
+
export class DLSSample extends BasicSample
|
|
4
|
+
{
|
|
5
|
+
/**
|
|
6
|
+
* in decibels of attenuation, WITHOUT EMU CORRECTION
|
|
7
|
+
* @type {number}
|
|
8
|
+
*/
|
|
9
|
+
sampleDbAttenuation;
|
|
10
|
+
/**
|
|
11
|
+
* @type {Float32Array}
|
|
12
|
+
*/
|
|
13
|
+
sampleData;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param name {string}
|
|
17
|
+
* @param rate {number}
|
|
18
|
+
* @param pitch {number}
|
|
19
|
+
* @param pitchCorrection {number}
|
|
20
|
+
* @param loopStart {number} sample data points
|
|
21
|
+
* @param loopEnd {number} sample data points
|
|
22
|
+
* @param data {Float32Array}
|
|
23
|
+
* @param sampleDbAttenuation {number} in db
|
|
24
|
+
*/
|
|
25
|
+
constructor(
|
|
26
|
+
name,
|
|
27
|
+
rate,
|
|
28
|
+
pitch,
|
|
29
|
+
pitchCorrection,
|
|
30
|
+
loopStart,
|
|
31
|
+
loopEnd,
|
|
32
|
+
data,
|
|
33
|
+
sampleDbAttenuation
|
|
34
|
+
)
|
|
35
|
+
{
|
|
36
|
+
super(
|
|
37
|
+
name,
|
|
38
|
+
rate,
|
|
39
|
+
pitch,
|
|
40
|
+
pitchCorrection,
|
|
41
|
+
0,
|
|
42
|
+
1,
|
|
43
|
+
loopStart,
|
|
44
|
+
loopEnd
|
|
45
|
+
);
|
|
46
|
+
this.sampleData = data;
|
|
47
|
+
this.sampleDbAttenuation = sampleDbAttenuation;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getAudioData()
|
|
51
|
+
{
|
|
52
|
+
return this.sampleData;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getRawData()
|
|
56
|
+
{
|
|
57
|
+
if (this.isCompressed)
|
|
58
|
+
{
|
|
59
|
+
if (!this.compressedData)
|
|
60
|
+
{
|
|
61
|
+
throw new Error("Compressed but no data?? This shouldn't happen!!");
|
|
62
|
+
}
|
|
63
|
+
return this.compressedData;
|
|
64
|
+
}
|
|
65
|
+
return super.getRawData();
|
|
66
|
+
// const uint8 = new Uint8Array(this.sampleData.length * 2);
|
|
67
|
+
// for (let i = 0; i < this.sampleData.length; i++)
|
|
68
|
+
// {
|
|
69
|
+
// const sample = Math.floor(this.sampleData[i] * 32768);
|
|
70
|
+
// uint8[i * 2] = sample & 0xFF; // lower byte
|
|
71
|
+
// uint8[i * 2 + 1] = (sample >> 8) & 0xFF; // upper byte
|
|
72
|
+
// }
|
|
73
|
+
// return uint8;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { BasicSoundBank } from "../basic_soundfont/basic_soundfont.js";
|
|
2
|
+
import { IndexedByteArray } from "../../utils/indexed_array.js";
|
|
3
|
+
import { SpessaSynthGroup, SpessaSynthGroupEnd, SpessaSynthInfo } from "../../utils/loggin.js";
|
|
4
|
+
import { consoleColors } from "../../utils/other.js";
|
|
5
|
+
import { findRIFFListType, readRIFFChunk } from "../basic_soundfont/riff_chunk.js";
|
|
6
|
+
import { readBytesAsString } from "../../utils/byte_functions/string.js";
|
|
7
|
+
import { readLittleEndian } from "../../utils/byte_functions/little_endian.js";
|
|
8
|
+
import { readDLSInstrumentList } from "./read_instrument_list.js";
|
|
9
|
+
import { readDLSInstrument } from "./read_instrument.js";
|
|
10
|
+
import { readLart } from "./read_lart.js";
|
|
11
|
+
import { readRegion } from "./read_region.js";
|
|
12
|
+
import { readDLSSamples } from "./read_samples.js";
|
|
13
|
+
|
|
14
|
+
class DLSSoundFont extends BasicSoundBank
|
|
15
|
+
{
|
|
16
|
+
/**
|
|
17
|
+
* Loads a new DLS (Downloadable sounds) soundfont
|
|
18
|
+
* @param buffer {ArrayBuffer}
|
|
19
|
+
*/
|
|
20
|
+
constructor(buffer)
|
|
21
|
+
{
|
|
22
|
+
super();
|
|
23
|
+
this.dataArray = new IndexedByteArray(buffer);
|
|
24
|
+
SpessaSynthGroup("%cParsing DLS...", consoleColors.info);
|
|
25
|
+
if (!this.dataArray)
|
|
26
|
+
{
|
|
27
|
+
SpessaSynthGroupEnd();
|
|
28
|
+
this.parsingError("No data provided!");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// read the main chunk
|
|
32
|
+
let firstChunk = readRIFFChunk(this.dataArray, false);
|
|
33
|
+
this.verifyHeader(firstChunk, "riff");
|
|
34
|
+
this.verifyText(readBytesAsString(this.dataArray, 4).toLowerCase(), "dls ");
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Read the list
|
|
38
|
+
* @type {RiffChunk[]}
|
|
39
|
+
*/
|
|
40
|
+
const chunks = [];
|
|
41
|
+
while (this.dataArray.currentIndex < this.dataArray.length)
|
|
42
|
+
{
|
|
43
|
+
chunks.push(readRIFFChunk(this.dataArray));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// mandatory
|
|
47
|
+
this.soundFontInfo["ifil"] = "2.1"; // always for dls
|
|
48
|
+
this.soundFontInfo["isng"] = "EMU8000";
|
|
49
|
+
|
|
50
|
+
// set some defaults
|
|
51
|
+
this.soundFontInfo["INAM"] = "Unnamed DLS";
|
|
52
|
+
this.soundFontInfo["IENG"] = "Unknown";
|
|
53
|
+
this.soundFontInfo["IPRD"] = "SpessaSynth DLS";
|
|
54
|
+
this.soundFontInfo["ICRD"] = new Date().toDateString();
|
|
55
|
+
|
|
56
|
+
// read info
|
|
57
|
+
const infoChunk = findRIFFListType(chunks, "INFO");
|
|
58
|
+
if (infoChunk)
|
|
59
|
+
{
|
|
60
|
+
while (infoChunk.chunkData.currentIndex < infoChunk.chunkData.length)
|
|
61
|
+
{
|
|
62
|
+
const infoPart = readRIFFChunk(infoChunk.chunkData);
|
|
63
|
+
this.soundFontInfo[infoPart.header] = readBytesAsString(infoPart.chunkData, infoPart.size);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
this.soundFontInfo["ICMT"] = this.soundFontInfo["ICMT"] || "(No description)";
|
|
67
|
+
if (this.soundFontInfo["ISBJ"])
|
|
68
|
+
{
|
|
69
|
+
// merge it
|
|
70
|
+
this.soundFontInfo["ICMT"] += "\n" + this.soundFontInfo["ISBJ"];
|
|
71
|
+
delete this.soundFontInfo["ISBJ"];
|
|
72
|
+
}
|
|
73
|
+
this.soundFontInfo["ICMT"] += "\nConverted from DLS to SF2 with SpessaSynth";
|
|
74
|
+
|
|
75
|
+
for (const [info, value] of Object.entries(this.soundFontInfo))
|
|
76
|
+
{
|
|
77
|
+
SpessaSynthInfo(
|
|
78
|
+
`%c"${info}": %c"${value}"`,
|
|
79
|
+
consoleColors.info,
|
|
80
|
+
consoleColors.recognized
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// read "colh"
|
|
85
|
+
let colhChunk = chunks.find(c => c.header === "colh");
|
|
86
|
+
if (!colhChunk)
|
|
87
|
+
{
|
|
88
|
+
SpessaSynthGroupEnd();
|
|
89
|
+
this.parsingError("No colh chunk!");
|
|
90
|
+
}
|
|
91
|
+
this.instrumentAmount = readLittleEndian(colhChunk.chunkData, 4);
|
|
92
|
+
SpessaSynthInfo(
|
|
93
|
+
`%cInstruments amount: %c${this.instrumentAmount}`,
|
|
94
|
+
consoleColors.info,
|
|
95
|
+
consoleColors.recognized
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
// read the wave list
|
|
99
|
+
let waveListChunk = findRIFFListType(chunks, "wvpl");
|
|
100
|
+
if (!waveListChunk)
|
|
101
|
+
{
|
|
102
|
+
SpessaSynthGroupEnd();
|
|
103
|
+
this.parsingError("No wvpl chunk!");
|
|
104
|
+
}
|
|
105
|
+
this.readDLSSamples(waveListChunk);
|
|
106
|
+
|
|
107
|
+
// read the instrument list
|
|
108
|
+
let instrumentListChunk = findRIFFListType(chunks, "lins");
|
|
109
|
+
if (!instrumentListChunk)
|
|
110
|
+
{
|
|
111
|
+
SpessaSynthGroupEnd();
|
|
112
|
+
this.parsingError("No lins chunk!");
|
|
113
|
+
}
|
|
114
|
+
this.readDLSInstrumentList(instrumentListChunk);
|
|
115
|
+
|
|
116
|
+
// sort presets
|
|
117
|
+
this.presets.sort((a, b) => (a.program - b.program) + (a.bank - b.bank));
|
|
118
|
+
this._parseInternal();
|
|
119
|
+
SpessaSynthInfo(
|
|
120
|
+
`%cParsing finished! %c"${this.soundFontInfo["INAM"] || "UNNAMED"}"%c has %c${this.presets.length} %cpresets,
|
|
121
|
+
%c${this.instruments.length}%c instruments and %c${this.samples.length}%c samples.`,
|
|
122
|
+
consoleColors.info,
|
|
123
|
+
consoleColors.recognized,
|
|
124
|
+
consoleColors.info,
|
|
125
|
+
consoleColors.recognized,
|
|
126
|
+
consoleColors.info,
|
|
127
|
+
consoleColors.recognized,
|
|
128
|
+
consoleColors.info,
|
|
129
|
+
consoleColors.recognized,
|
|
130
|
+
consoleColors.info
|
|
131
|
+
);
|
|
132
|
+
SpessaSynthGroupEnd();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @param chunk {RiffChunk}
|
|
137
|
+
* @param expected {string}
|
|
138
|
+
*/
|
|
139
|
+
verifyHeader(chunk, ...expected)
|
|
140
|
+
{
|
|
141
|
+
for (const expect of expected)
|
|
142
|
+
{
|
|
143
|
+
if (chunk.header.toLowerCase() === expect.toLowerCase())
|
|
144
|
+
{
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
SpessaSynthGroupEnd();
|
|
149
|
+
this.parsingError(`Invalid DLS chunk header! Expected "${expected.toString()}" got "${chunk.header.toLowerCase()}"`);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @param text {string}
|
|
154
|
+
* @param expected {string}
|
|
155
|
+
*/
|
|
156
|
+
verifyText(text, expected)
|
|
157
|
+
{
|
|
158
|
+
if (text.toLowerCase() !== expected.toLowerCase())
|
|
159
|
+
{
|
|
160
|
+
SpessaSynthGroupEnd();
|
|
161
|
+
this.parsingError(`FourCC error: Expected "${expected.toLowerCase()}" got "${text.toLowerCase()}"`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @param error {string}
|
|
167
|
+
*/
|
|
168
|
+
parsingError(error)
|
|
169
|
+
{
|
|
170
|
+
throw new Error(`DLS parse error: ${error} The file may be corrupted.`);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
destroySoundBank()
|
|
174
|
+
{
|
|
175
|
+
super.destroySoundBank();
|
|
176
|
+
delete this.dataArray;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
DLSSoundFont.prototype.readDLSInstrumentList = readDLSInstrumentList;
|
|
181
|
+
DLSSoundFont.prototype.readDLSInstrument = readDLSInstrument;
|
|
182
|
+
DLSSoundFont.prototype.readRegion = readRegion;
|
|
183
|
+
DLSSoundFont.prototype.readLart = readLart;
|
|
184
|
+
DLSSoundFont.prototype.readDLSSamples = readDLSSamples;
|
|
185
|
+
|
|
186
|
+
export { DLSSoundFont };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Modulator } from "../basic_soundfont/modulator.js";
|
|
2
|
+
import { generatorTypes } from "../basic_soundfont/generator.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @enum {number}
|
|
6
|
+
*/
|
|
7
|
+
export const DLSSources = {
|
|
8
|
+
none: 0x0,
|
|
9
|
+
modLfo: 0x1,
|
|
10
|
+
velocity: 0x2,
|
|
11
|
+
keyNum: 0x3,
|
|
12
|
+
volEnv: 0x4,
|
|
13
|
+
modEnv: 0x5,
|
|
14
|
+
pitchWheel: 0x6,
|
|
15
|
+
polyPressure: 0x7,
|
|
16
|
+
channelPressure: 0x8,
|
|
17
|
+
vibratoLfo: 0x9,
|
|
18
|
+
|
|
19
|
+
modulationWheel: 0x81,
|
|
20
|
+
volume: 0x87,
|
|
21
|
+
pan: 0x8a,
|
|
22
|
+
expression: 0x8b,
|
|
23
|
+
// note: these are flipped unintentionally in DLS2 table 9. Argh!
|
|
24
|
+
chorus: 0xdd,
|
|
25
|
+
reverb: 0xdb,
|
|
26
|
+
|
|
27
|
+
pitchWheelRange: 0x100,
|
|
28
|
+
fineTune: 0x101,
|
|
29
|
+
coarseTune: 0x102
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const DEFAULT_DLS_REVERB = new Modulator(
|
|
33
|
+
0x00DB,
|
|
34
|
+
0x0,
|
|
35
|
+
generatorTypes.reverbEffectsSend,
|
|
36
|
+
1000,
|
|
37
|
+
0
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
export const DEFAULT_DLS_CHORUS = new Modulator(
|
|
41
|
+
0x00DD,
|
|
42
|
+
0x0,
|
|
43
|
+
generatorTypes.chorusEffectsSend,
|
|
44
|
+
1000,
|
|
45
|
+
0
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
export const DLS_1_NO_VIBRATO_MOD = new Modulator(
|
|
49
|
+
0x0081,
|
|
50
|
+
0x0,
|
|
51
|
+
generatorTypes.vibLfoToPitch,
|
|
52
|
+
0,
|
|
53
|
+
0
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
export const DLS_1_NO_VIBRATO_PRESSURE = new Modulator(
|
|
57
|
+
0x000D,
|
|
58
|
+
0x0,
|
|
59
|
+
generatorTypes.vibLfoToPitch,
|
|
60
|
+
0,
|
|
61
|
+
0
|
|
62
|
+
);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { BasicInstrumentZone } from "../basic_soundfont/basic_zones.js";
|
|
2
|
+
import { Generator, generatorTypes } from "../basic_soundfont/generator.js";
|
|
3
|
+
|
|
4
|
+
export class DLSZone extends BasicInstrumentZone
|
|
5
|
+
{
|
|
6
|
+
/**
|
|
7
|
+
* @param keyRange {SoundFontRange}
|
|
8
|
+
* @param velRange {SoundFontRange}
|
|
9
|
+
*/
|
|
10
|
+
constructor(keyRange, velRange)
|
|
11
|
+
{
|
|
12
|
+
super();
|
|
13
|
+
this.keyRange = keyRange;
|
|
14
|
+
this.velRange = velRange;
|
|
15
|
+
this.isGlobal = true;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param attenuationCb {number} with EMU correction
|
|
20
|
+
* @param loopingMode {number} the sfont one
|
|
21
|
+
* @param loop {{start: number, end: number}}
|
|
22
|
+
* @param sampleKey {number}
|
|
23
|
+
* @param sample {BasicSample}
|
|
24
|
+
* @param sampleID {number}
|
|
25
|
+
* @param samplePitchCorrection {number} cents
|
|
26
|
+
*/
|
|
27
|
+
setWavesample(
|
|
28
|
+
attenuationCb,
|
|
29
|
+
loopingMode,
|
|
30
|
+
loop,
|
|
31
|
+
sampleKey,
|
|
32
|
+
sample,
|
|
33
|
+
sampleID,
|
|
34
|
+
samplePitchCorrection
|
|
35
|
+
)
|
|
36
|
+
{
|
|
37
|
+
if (loopingMode !== 0)
|
|
38
|
+
{
|
|
39
|
+
this.generators.push(new Generator(generatorTypes.sampleModes, loopingMode));
|
|
40
|
+
}
|
|
41
|
+
this.generators.push(new Generator(generatorTypes.initialAttenuation, attenuationCb));
|
|
42
|
+
this.isGlobal = false;
|
|
43
|
+
|
|
44
|
+
// correct tuning if needed
|
|
45
|
+
samplePitchCorrection -= sample.samplePitchCorrection;
|
|
46
|
+
const coarseTune = Math.trunc(samplePitchCorrection / 100);
|
|
47
|
+
if (coarseTune !== 0)
|
|
48
|
+
{
|
|
49
|
+
this.generators.push(new Generator(generatorTypes.coarseTune, coarseTune));
|
|
50
|
+
}
|
|
51
|
+
const fineTune = samplePitchCorrection - (coarseTune * 100);
|
|
52
|
+
if (fineTune !== 0)
|
|
53
|
+
{
|
|
54
|
+
this.generators.push(new Generator(generatorTypes.fineTune, fineTune));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// correct loop if needed
|
|
58
|
+
if (loopingMode !== 0)
|
|
59
|
+
{
|
|
60
|
+
const diffStart = loop.start - sample.sampleLoopStartIndex;
|
|
61
|
+
const diffEnd = loop.end - sample.sampleLoopEndIndex;
|
|
62
|
+
if (diffStart !== 0)
|
|
63
|
+
{
|
|
64
|
+
const fine = diffStart % 32768;
|
|
65
|
+
this.generators.push(new Generator(generatorTypes.startloopAddrsOffset, fine));
|
|
66
|
+
// coarse generator uses 32768 samples per step
|
|
67
|
+
const coarse = Math.trunc(diffStart / 32768);
|
|
68
|
+
if (coarse !== 0)
|
|
69
|
+
{
|
|
70
|
+
this.generators.push(new Generator(generatorTypes.startloopAddrsCoarseOffset, coarse));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (diffEnd !== 0)
|
|
74
|
+
{
|
|
75
|
+
const fine = diffEnd % 32768;
|
|
76
|
+
this.generators.push(new Generator(generatorTypes.endloopAddrsOffset, fine));
|
|
77
|
+
// coarse generator uses 32768 samples per step
|
|
78
|
+
const coarse = Math.trunc(diffEnd / 32768);
|
|
79
|
+
if (coarse !== 0)
|
|
80
|
+
{
|
|
81
|
+
this.generators.push(new Generator(generatorTypes.endloopAddrsCoarseOffset, coarse));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// correct the key if needed
|
|
86
|
+
if (sampleKey !== sample.samplePitch)
|
|
87
|
+
{
|
|
88
|
+
this.generators.push(new Generator(generatorTypes.overridingRootKey, sampleKey));
|
|
89
|
+
}
|
|
90
|
+
// add sample ID
|
|
91
|
+
this.generators.push(new Generator(generatorTypes.sampleID, sampleID));
|
|
92
|
+
this.sample = sample;
|
|
93
|
+
sample.useCount++;
|
|
94
|
+
}
|
|
95
|
+
}
|