spessasynth_lib 3.20.5 → 3.20.8
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 +42 -15
- package/synthetizer/worklet_processor.min.js +7 -7
- 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/controller_control.js +6 -1
- package/synthetizer/worklet_system/worklet_methods/program_control.js +6 -1
- package/synthetizer/worklet_system/worklet_methods/system_exclusive.js +16 -0
- package/synthetizer/worklet_system/worklet_methods/voice_control.js +9 -2
- 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.8";
|
|
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,17 @@ 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 processor (worklet_processor.min.js)
|
|
335
|
+
version: ${messageData}.
|
|
336
|
+
Please update it to the latest version (${CURRENT_SPESSASYNTH_VERSION})`);
|
|
337
|
+
}
|
|
303
338
|
}
|
|
304
339
|
}
|
|
305
340
|
|
|
@@ -563,11 +598,7 @@ export class Synthetizer {
|
|
|
563
598
|
*/
|
|
564
599
|
setMainVolume(volume)
|
|
565
600
|
{
|
|
566
|
-
this.
|
|
567
|
-
channelNumber: ALL_CHANNELS_OR_DIFFERENT_ACTION,
|
|
568
|
-
messageType: workletMessageType.setMasterParameter,
|
|
569
|
-
messageData: [masterParameterType.mainVolume, volume]
|
|
570
|
-
});
|
|
601
|
+
this._setMasterParam(masterParameterType.mainVolume, volume);
|
|
571
602
|
}
|
|
572
603
|
|
|
573
604
|
/**
|
|
@@ -576,11 +607,7 @@ export class Synthetizer {
|
|
|
576
607
|
*/
|
|
577
608
|
setMasterPan(pan)
|
|
578
609
|
{
|
|
579
|
-
this.
|
|
580
|
-
channelNumber: ALL_CHANNELS_OR_DIFFERENT_ACTION,
|
|
581
|
-
messageType: workletMessageType.setMasterParameter,
|
|
582
|
-
messageData: [masterParameterType.masterPan, pan]
|
|
583
|
-
});
|
|
610
|
+
this._setMasterParam(masterParameterType.masterPan, pan);
|
|
584
611
|
}
|
|
585
612
|
|
|
586
613
|
/**
|