spessasynth_lib 3.21.14 → 3.22.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/@types/soundfont/basic_soundfont/basic_soundfont.d.ts +4 -0
- package/package.json +1 -1
- package/sequencer/sequencer.js +1 -1
- package/sequencer/worklet_sequencer/song_control.js +1 -1
- package/soundfont/basic_soundfont/basic_soundfont.js +8 -0
- package/soundfont/dls/articulator_converter.js +1 -1
- package/soundfont/dls/dls_sample.js +1 -1
- package/soundfont/dls/dls_soundfont.js +18 -5
- package/soundfont/dls/read_instrument.js +1 -1
- package/soundfont/dls/read_samples.js +1 -1
- package/soundfont/read_sf2/samples.js +12 -5
- package/soundfont/read_sf2/soundfont.js +3 -3
- package/synthetizer/worklet_processor.min.js +10 -10
- package/synthetizer/worklet_system/message_protocol/handle_message.js +17 -2
|
@@ -81,6 +81,10 @@ export class BasicSoundFont {
|
|
|
81
81
|
* @returns {BasicPreset}
|
|
82
82
|
*/
|
|
83
83
|
getPresetByName(presetName: string): BasicPreset;
|
|
84
|
+
/**
|
|
85
|
+
* @param error {string}
|
|
86
|
+
*/
|
|
87
|
+
parsingError(error: string): void;
|
|
84
88
|
write: typeof write;
|
|
85
89
|
}
|
|
86
90
|
import { Modulator } from "./modulator.js";
|
package/package.json
CHANGED
package/sequencer/sequencer.js
CHANGED
|
@@ -49,7 +49,7 @@ export function loadNewSequence(parsedMidi, autoPlay = true)
|
|
|
49
49
|
this.stop();
|
|
50
50
|
if (!parsedMidi.tracks)
|
|
51
51
|
{
|
|
52
|
-
throw "
|
|
52
|
+
throw new Error("This MIDI has no tracks!");
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
this.oneTickToSeconds = 60 / (120 * parsedMidi.timeDivision);
|
|
@@ -225,6 +225,14 @@ class BasicSoundFont
|
|
|
225
225
|
}
|
|
226
226
|
return preset;
|
|
227
227
|
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @param error {string}
|
|
231
|
+
*/
|
|
232
|
+
parsingError(error)
|
|
233
|
+
{
|
|
234
|
+
throw new Error(`SF parsing error: ${error} The file may be corrupted.`);
|
|
235
|
+
}
|
|
228
236
|
}
|
|
229
237
|
|
|
230
238
|
BasicSoundFont.prototype.write = write;
|
|
@@ -25,7 +25,7 @@ class DLSSoundFont extends BasicSoundFont
|
|
|
25
25
|
if (!this.dataArray)
|
|
26
26
|
{
|
|
27
27
|
SpessaSynthGroupEnd();
|
|
28
|
-
|
|
28
|
+
this.parsingError("No data provided!");
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// read the main chunk
|
|
@@ -85,7 +85,7 @@ class DLSSoundFont extends BasicSoundFont
|
|
|
85
85
|
if (!colhChunk)
|
|
86
86
|
{
|
|
87
87
|
SpessaSynthGroupEnd();
|
|
88
|
-
|
|
88
|
+
this.parsingError("No colh chunk!");
|
|
89
89
|
}
|
|
90
90
|
this.instrumentAmount = readLittleEndian(colhChunk.chunkData, 4);
|
|
91
91
|
SpessaSynthInfo(
|
|
@@ -96,6 +96,11 @@ class DLSSoundFont extends BasicSoundFont
|
|
|
96
96
|
|
|
97
97
|
// read wave list
|
|
98
98
|
let waveListChunk = findRIFFListType(chunks, "wvpl");
|
|
99
|
+
if (!waveListChunk)
|
|
100
|
+
{
|
|
101
|
+
SpessaSynthGroupEnd();
|
|
102
|
+
this.parsingError("No wvpl chunk!");
|
|
103
|
+
}
|
|
99
104
|
this.readDLSSamples(waveListChunk);
|
|
100
105
|
|
|
101
106
|
// read instrument list
|
|
@@ -103,7 +108,7 @@ class DLSSoundFont extends BasicSoundFont
|
|
|
103
108
|
if (!instrumentListChunk)
|
|
104
109
|
{
|
|
105
110
|
SpessaSynthGroupEnd();
|
|
106
|
-
|
|
111
|
+
this.parsingError("No lins chunk!");
|
|
107
112
|
}
|
|
108
113
|
this.readDLSInstrumentList(instrumentListChunk);
|
|
109
114
|
|
|
@@ -135,7 +140,7 @@ class DLSSoundFont extends BasicSoundFont
|
|
|
135
140
|
if (chunk.header.toLowerCase() !== expected.toLowerCase())
|
|
136
141
|
{
|
|
137
142
|
SpessaSynthGroupEnd();
|
|
138
|
-
|
|
143
|
+
this.parsingError(`Invalid DLS chunk header! Expected "${expected.toLowerCase()}" got "${chunk.header.toLowerCase()}"`);
|
|
139
144
|
}
|
|
140
145
|
}
|
|
141
146
|
|
|
@@ -148,9 +153,17 @@ class DLSSoundFont extends BasicSoundFont
|
|
|
148
153
|
if (text.toLowerCase() !== expected.toLowerCase())
|
|
149
154
|
{
|
|
150
155
|
SpessaSynthGroupEnd();
|
|
151
|
-
|
|
156
|
+
this.parsingError(`FourCC error: Expected "${expected.toLowerCase()}" got "${text.toLowerCase()}"`);
|
|
152
157
|
}
|
|
153
158
|
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @param error {string}
|
|
162
|
+
*/
|
|
163
|
+
parsingError(error)
|
|
164
|
+
{
|
|
165
|
+
throw new Error(`DLS parse error: ${error} The file may be corrupted.`);
|
|
166
|
+
}
|
|
154
167
|
}
|
|
155
168
|
|
|
156
169
|
DLSSoundFont.prototype.readDLSInstrumentList = readDLSInstrumentList;
|
|
@@ -85,7 +85,7 @@ export function readDLSInstrument(chunk)
|
|
|
85
85
|
if (type !== "rgn " && type !== "rgn2")
|
|
86
86
|
{
|
|
87
87
|
SpessaSynthGroupEnd();
|
|
88
|
-
|
|
88
|
+
this.parsingError(`Invalid DLS region! Expected "rgn " or "rgn2" got "${type}"`);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
|
|
@@ -80,7 +80,7 @@ export function readDLSSamples(waveListChunk)
|
|
|
80
80
|
const dataChunk = waveChunks.find(c => c.header === "data");
|
|
81
81
|
if (!dataChunk)
|
|
82
82
|
{
|
|
83
|
-
|
|
83
|
+
this.parsingError("No data chunk in the WAVE chunk!");
|
|
84
84
|
}
|
|
85
85
|
const sampleLength = dataChunk.size / bytesPerSample;
|
|
86
86
|
const sampleData = new Float32Array(sampleLength);
|
|
@@ -113,11 +113,18 @@ export class LoadedSample extends BasicSample
|
|
|
113
113
|
const buff = smplArr.slice(this.sampleStartIndex / 2 + smplStart, this.sampleEndIndex / 2 + smplStart);
|
|
114
114
|
// reset array and being decoding
|
|
115
115
|
this.sampleData = new Float32Array(0);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
try
|
|
117
|
+
{
|
|
118
|
+
/**
|
|
119
|
+
* @type {{data: Float32Array[], error: (string|null), sampleRate: number, eof: boolean}}
|
|
120
|
+
*/
|
|
121
|
+
const vorbis = stbvorbis.decode(buff.buffer);
|
|
122
|
+
this.sampleData = vorbis.data[0];
|
|
123
|
+
}
|
|
124
|
+
catch (e)
|
|
125
|
+
{
|
|
126
|
+
throw new Error(`Ogg Vorbis decode error: ${e}`);
|
|
127
|
+
}
|
|
121
128
|
}
|
|
122
129
|
|
|
123
130
|
/**
|
|
@@ -39,7 +39,7 @@ export class SoundFont2 extends BasicSoundFont
|
|
|
39
39
|
if (!this.dataArray)
|
|
40
40
|
{
|
|
41
41
|
SpessaSynthGroupEnd();
|
|
42
|
-
|
|
42
|
+
this.parsingError("No data provided!");
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// read the main read
|
|
@@ -280,7 +280,7 @@ export class SoundFont2 extends BasicSoundFont
|
|
|
280
280
|
if (chunk.header.toLowerCase() !== expected.toLowerCase())
|
|
281
281
|
{
|
|
282
282
|
SpessaSynthGroupEnd();
|
|
283
|
-
|
|
283
|
+
this.parsingError(`Invalid chunk header! Expected "${expected.toLowerCase()}" got "${chunk.header.toLowerCase()}"`);
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
286
|
|
|
@@ -293,7 +293,7 @@ export class SoundFont2 extends BasicSoundFont
|
|
|
293
293
|
if (text.toLowerCase() !== expected.toLowerCase())
|
|
294
294
|
{
|
|
295
295
|
SpessaSynthGroupEnd();
|
|
296
|
-
|
|
296
|
+
this.parsingError(`Invalid FourCC: Expected "${expected.toLowerCase()}" got "${text.toLowerCase()}"\``);
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
}
|