spessasynth_lib 3.16.4 → 3.17.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/@types/index.d.ts +5 -4
- package/@types/midi_parser/basic_midi.d.ts +125 -0
- package/@types/midi_parser/midi_builder.d.ts +69 -0
- package/@types/midi_parser/midi_data.d.ts +2 -2
- package/@types/midi_parser/midi_editor.d.ts +4 -4
- package/@types/midi_parser/midi_loader.d.ts +3 -100
- package/@types/midi_parser/midi_writer.d.ts +2 -2
- package/@types/midi_parser/rmidi_writer.d.ts +4 -3
- package/@types/midi_parser/used_keys_loaded.d.ts +2 -2
- package/@types/sequencer/sequencer.d.ts +1 -1
- package/@types/soundfont/basic_soundfont/basic_soundfont.d.ts +5 -4
- package/@types/soundfont/basic_soundfont/write_sf2/soundfont_trimmer.d.ts +2 -2
- package/@types/soundfont/dls/dls_preset.d.ts +11 -0
- package/@types/soundfont/dls/dls_soundfont.d.ts +24 -0
- package/@types/soundfont/dls/read_instrument.d.ts +5 -0
- package/@types/soundfont/dls/read_instrument_list.d.ts +5 -0
- package/@types/soundfont/load_soundfont.d.ts +6 -0
- package/@types/soundfont/soundfont.d.ts +2 -1
- package/@types/synthetizer/synthetizer.d.ts +2 -2
- package/@types/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.d.ts +2 -2
- package/@types/utils/byte_functions/little_endian.d.ts +1 -1
- package/README.md +17 -15
- package/index.js +6 -4
- package/midi_parser/basic_midi.js +146 -0
- package/midi_parser/midi_builder.js +281 -0
- package/midi_parser/midi_data.js +1 -1
- package/midi_parser/midi_editor.js +2 -2
- package/midi_parser/midi_loader.js +17 -53
- package/midi_parser/midi_writer.js +1 -1
- package/midi_parser/rmidi_writer.js +227 -246
- package/midi_parser/used_keys_loaded.js +1 -1
- package/package.json +1 -1
- package/sequencer/sequencer.js +1 -1
- package/sequencer/worklet_sequencer/song_control.js +3 -3
- package/sequencer/worklet_sequencer/worklet_sequencer.js +1 -1
- package/soundfont/basic_soundfont/basic_soundfont.js +25 -10
- package/soundfont/basic_soundfont/riff_chunk.js +2 -2
- package/soundfont/basic_soundfont/write_sf2/soundfont_trimmer.js +1 -1
- package/soundfont/dls/dls_preset.js +25 -0
- package/soundfont/dls/dls_soundfont.js +93 -0
- package/soundfont/dls/read_instrument.js +22 -0
- package/soundfont/dls/read_instrument_list.js +17 -0
- package/soundfont/load_soundfont.js +21 -0
- package/soundfont/read_sf2/instruments.js +2 -2
- package/soundfont/read_sf2/modulators.js +5 -5
- package/soundfont/read_sf2/presets.js +7 -7
- package/soundfont/read_sf2/samples.js +8 -8
- package/soundfont/read_sf2/zones.js +5 -5
- package/soundfont/soundfont.js +8 -3
- package/synthetizer/synthetizer.js +1 -1
- package/synthetizer/worklet_processor.min.js +7 -6
- package/synthetizer/worklet_system/main_processor.js +1 -2
- package/synthetizer/worklet_system/worklet_methods/program_control.js +12 -20
- package/synthetizer/worklet_system/worklet_methods/worklet_soundfont_manager/worklet_soundfont_manager.js +5 -5
- package/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.js +1 -1
- package/utils/byte_functions/little_endian.js +1 -1
- /package/@types/{midi_handler → external_midi}/midi_handler.d.ts +0 -0
- /package/@types/{midi_handler → external_midi}/web_midi_link.d.ts +0 -0
- /package/{midi_handler → external_midi}/README.md +0 -0
- /package/{midi_handler → external_midi}/midi_handler.js +0 -0
- /package/{midi_handler → external_midi}/web_midi_link.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IndexedByteArray } from '../../utils/indexed_array.js'
|
|
2
|
-
import {
|
|
2
|
+
import { readLittleEndian, writeDword } from '../../utils/byte_functions/little_endian.js'
|
|
3
3
|
import { readBytesAsString, writeStringAsBytes } from '../../utils/byte_functions/string.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -33,7 +33,7 @@ export class RiffChunk
|
|
|
33
33
|
export function readRIFFChunk(dataArray, readData = true, forceShift = false) {
|
|
34
34
|
let header = readBytesAsString(dataArray, 4)
|
|
35
35
|
|
|
36
|
-
let size =
|
|
36
|
+
let size = readLittleEndian(dataArray, 4)
|
|
37
37
|
let chunkData = undefined
|
|
38
38
|
if (readData)
|
|
39
39
|
{
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BasicPreset } from '../basic_soundfont/basic_preset.js'
|
|
2
|
+
|
|
3
|
+
export class DLSPreset extends BasicPreset
|
|
4
|
+
{
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new DLS preset
|
|
7
|
+
* @param ulBank {number} the ULONG value
|
|
8
|
+
* @param ulInstrument {number} the ULONG value
|
|
9
|
+
* @param regionsAmount {number}
|
|
10
|
+
*/
|
|
11
|
+
constructor(ulBank, ulInstrument, regionsAmount)
|
|
12
|
+
{
|
|
13
|
+
super();
|
|
14
|
+
this.regionsAmount = regionsAmount;
|
|
15
|
+
this.program = ulInstrument & 127;
|
|
16
|
+
this.bank = (ulBank >> 8) & 127;
|
|
17
|
+
const isDrums = ulInstrument & (1 << 31);
|
|
18
|
+
if(isDrums)
|
|
19
|
+
{
|
|
20
|
+
console.log("DEUMS")
|
|
21
|
+
}
|
|
22
|
+
console.log(this.bank, this.program)
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { BasicSoundFont } 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 { 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
|
+
|
|
11
|
+
class DLSSoundFont extends BasicSoundFont
|
|
12
|
+
{
|
|
13
|
+
/**
|
|
14
|
+
* Loads a new DLS (Downloadable sounds) soundfont
|
|
15
|
+
* @param buffer {ArrayBuffer}
|
|
16
|
+
*/
|
|
17
|
+
constructor(buffer)
|
|
18
|
+
{
|
|
19
|
+
super();
|
|
20
|
+
this.dataArray = new IndexedByteArray(buffer);
|
|
21
|
+
SpessaSynthGroup("%cParsing DLS...", consoleColors.info);
|
|
22
|
+
if(!this.dataArray)
|
|
23
|
+
{
|
|
24
|
+
SpessaSynthGroupEnd();
|
|
25
|
+
throw new TypeError("No data!");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
this.soundFontInfo["ifil"] = "2.1"; // always for dls
|
|
29
|
+
|
|
30
|
+
// read the main chunk
|
|
31
|
+
let firstChunk = readRIFFChunk(this.dataArray, false);
|
|
32
|
+
this.verifyHeader(firstChunk, "riff");
|
|
33
|
+
this.verifyText(readBytesAsString(this.dataArray,4).toLowerCase(), "dls ");
|
|
34
|
+
|
|
35
|
+
// read until we reach "colh"
|
|
36
|
+
let colhChunk = readRIFFChunk(this.dataArray);
|
|
37
|
+
while(colhChunk.header !== "colh")
|
|
38
|
+
{
|
|
39
|
+
colhChunk = readRIFFChunk(this.dataArray);
|
|
40
|
+
}
|
|
41
|
+
this.instrumentAmount = readLittleEndian(colhChunk.chunkData, 4);
|
|
42
|
+
SpessaSynthInfo(`%cInstruments amount: %c${this.instrumentAmount}`,
|
|
43
|
+
consoleColors.info,
|
|
44
|
+
consoleColors.recognized);
|
|
45
|
+
|
|
46
|
+
// instrument list
|
|
47
|
+
this.readDLSInstrumentList(this.dataArray);
|
|
48
|
+
|
|
49
|
+
SpessaSynthInfo(`%cParsing finished! %c"desfont"%c has %c${this.presets.length} %cpresets,
|
|
50
|
+
%c${this.instruments.length}%c instruments and %c${this.samples.length}%c samples.`,
|
|
51
|
+
consoleColors.info,
|
|
52
|
+
consoleColors.recognized,
|
|
53
|
+
consoleColors.info,
|
|
54
|
+
consoleColors.recognized,
|
|
55
|
+
consoleColors.info,
|
|
56
|
+
consoleColors.recognized,
|
|
57
|
+
consoleColors.info,
|
|
58
|
+
consoleColors.recognized,
|
|
59
|
+
consoleColors.info);
|
|
60
|
+
SpessaSynthGroupEnd();
|
|
61
|
+
throw new Error("Not implemented yet...")
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @param chunk {RiffChunk}
|
|
66
|
+
* @param expected {string}
|
|
67
|
+
*/
|
|
68
|
+
verifyHeader(chunk, expected)
|
|
69
|
+
{
|
|
70
|
+
if(chunk.header.toLowerCase() !== expected.toLowerCase())
|
|
71
|
+
{
|
|
72
|
+
SpessaSynthGroupEnd();
|
|
73
|
+
throw new SyntaxError(`Invalid DLS chunk header! Expected "${expected.toLowerCase()}" got "${chunk.header.toLowerCase()}"`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param text {string}
|
|
79
|
+
* @param expected {string}
|
|
80
|
+
*/
|
|
81
|
+
verifyText(text, expected)
|
|
82
|
+
{
|
|
83
|
+
if(text.toLowerCase() !== expected.toLowerCase())
|
|
84
|
+
{
|
|
85
|
+
SpessaSynthGroupEnd();
|
|
86
|
+
throw new SyntaxError(`Invalid DLS soundfont! Expected "${expected.toLowerCase()}" got "${text.toLowerCase()}"`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
DLSSoundFont.prototype.readDLSInstrumentList = readDLSInstrumentList;
|
|
91
|
+
DLSSoundFont.prototype.readDLSInstrument = readDLSInstrument;
|
|
92
|
+
|
|
93
|
+
export {DLSSoundFont}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { readBytesAsString } from '../../utils/byte_functions/string.js'
|
|
2
|
+
import { readLittleEndian } from '../../utils/byte_functions/little_endian.js'
|
|
3
|
+
import { DLSPreset } from './dls_preset.js'
|
|
4
|
+
import { readRIFFChunk } from '../basic_soundfont/riff_chunk.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @this {DLSSoundFont}
|
|
8
|
+
* @param chunk {RiffChunk}
|
|
9
|
+
*/
|
|
10
|
+
export function readDLSInstrument(chunk)
|
|
11
|
+
{
|
|
12
|
+
this.verifyHeader(chunk, "LIST");
|
|
13
|
+
this.verifyText(readBytesAsString(chunk.chunkData, 4), "ins ");
|
|
14
|
+
|
|
15
|
+
const instrumentHeader = readRIFFChunk(chunk.chunkData);
|
|
16
|
+
this.verifyHeader(instrumentHeader, "insh");
|
|
17
|
+
|
|
18
|
+
const regions = readLittleEndian(instrumentHeader.chunkData, 4);
|
|
19
|
+
const ulBank = readLittleEndian(instrumentHeader.chunkData, 4);
|
|
20
|
+
const ulInstrument = readLittleEndian(instrumentHeader.chunkData, 4);
|
|
21
|
+
this.presets.push(new DLSPreset(ulBank, ulInstrument, regions));
|
|
22
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { readRIFFChunk } from '../basic_soundfont/riff_chunk.js'
|
|
2
|
+
import { readBytesAsString } from '../../utils/byte_functions/string.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @this {DLSSoundFont}
|
|
6
|
+
* @param dataArray {IndexedByteArray}
|
|
7
|
+
*/
|
|
8
|
+
export function readDLSInstrumentList(dataArray)
|
|
9
|
+
{
|
|
10
|
+
const instrumentListChunk = readRIFFChunk(dataArray);
|
|
11
|
+
this.verifyHeader(instrumentListChunk, "LIST");
|
|
12
|
+
this.verifyText(readBytesAsString(instrumentListChunk.chunkData, 4), "lins");
|
|
13
|
+
for(let i = 0; i < this.instrumentAmount; i++)
|
|
14
|
+
{
|
|
15
|
+
this.readDLSInstrument(readRIFFChunk(instrumentListChunk.chunkData));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IndexedByteArray } from '../utils/indexed_array.js'
|
|
2
|
+
import { readBytesAsString } from '../utils/byte_functions/string.js'
|
|
3
|
+
import { DLSSoundFont } from './dls/dls_soundfont.js'
|
|
4
|
+
import { SoundFont2 } from './soundfont.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Loads a soundfont file
|
|
8
|
+
* @param buffer {ArrayBuffer}
|
|
9
|
+
* @returns {BasicSoundFont}
|
|
10
|
+
*/
|
|
11
|
+
export function loadSoundFont(buffer)
|
|
12
|
+
{
|
|
13
|
+
const check = buffer.slice(8, 12);
|
|
14
|
+
const a = new IndexedByteArray(check);
|
|
15
|
+
const id = readBytesAsString(a, 4, undefined, false).toLowerCase();
|
|
16
|
+
if(id === "dls ")
|
|
17
|
+
{
|
|
18
|
+
return new DLSSoundFont(buffer);
|
|
19
|
+
}
|
|
20
|
+
return new SoundFont2(buffer, false);
|
|
21
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {RiffChunk} from "../basic_soundfont/riff_chunk.js";
|
|
2
2
|
import {InstrumentZone} from "./zones.js";
|
|
3
|
-
import {
|
|
3
|
+
import {readLittleEndian} from "../../utils/byte_functions/little_endian.js";
|
|
4
4
|
import { readBytesAsString } from '../../utils/byte_functions/string.js'
|
|
5
5
|
import { BasicInstrument } from '../basic_soundfont/basic_instrument.js'
|
|
6
6
|
|
|
@@ -19,7 +19,7 @@ export class Instrument extends BasicInstrument
|
|
|
19
19
|
{
|
|
20
20
|
super();
|
|
21
21
|
this.instrumentName = readBytesAsString(instrumentChunk.chunkData, 20).trim();
|
|
22
|
-
this.instrumentZoneIndex =
|
|
22
|
+
this.instrumentZoneIndex = readLittleEndian(instrumentChunk.chunkData, 2);
|
|
23
23
|
this.instrumentZonesAmount = 0;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {signedInt16,
|
|
1
|
+
import {signedInt16, readLittleEndian} from "../../utils/byte_functions/little_endian.js";
|
|
2
2
|
import { IndexedByteArray } from '../../utils/indexed_array.js';
|
|
3
3
|
import { generatorTypes } from './generators.js'
|
|
4
4
|
import { midiControllers } from '../../midi_parser/midi_message.js'
|
|
@@ -54,11 +54,11 @@ export class Modulator{
|
|
|
54
54
|
}
|
|
55
55
|
else
|
|
56
56
|
{
|
|
57
|
-
this.modulatorSource =
|
|
58
|
-
this.modulatorDestination =
|
|
57
|
+
this.modulatorSource = readLittleEndian(dataArray, 2);
|
|
58
|
+
this.modulatorDestination = readLittleEndian(dataArray, 2);
|
|
59
59
|
this.transformAmount = signedInt16(dataArray[dataArray.currentIndex++], dataArray[dataArray.currentIndex++]);
|
|
60
|
-
this.modulationSecondarySrc =
|
|
61
|
-
this.transformType =
|
|
60
|
+
this.modulationSecondarySrc = readLittleEndian(dataArray, 2);
|
|
61
|
+
this.transformType = readLittleEndian(dataArray, 2);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
if(this.modulatorDestination > 58)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {RiffChunk} from "../basic_soundfont/riff_chunk.js";
|
|
2
2
|
import {PresetZone} from "./zones.js";
|
|
3
|
-
import {
|
|
3
|
+
import {readLittleEndian} from "../../utils/byte_functions/little_endian.js";
|
|
4
4
|
import { readBytesAsString } from '../../utils/byte_functions/string.js'
|
|
5
5
|
import { BasicPreset } from '../basic_soundfont/basic_preset.js'
|
|
6
6
|
|
|
@@ -21,14 +21,14 @@ export class Preset extends BasicPreset
|
|
|
21
21
|
.trim()
|
|
22
22
|
.replace(/\d{3}:\d{3}/, ""); // remove those pesky "000:001"
|
|
23
23
|
|
|
24
|
-
this.program =
|
|
25
|
-
this.bank =
|
|
26
|
-
this.presetZoneStartIndex =
|
|
24
|
+
this.program = readLittleEndian(presetChunk.chunkData, 2);
|
|
25
|
+
this.bank = readLittleEndian(presetChunk.chunkData, 2);
|
|
26
|
+
this.presetZoneStartIndex = readLittleEndian(presetChunk.chunkData, 2);
|
|
27
27
|
|
|
28
28
|
// read the dwords
|
|
29
|
-
this.library =
|
|
30
|
-
this.genre =
|
|
31
|
-
this.morphology =
|
|
29
|
+
this.library = readLittleEndian(presetChunk.chunkData, 4);
|
|
30
|
+
this.genre = readLittleEndian(presetChunk.chunkData, 4);
|
|
31
|
+
this.morphology = readLittleEndian(presetChunk.chunkData, 4);
|
|
32
32
|
this.presetZonesAmount = 0;
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RiffChunk } from '../basic_soundfont/riff_chunk.js'
|
|
2
2
|
import { IndexedByteArray } from '../../utils/indexed_array.js'
|
|
3
|
-
import {
|
|
3
|
+
import { readLittleEndian, signedInt8 } from '../../utils/byte_functions/little_endian.js'
|
|
4
4
|
import { stbvorbis } from '../../externals/stbvorbis_sync/stbvorbis_sync.min.js'
|
|
5
5
|
import { SpessaSynthWarn } from '../../utils/loggin.js'
|
|
6
6
|
import { readBytesAsString } from '../../utils/byte_functions/string.js'
|
|
@@ -239,19 +239,19 @@ function readSample(index, sampleHeaderData, smplArrayData, isDataRaw) {
|
|
|
239
239
|
let sampleName = readBytesAsString(sampleHeaderData, 20);
|
|
240
240
|
|
|
241
241
|
// read the sample start index
|
|
242
|
-
let sampleStartIndex =
|
|
242
|
+
let sampleStartIndex = readLittleEndian(sampleHeaderData, 4) * 2;
|
|
243
243
|
|
|
244
244
|
// read the sample end index
|
|
245
|
-
let sampleEndIndex =
|
|
245
|
+
let sampleEndIndex = readLittleEndian(sampleHeaderData, 4) * 2;
|
|
246
246
|
|
|
247
247
|
// read the sample looping start index
|
|
248
|
-
let sampleLoopStartIndex =
|
|
248
|
+
let sampleLoopStartIndex = readLittleEndian(sampleHeaderData, 4) * 2;
|
|
249
249
|
|
|
250
250
|
// read the sample looping end index
|
|
251
|
-
let sampleLoopEndIndex =
|
|
251
|
+
let sampleLoopEndIndex = readLittleEndian(sampleHeaderData, 4) * 2;
|
|
252
252
|
|
|
253
253
|
// read the sample rate
|
|
254
|
-
let sampleRate =
|
|
254
|
+
let sampleRate = readLittleEndian(sampleHeaderData, 4);
|
|
255
255
|
|
|
256
256
|
// read the original sample pitch
|
|
257
257
|
let samplePitch = sampleHeaderData[sampleHeaderData.currentIndex++];
|
|
@@ -266,8 +266,8 @@ function readSample(index, sampleHeaderData, smplArrayData, isDataRaw) {
|
|
|
266
266
|
|
|
267
267
|
|
|
268
268
|
// read the link to the other channel
|
|
269
|
-
let sampleLink =
|
|
270
|
-
let sampleType =
|
|
269
|
+
let sampleLink = readLittleEndian(sampleHeaderData, 2);
|
|
270
|
+
let sampleType = readLittleEndian(sampleHeaderData, 2);
|
|
271
271
|
|
|
272
272
|
|
|
273
273
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {readLittleEndian} from "../../utils/byte_functions/little_endian.js";
|
|
2
2
|
import {IndexedByteArray} from "../../utils/indexed_array.js";
|
|
3
3
|
import {RiffChunk} from "../basic_soundfont/riff_chunk.js";
|
|
4
4
|
import {Generator, generatorTypes} from "./generators.js";
|
|
@@ -20,8 +20,8 @@ export class InstrumentZone extends BasicInstrumentZone
|
|
|
20
20
|
constructor(dataArray)
|
|
21
21
|
{
|
|
22
22
|
super();
|
|
23
|
-
this.generatorZoneStartIndex =
|
|
24
|
-
this.modulatorZoneStartIndex =
|
|
23
|
+
this.generatorZoneStartIndex = readLittleEndian(dataArray, 2);
|
|
24
|
+
this.modulatorZoneStartIndex = readLittleEndian(dataArray, 2);
|
|
25
25
|
this.modulatorZoneSize = 0;
|
|
26
26
|
this.generatorZoneSize = 0;
|
|
27
27
|
this.isGlobal = true;
|
|
@@ -146,8 +146,8 @@ export class PresetZone extends BasicPresetZone
|
|
|
146
146
|
constructor(dataArray)
|
|
147
147
|
{
|
|
148
148
|
super();
|
|
149
|
-
this.generatorZoneStartIndex =
|
|
150
|
-
this.modulatorZoneStartIndex =
|
|
149
|
+
this.generatorZoneStartIndex = readLittleEndian(dataArray, 2);
|
|
150
|
+
this.modulatorZoneStartIndex = readLittleEndian(dataArray, 2);
|
|
151
151
|
this.modulatorZoneSize = 0;
|
|
152
152
|
this.generatorZoneSize = 0;
|
|
153
153
|
this.isGlobal = true;
|
package/soundfont/soundfont.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IndexedByteArray } from '../utils/indexed_array.js'
|
|
2
2
|
import {readSamples} from "./read_sf2/samples.js";
|
|
3
|
-
import {
|
|
3
|
+
import { readLittleEndian } from '../utils/byte_functions/little_endian.js'
|
|
4
4
|
import { readGenerators, Generator } from './read_sf2/generators.js'
|
|
5
5
|
import {readInstrumentZones, InstrumentZone, readPresetZones} from "./read_sf2/zones.js";
|
|
6
6
|
import { readPresets } from "./read_sf2/presets.js";
|
|
@@ -23,10 +23,15 @@ export class SoundFont2 extends BasicSoundFont
|
|
|
23
23
|
/**
|
|
24
24
|
* Initializes a new SoundFont2 Parser and parses the given data array
|
|
25
25
|
* @param arrayBuffer {ArrayBuffer}
|
|
26
|
+
* @param warnDeprecated {boolean}
|
|
26
27
|
*/
|
|
27
|
-
constructor(arrayBuffer)
|
|
28
|
+
constructor(arrayBuffer, warnDeprecated = true)
|
|
28
29
|
{
|
|
29
30
|
super();
|
|
31
|
+
if(warnDeprecated)
|
|
32
|
+
{
|
|
33
|
+
console.warn("Using the constructor directly is deprecated. Use loadSoundFont instead.");
|
|
34
|
+
}
|
|
30
35
|
this.dataArray = new IndexedByteArray(arrayBuffer);
|
|
31
36
|
SpessaSynthGroup("%cParsing SoundFont...", consoleColors.info);
|
|
32
37
|
if(!this.dataArray)
|
|
@@ -66,7 +71,7 @@ export class SoundFont2 extends BasicSoundFont
|
|
|
66
71
|
{
|
|
67
72
|
case "ifil":
|
|
68
73
|
case "iver":
|
|
69
|
-
text = `${
|
|
74
|
+
text = `${readLittleEndian(chunk.chunkData, 2)}.${readLittleEndian(chunk.chunkData, 2)}`;
|
|
70
75
|
break;
|
|
71
76
|
|
|
72
77
|
case "icmt":
|
|
@@ -21,7 +21,7 @@ import { SoundfontManager } from './synth_soundfont_manager.js'
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @typedef {Object} StartRenderingDataConfig
|
|
24
|
-
* @property {
|
|
24
|
+
* @property {BasicMIDI} parsedMIDI - the MIDI to render
|
|
25
25
|
* @property {SynthesizerSnapshot} snapshot - the snapshot to apply
|
|
26
26
|
* @property {boolean|undefined} oneOutput - if synth should use one output with 32 channels (2 audio channels for each midi channel). this disables chorus and reverb.
|
|
27
27
|
*/
|