spessasynth_lib 3.20.6 → 3.20.9
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/synthetizer/synthetizer.d.ts +13 -10
- package/@types/synthetizer/worklet_system/message_protocol/worklet_message.d.ts +3 -0
- package/package.json +1 -1
- package/soundfont/dls/read_articulation.js +13 -8
- package/synthetizer/synthetizer.js +40 -15
- package/synthetizer/worklet_processor.min.js +6 -6
- package/synthetizer/worklet_system/main_processor.js +13 -0
- package/synthetizer/worklet_system/message_protocol/handle_message.js +4 -0
- package/synthetizer/worklet_system/message_protocol/worklet_message.js +3 -0
- package/synthetizer/worklet_system/worklet_methods/voice_control.js +11 -3
- package/synthetizer/worklet_system/worklet_utilities/volume_envelope.js +13 -4
- package/synthetizer/worklet_system/worklet_utilities/wavetable_oscillator.js +73 -2
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* synthesizer.js
|
|
3
|
-
* purpose: responds to midi messages and called functions, managing the channels and passing the messages to them
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {Object} StartRenderingDataConfig
|
|
7
|
-
* @property {BasicMIDI} parsedMIDI - the MIDI to render
|
|
8
|
-
* @property {SynthesizerSnapshot} snapshot - the snapshot to apply
|
|
9
|
-
* @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.
|
|
10
|
-
*/
|
|
11
1
|
export const WORKLET_PROCESSOR_NAME: "spessasynth-worklet-system";
|
|
12
2
|
export const VOICE_CAP: 450;
|
|
13
3
|
export const DEFAULT_PERCUSSION: 9;
|
|
@@ -112,6 +102,19 @@ export class Synthetizer {
|
|
|
112
102
|
* @param enableTable {boolean} - enable table (debug message)
|
|
113
103
|
*/
|
|
114
104
|
setLogLevel(enableInfo: boolean, enableWarning: boolean, enableGroup: boolean, enableTable: boolean): void;
|
|
105
|
+
/**
|
|
106
|
+
* @param type {masterParameterType}
|
|
107
|
+
* @param data {any}
|
|
108
|
+
* @private
|
|
109
|
+
*/
|
|
110
|
+
private _setMasterParam;
|
|
111
|
+
/**
|
|
112
|
+
* Sets the interpolation type for the synthesizer:
|
|
113
|
+
* 0 - linear
|
|
114
|
+
* 1 - nearest neighbor
|
|
115
|
+
* @param type {interpolationTypes}
|
|
116
|
+
*/
|
|
117
|
+
setInterpolationType(type: interpolationTypes): void;
|
|
115
118
|
/**
|
|
116
119
|
* Handles the messages received from the worklet
|
|
117
120
|
* @param message {WorkletReturnMessage}
|
|
@@ -35,6 +35,7 @@ export namespace masterParameterType {
|
|
|
35
35
|
let mainVolume: number;
|
|
36
36
|
let masterPan: number;
|
|
37
37
|
let voicesCap: number;
|
|
38
|
+
let interpolationType: number;
|
|
38
39
|
}
|
|
39
40
|
export const ALL_CHANNELS_OR_DIFFERENT_ACTION: -1;
|
|
40
41
|
export type returnMessageType = number;
|
|
@@ -47,6 +48,7 @@ export namespace returnMessageType {
|
|
|
47
48
|
export let synthesizerSnapshot: number;
|
|
48
49
|
export let ready: number;
|
|
49
50
|
export let soundfontError: number;
|
|
51
|
+
export let identify: number;
|
|
50
52
|
}
|
|
51
53
|
export type WorkletMessage = {
|
|
52
54
|
channelNumber: number;
|
|
@@ -78,6 +80,7 @@ export type WorkletReturnMessage = {
|
|
|
78
80
|
* 4 - synthesizer snapshot -> snapshot<SynthesizerSnapshot> note: refer to snapshot.js
|
|
79
81
|
* 5 - ready -> (no data)
|
|
80
82
|
* 6 - soundfontError -> errorMessage<string>
|
|
83
|
+
* 7 - idenfity -> version<string>
|
|
81
84
|
*/
|
|
82
85
|
messageData: {
|
|
83
86
|
eventName: string;
|
package/package.json
CHANGED
|
@@ -318,24 +318,29 @@ export function readArticulation(chunk, disableVibrato)
|
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
// override reverb and chorus with 1000 instead of 200
|
|
322
|
-
|
|
323
|
-
|
|
321
|
+
// override reverb and chorus with 1000 instead of 200 (if not overriden)
|
|
322
|
+
// reverb
|
|
323
|
+
if(modulators.find(m => m.modulatorDestination === generatorTypes.reverbEffectsSend) === undefined)
|
|
324
|
+
{
|
|
325
|
+
modulators.push(new Modulator({
|
|
324
326
|
srcEnum: 0x00DB,
|
|
325
327
|
dest: generatorTypes.reverbEffectsSend,
|
|
326
328
|
amt: 1000,
|
|
327
329
|
secSrcEnum: 0x0,
|
|
328
330
|
transform: 0
|
|
329
|
-
})
|
|
330
|
-
|
|
331
|
-
|
|
331
|
+
}));
|
|
332
|
+
}
|
|
333
|
+
// chorus
|
|
334
|
+
if(modulators.find(m => m.modulatorDestination === generatorTypes.chorusEffectsSend) === undefined)
|
|
335
|
+
{
|
|
336
|
+
modulators.push(new Modulator({
|
|
332
337
|
srcEnum: 0x00DD,
|
|
333
338
|
dest: generatorTypes.chorusEffectsSend,
|
|
334
339
|
amt: 1000,
|
|
335
340
|
secSrcEnum: 0x0,
|
|
336
341
|
transform: 0
|
|
337
|
-
})
|
|
338
|
-
|
|
342
|
+
}));
|
|
343
|
+
}
|
|
339
344
|
|
|
340
345
|
// it seems that dls 1 does not have vibrato lfo, so we shall disable it
|
|
341
346
|
if(disableVibrato)
|
|
@@ -26,6 +26,8 @@ import { SoundfontManager } from './synth_soundfont_manager.js'
|
|
|
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
|
*/
|
|
28
28
|
|
|
29
|
+
const CURRENT_SPESSASYNTH_VERSION = "3.20.9";
|
|
30
|
+
|
|
29
31
|
export const WORKLET_PROCESSOR_NAME = "spessasynth-worklet-system";
|
|
30
32
|
|
|
31
33
|
export const VOICE_CAP = 450;
|
|
@@ -218,10 +220,7 @@ export class Synthetizer {
|
|
|
218
220
|
*/
|
|
219
221
|
set voiceCap(value)
|
|
220
222
|
{
|
|
221
|
-
this.
|
|
222
|
-
messageType: workletMessageType.setMasterParameter,
|
|
223
|
-
messageData: [masterParameterType.voicesCap, value]
|
|
224
|
-
})
|
|
223
|
+
this._setMasterParam(masterParameterType.voicesCap, value);
|
|
225
224
|
this._voiceCap = value;
|
|
226
225
|
}
|
|
227
226
|
|
|
@@ -250,12 +249,37 @@ export class Synthetizer {
|
|
|
250
249
|
setLogLevel(enableInfo, enableWarning, enableGroup, enableTable)
|
|
251
250
|
{
|
|
252
251
|
this.post({
|
|
253
|
-
channelNumber:
|
|
252
|
+
channelNumber: ALL_CHANNELS_OR_DIFFERENT_ACTION,
|
|
254
253
|
messageType: workletMessageType.setLogLevel,
|
|
255
254
|
messageData: [enableInfo, enableWarning, enableGroup, enableTable]
|
|
256
255
|
});
|
|
257
256
|
}
|
|
258
257
|
|
|
258
|
+
/**
|
|
259
|
+
* @param type {masterParameterType}
|
|
260
|
+
* @param data {any}
|
|
261
|
+
* @private
|
|
262
|
+
*/
|
|
263
|
+
_setMasterParam(type, data)
|
|
264
|
+
{
|
|
265
|
+
this.post({
|
|
266
|
+
channelNumber: ALL_CHANNELS_OR_DIFFERENT_ACTION,
|
|
267
|
+
messageType: workletMessageType.setMasterParameter,
|
|
268
|
+
messageData: [type, data]
|
|
269
|
+
})
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Sets the interpolation type for the synthesizer:
|
|
274
|
+
* 0 - linear
|
|
275
|
+
* 1 - nearest neighbor
|
|
276
|
+
* @param type {interpolationTypes}
|
|
277
|
+
*/
|
|
278
|
+
setInterpolationType(type)
|
|
279
|
+
{
|
|
280
|
+
this._setMasterParam(masterParameterType.interpolationType, type);
|
|
281
|
+
}
|
|
282
|
+
|
|
259
283
|
/**
|
|
260
284
|
* Handles the messages received from the worklet
|
|
261
285
|
* @param message {WorkletReturnMessage}
|
|
@@ -300,6 +324,15 @@ export class Synthetizer {
|
|
|
300
324
|
case returnMessageType.soundfontError:
|
|
301
325
|
SpessaSynthWarn(new Error(messageData));
|
|
302
326
|
this.eventHandler.callEvent("soundfonterror", messageData);
|
|
327
|
+
break;
|
|
328
|
+
|
|
329
|
+
case returnMessageType.identify:
|
|
330
|
+
if(messageData !== CURRENT_SPESSASYNTH_VERSION)
|
|
331
|
+
{
|
|
332
|
+
this.stopAll(true);
|
|
333
|
+
this.worklet.disconnect();
|
|
334
|
+
throw new Error(`Outdated worklet_processor.min.js! version: ${messageData}. Please update it to ${CURRENT_SPESSASYNTH_VERSION}`);
|
|
335
|
+
}
|
|
303
336
|
}
|
|
304
337
|
}
|
|
305
338
|
|
|
@@ -563,11 +596,7 @@ export class Synthetizer {
|
|
|
563
596
|
*/
|
|
564
597
|
setMainVolume(volume)
|
|
565
598
|
{
|
|
566
|
-
this.
|
|
567
|
-
channelNumber: ALL_CHANNELS_OR_DIFFERENT_ACTION,
|
|
568
|
-
messageType: workletMessageType.setMasterParameter,
|
|
569
|
-
messageData: [masterParameterType.mainVolume, volume]
|
|
570
|
-
});
|
|
599
|
+
this._setMasterParam(masterParameterType.mainVolume, volume);
|
|
571
600
|
}
|
|
572
601
|
|
|
573
602
|
/**
|
|
@@ -576,11 +605,7 @@ export class Synthetizer {
|
|
|
576
605
|
*/
|
|
577
606
|
setMasterPan(pan)
|
|
578
607
|
{
|
|
579
|
-
this.
|
|
580
|
-
channelNumber: ALL_CHANNELS_OR_DIFFERENT_ACTION,
|
|
581
|
-
messageType: workletMessageType.setMasterParameter,
|
|
582
|
-
messageData: [masterParameterType.masterPan, pan]
|
|
583
|
-
});
|
|
608
|
+
this._setMasterParam(masterParameterType.masterPan, pan);
|
|
584
609
|
}
|
|
585
610
|
|
|
586
611
|
/**
|