spessasynth_lib 3.23.3 → 3.23.6
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/modulator.d.ts +2 -1
- package/@types/soundfont/dls/articulator_converter.d.ts +9 -0
- package/@types/soundfont/dls/dls_sources.d.ts +5 -0
- package/@types/synthetizer/synth_event_handler.d.ts +5 -0
- package/@types/utils/byte_functions/string.d.ts +5 -0
- package/midi_parser/rmidi_writer.js +4 -4
- package/package.json +1 -1
- package/soundfont/basic_soundfont/modulator.js +4 -2
- package/soundfont/basic_soundfont/riff_chunk.js +1 -1
- package/soundfont/basic_soundfont/write_dls/art2.js +17 -0
- package/soundfont/basic_soundfont/write_dls/ins.js +2 -2
- package/soundfont/basic_soundfont/write_dls/modulator_converter.js +12 -6
- package/soundfont/basic_soundfont/write_dls/rgn2.js +30 -25
- package/soundfont/basic_soundfont/write_dls/wave.js +8 -3
- package/soundfont/basic_soundfont/write_dls/write_dls.js +3 -2
- package/soundfont/basic_soundfont/write_dls/wsmp.js +2 -2
- package/soundfont/dls/articulator_converter.js +12 -10
- package/soundfont/dls/dls_sources.js +36 -1
- package/soundfont/dls/read_articulation.js +3 -15
- package/soundfont/dls/read_instrument.js +3 -14
- package/synthetizer/synth_event_handler.js +17 -1
- package/synthetizer/worklet_processor.min.js +10 -10
- package/utils/byte_functions/string.js +9 -0
|
@@ -25,9 +25,10 @@ export class Modulator {
|
|
|
25
25
|
/**
|
|
26
26
|
* @param mod1 {Modulator}
|
|
27
27
|
* @param mod2 {Modulator}
|
|
28
|
+
* @param checkAmount {boolean}
|
|
28
29
|
* @returns {boolean}
|
|
29
30
|
*/
|
|
30
|
-
static isIdentical(mod1: Modulator, mod2: Modulator): boolean;
|
|
31
|
+
static isIdentical(mod1: Modulator, mod2: Modulator, checkAmount?: boolean): boolean;
|
|
31
32
|
/**
|
|
32
33
|
* Creates a modulator
|
|
33
34
|
* @param params {{srcEnum: number, secSrcEnum: number, dest: generatorTypes, amt: number, transform: number}}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param source {number}
|
|
3
|
+
* @param control {number}
|
|
4
|
+
* @param destination {number}
|
|
5
|
+
* @param value {number}
|
|
6
|
+
* @param transform {number}
|
|
7
|
+
* @param msg {string}
|
|
8
|
+
*/
|
|
9
|
+
export function modulatorConverterDebug(source: number, control: number, destination: number, value: number, transform: number, msg?: string): void;
|
|
1
10
|
/**
|
|
2
11
|
* @param source {number}
|
|
3
12
|
* @param control {number}
|
|
@@ -20,3 +20,8 @@ export namespace DLSSources {
|
|
|
20
20
|
let fineTune: number;
|
|
21
21
|
let coarseTune: number;
|
|
22
22
|
}
|
|
23
|
+
export const DEFAULT_DLS_REVERB: Modulator;
|
|
24
|
+
export const DEFAULT_DLS_CHORUS: Modulator;
|
|
25
|
+
export const DLS_1_NO_VIBRATO_MOD: Modulator;
|
|
26
|
+
export const DLS_1_NO_VIBRATO_PRESSURE: Modulator;
|
|
27
|
+
import { Modulator } from "../basic_soundfont/modulator.js";
|
|
@@ -96,6 +96,11 @@ export class EventHandler {
|
|
|
96
96
|
* @type {Object<EventTypes, Object<string, function(EventCallbackData)>>}
|
|
97
97
|
*/
|
|
98
98
|
events: any;
|
|
99
|
+
/**
|
|
100
|
+
* Set to 0 to disabled, otherwise in seconds
|
|
101
|
+
* @type {number}
|
|
102
|
+
*/
|
|
103
|
+
timeDelay: number;
|
|
99
104
|
/**
|
|
100
105
|
* Adds a new event listener
|
|
101
106
|
* @param name {EventTypes}
|
|
@@ -12,6 +12,11 @@ export function readBytesAsString(dataArray: IndexedByteArray, bytes: number, en
|
|
|
12
12
|
* @returns {IndexedByteArray}
|
|
13
13
|
*/
|
|
14
14
|
export function getStringBytes(string: string, padLength?: number): IndexedByteArray;
|
|
15
|
+
/**
|
|
16
|
+
* @param string {string}
|
|
17
|
+
* @returns {IndexedByteArray}
|
|
18
|
+
*/
|
|
19
|
+
export function getStringBytesZero(string: string): IndexedByteArray;
|
|
15
20
|
/**
|
|
16
21
|
* @param string {string}
|
|
17
22
|
* @param outArray {IndexedByteArray}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { combineArrays, IndexedByteArray } from "../utils/indexed_array.js";
|
|
2
2
|
import { writeMIDIFile } from "./midi_writer.js";
|
|
3
3
|
import { writeRIFFOddSize } from "../soundfont/basic_soundfont/riff_chunk.js";
|
|
4
|
-
import { getStringBytes } from "../utils/byte_functions/string.js";
|
|
4
|
+
import { getStringBytes, getStringBytesZero } from "../utils/byte_functions/string.js";
|
|
5
5
|
import { messageTypes, midiControllers, MidiMessage } from "./midi_message.js";
|
|
6
6
|
import { DEFAULT_PERCUSSION } from "../synthetizer/synthetizer.js";
|
|
7
7
|
import { getGsOn } from "./midi_editor.js";
|
|
@@ -409,7 +409,7 @@ export function writeRMIDI(
|
|
|
409
409
|
minute: "numeric"
|
|
410
410
|
});
|
|
411
411
|
infoContent.push(
|
|
412
|
-
writeRIFFOddSize(RMIDINFOChunks.creationDate,
|
|
412
|
+
writeRIFFOddSize(RMIDINFOChunks.creationDate, getStringBytesZero(today), true)
|
|
413
413
|
);
|
|
414
414
|
}
|
|
415
415
|
// comment
|
|
@@ -471,7 +471,7 @@ export function writeRMIDI(
|
|
|
471
471
|
// use midi copyright if possible
|
|
472
472
|
const copyright = mid.copyright.length > 0 ? mid.copyright : DEFAULT_COPYRIGHT;
|
|
473
473
|
infoContent.push(
|
|
474
|
-
writeRIFFOddSize(RMIDINFOChunks.copyright,
|
|
474
|
+
writeRIFFOddSize(RMIDINFOChunks.copyright, getStringBytesZero(copyright))
|
|
475
475
|
);
|
|
476
476
|
}
|
|
477
477
|
|
|
@@ -488,7 +488,7 @@ export function writeRMIDI(
|
|
|
488
488
|
encoding = FORCED_ENCODING;
|
|
489
489
|
}
|
|
490
490
|
// encoding
|
|
491
|
-
infoContent.push(writeRIFFOddSize(RMIDINFOChunks.encoding,
|
|
491
|
+
infoContent.push(writeRIFFOddSize(RMIDINFOChunks.encoding, getStringBytesZero(encoding)));
|
|
492
492
|
|
|
493
493
|
// combine and write out
|
|
494
494
|
const infodata = combineArrays(infoContent);
|
package/package.json
CHANGED
|
@@ -108,14 +108,16 @@ export class Modulator
|
|
|
108
108
|
/**
|
|
109
109
|
* @param mod1 {Modulator}
|
|
110
110
|
* @param mod2 {Modulator}
|
|
111
|
+
* @param checkAmount {boolean}
|
|
111
112
|
* @returns {boolean}
|
|
112
113
|
*/
|
|
113
|
-
static isIdentical(mod1, mod2)
|
|
114
|
+
static isIdentical(mod1, mod2, checkAmount = false)
|
|
114
115
|
{
|
|
115
116
|
return (mod1.sourceEnum === mod2.sourceEnum)
|
|
116
117
|
&& (mod1.modulatorDestination === mod2.modulatorDestination)
|
|
117
118
|
&& (mod1.secondarySourceEnum === mod2.secondarySourceEnum)
|
|
118
|
-
&& (mod1.transformType === mod2.transformType)
|
|
119
|
+
&& (mod1.transformType === mod2.transformType)
|
|
120
|
+
&& (!checkAmount || (mod1.transformAmount === mod2.transformAmount));
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
/**
|
|
@@ -101,7 +101,7 @@ export function writeRIFFOddSize(header, data, addZeroByte = false, isList = fal
|
|
|
101
101
|
if (addZeroByte)
|
|
102
102
|
{
|
|
103
103
|
const tempData = new Uint8Array(data.length + 1);
|
|
104
|
-
tempData.set(data
|
|
104
|
+
tempData.set(data);
|
|
105
105
|
data = tempData;
|
|
106
106
|
}
|
|
107
107
|
let offset = 8;
|
|
@@ -5,6 +5,13 @@ import { Generator, generatorTypes } from "../generator.js";
|
|
|
5
5
|
import { writeDword } from "../../../utils/byte_functions/little_endian.js";
|
|
6
6
|
import { consoleColors } from "../../../utils/other.js";
|
|
7
7
|
import { SpessaSynthInfo, SpessaSynthWarn } from "../../../utils/loggin.js";
|
|
8
|
+
import { Modulator } from "../modulator.js";
|
|
9
|
+
import {
|
|
10
|
+
DEFAULT_DLS_CHORUS,
|
|
11
|
+
DEFAULT_DLS_REVERB,
|
|
12
|
+
DLS_1_NO_VIBRATO_MOD,
|
|
13
|
+
DLS_1_NO_VIBRATO_PRESSURE
|
|
14
|
+
} from "../../dls/dls_sources.js";
|
|
8
15
|
|
|
9
16
|
const invalidGeneratorTypes = new Set([
|
|
10
17
|
generatorTypes.sampleModes,
|
|
@@ -108,6 +115,16 @@ export function writeArticulator(zone)
|
|
|
108
115
|
*/
|
|
109
116
|
const modulators = zone.modulators.reduce((arrs, m) =>
|
|
110
117
|
{
|
|
118
|
+
// do not write the default DLS modulators
|
|
119
|
+
if (
|
|
120
|
+
Modulator.isIdentical(m, DEFAULT_DLS_CHORUS, true) ||
|
|
121
|
+
Modulator.isIdentical(m, DEFAULT_DLS_REVERB, true) ||
|
|
122
|
+
Modulator.isIdentical(m, DLS_1_NO_VIBRATO_MOD, true) ||
|
|
123
|
+
Modulator.isIdentical(m, DLS_1_NO_VIBRATO_PRESSURE, true)
|
|
124
|
+
)
|
|
125
|
+
{
|
|
126
|
+
return arrs;
|
|
127
|
+
}
|
|
111
128
|
const art = getDLSArticulatorFromSf2Modulator(m);
|
|
112
129
|
if (art !== undefined)
|
|
113
130
|
{
|
|
@@ -3,7 +3,7 @@ import { combineZones } from "./combine_zones.js";
|
|
|
3
3
|
import { writeRIFFOddSize } from "../riff_chunk.js";
|
|
4
4
|
import { writeDword } from "../../../utils/byte_functions/little_endian.js";
|
|
5
5
|
import { writeDLSRegion } from "./rgn2.js";
|
|
6
|
-
import {
|
|
6
|
+
import { getStringBytesZero } from "../../../utils/byte_functions/string.js";
|
|
7
7
|
import { writeArticulator } from "./art2.js";
|
|
8
8
|
import { SpessaSynthGroupCollapsed, SpessaSynthGroupEnd } from "../../../utils/loggin.js";
|
|
9
9
|
import { consoleColors } from "../../../utils/other.js";
|
|
@@ -84,7 +84,7 @@ export function writeIns(preset)
|
|
|
84
84
|
// writeINFO
|
|
85
85
|
const inam = writeRIFFOddSize(
|
|
86
86
|
"INAM",
|
|
87
|
-
|
|
87
|
+
getStringBytesZero(preset.presetName)
|
|
88
88
|
);
|
|
89
89
|
const info = writeRIFFOddSize(
|
|
90
90
|
"INFO",
|
|
@@ -257,7 +257,7 @@ export function getDLSArticulatorFromSf2Modulator(mod)
|
|
|
257
257
|
return undefined;
|
|
258
258
|
}
|
|
259
259
|
let source = getDLSSourceFromSf2Source(mod.sourceUsesCC, mod.sourceIndex);
|
|
260
|
-
let
|
|
260
|
+
let sourceTransformType = mod.sourceCurveType;
|
|
261
261
|
let sourceBipolar = mod.sourcePolarity;
|
|
262
262
|
let sourceDirection = mod.sourceDirection;
|
|
263
263
|
if (source === undefined)
|
|
@@ -265,8 +265,13 @@ export function getDLSArticulatorFromSf2Modulator(mod)
|
|
|
265
265
|
SpessaSynthWarn(`Invalid source: ${mod.sourceIndex}, CC: ${mod.sourceUsesCC}`);
|
|
266
266
|
return undefined;
|
|
267
267
|
}
|
|
268
|
+
// attenuation is the opposite of gain. Invert
|
|
269
|
+
if (mod.modulatorDestination === generatorTypes.initialAttenuation)
|
|
270
|
+
{
|
|
271
|
+
sourceDirection = sourceDirection === 1 ? 0 : 1;
|
|
272
|
+
}
|
|
268
273
|
let control = getDLSSourceFromSf2Source(mod.secSrcUsesCC, mod.secSrcIndex);
|
|
269
|
-
let
|
|
274
|
+
let controlTransformType = mod.secSrcCurveType;
|
|
270
275
|
let controlBipolar = mod.secSrcPolarity;
|
|
271
276
|
let controlDirection = mod.secSrcDirection;
|
|
272
277
|
if (control === undefined)
|
|
@@ -288,12 +293,12 @@ export function getDLSArticulatorFromSf2Modulator(mod)
|
|
|
288
293
|
amt = specialCombo.amt;
|
|
289
294
|
// move source to control
|
|
290
295
|
control = source;
|
|
291
|
-
|
|
296
|
+
controlTransformType = sourceTransformType;
|
|
292
297
|
controlBipolar = sourceBipolar;
|
|
293
298
|
controlDirection = sourceDirection;
|
|
294
299
|
|
|
295
300
|
// set source as static as it's either: env, lfo or keynum
|
|
296
|
-
|
|
301
|
+
sourceTransformType = modulatorCurveTypes.linear;
|
|
297
302
|
sourceBipolar = specialCombo.isBipolar ? 1 : 0;
|
|
298
303
|
sourceDirection = 0;
|
|
299
304
|
source = specialCombo.source;
|
|
@@ -307,11 +312,12 @@ export function getDLSArticulatorFromSf2Modulator(mod)
|
|
|
307
312
|
|
|
308
313
|
// source curve type maps to desfont curve type in section 2.10, table 9
|
|
309
314
|
let transform = 0;
|
|
310
|
-
transform |=
|
|
315
|
+
transform |= controlTransformType << 4;
|
|
311
316
|
transform |= controlBipolar << 8;
|
|
312
317
|
transform |= controlDirection << 9;
|
|
313
318
|
|
|
314
|
-
|
|
319
|
+
// use use the source curve in output transform
|
|
320
|
+
transform |= sourceTransformType;
|
|
315
321
|
transform |= sourceBipolar << 14;
|
|
316
322
|
transform |= sourceDirection << 15;
|
|
317
323
|
return new Articulator(
|
|
@@ -14,14 +14,14 @@ import { writeArticulator } from "./art2.js";
|
|
|
14
14
|
export function writeDLSRegion(zone, globalZone)
|
|
15
15
|
{
|
|
16
16
|
// region header
|
|
17
|
-
const rgnhData = new IndexedByteArray(
|
|
17
|
+
const rgnhData = new IndexedByteArray(12);
|
|
18
18
|
// keyRange
|
|
19
19
|
writeWord(rgnhData, Math.max(zone.keyRange.min, 0));
|
|
20
20
|
writeWord(rgnhData, zone.keyRange.max);
|
|
21
21
|
// velRange
|
|
22
22
|
writeWord(rgnhData, Math.max(zone.velRange.min, 0));
|
|
23
23
|
writeWord(rgnhData, zone.velRange.max);
|
|
24
|
-
// fusOptions
|
|
24
|
+
// fusOptions: 0 it seems
|
|
25
25
|
writeWord(rgnhData, 0);
|
|
26
26
|
// keyGroup (exclusive class)
|
|
27
27
|
const exclusive = zone.getGeneratorValue(generatorTypes.exclusiveClass, 0);
|
|
@@ -71,21 +71,22 @@ export function writeDLSRegion(zone, globalZone)
|
|
|
71
71
|
const wlnkData = new IndexedByteArray(12);
|
|
72
72
|
writeWord(wlnkData, 0); // fusOptions
|
|
73
73
|
writeWord(wlnkData, 0); // usPhaseGroup
|
|
74
|
-
let sampleType = 0;
|
|
75
|
-
switch (zone.sample.sampleType)
|
|
76
|
-
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
74
|
+
// let sampleType = 0;
|
|
75
|
+
// switch (zone.sample.sampleType)
|
|
76
|
+
// {
|
|
77
|
+
// default:
|
|
78
|
+
// case 1:
|
|
79
|
+
// case 4:
|
|
80
|
+
// // mono/left
|
|
81
|
+
// sampleType = 0;
|
|
82
|
+
// break;
|
|
83
|
+
//
|
|
84
|
+
// case 2:
|
|
85
|
+
// // right
|
|
86
|
+
// sampleType = 1;
|
|
87
|
+
// }
|
|
88
|
+
// 1 means that the first bit is on so mono/left
|
|
89
|
+
writeDword(wlnkData, 1); // ulChannel
|
|
89
90
|
writeDword(wlnkData, this.samples.indexOf(zone.sample)); // ulTableIndex
|
|
90
91
|
const wlnk = writeRIFFOddSize(
|
|
91
92
|
"wlnk",
|
|
@@ -93,14 +94,18 @@ export function writeDLSRegion(zone, globalZone)
|
|
|
93
94
|
);
|
|
94
95
|
|
|
95
96
|
// art
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
let lar2 = new IndexedByteArray(0);
|
|
98
|
+
if (zone.modulators.length + zone.generators.length > 0)
|
|
99
|
+
{
|
|
100
|
+
const art2 = writeArticulator(zone);
|
|
101
|
+
|
|
102
|
+
lar2 = writeRIFFOddSize(
|
|
103
|
+
"lar2",
|
|
104
|
+
art2,
|
|
105
|
+
false,
|
|
106
|
+
true
|
|
107
|
+
);
|
|
108
|
+
}
|
|
104
109
|
|
|
105
110
|
return writeRIFFOddSize(
|
|
106
111
|
"rgn2",
|
|
@@ -2,7 +2,7 @@ import { combineArrays, IndexedByteArray } from "../../../utils/indexed_array.js
|
|
|
2
2
|
import { writeDword, writeWord } from "../../../utils/byte_functions/little_endian.js";
|
|
3
3
|
import { writeRIFFOddSize } from "../riff_chunk.js";
|
|
4
4
|
import { writeWavesample } from "./wsmp.js";
|
|
5
|
-
import {
|
|
5
|
+
import { getStringBytesZero } from "../../../utils/byte_functions/string.js";
|
|
6
6
|
import { SpessaSynthInfo } from "../../../utils/loggin.js";
|
|
7
7
|
import { consoleColors } from "../../../utils/other.js";
|
|
8
8
|
|
|
@@ -23,6 +23,11 @@ export function writeDLSSample(sample)
|
|
|
23
23
|
"fmt ",
|
|
24
24
|
fmtData
|
|
25
25
|
);
|
|
26
|
+
let loop = 1;
|
|
27
|
+
if (sample.sampleLoopStartIndex + Math.abs(sample.getAudioData().length - sample.sampleLoopEndIndex) < 2)
|
|
28
|
+
{
|
|
29
|
+
loop = 0;
|
|
30
|
+
}
|
|
26
31
|
const wsmp = writeWavesample(
|
|
27
32
|
sample,
|
|
28
33
|
sample.samplePitch,
|
|
@@ -30,7 +35,7 @@ export function writeDLSSample(sample)
|
|
|
30
35
|
0,
|
|
31
36
|
sample.sampleLoopStartIndex,
|
|
32
37
|
sample.sampleLoopEndIndex,
|
|
33
|
-
|
|
38
|
+
loop
|
|
34
39
|
);
|
|
35
40
|
const audio = sample.getAudioData();
|
|
36
41
|
let data;
|
|
@@ -60,7 +65,7 @@ export function writeDLSSample(sample)
|
|
|
60
65
|
|
|
61
66
|
const inam = writeRIFFOddSize(
|
|
62
67
|
"INAM",
|
|
63
|
-
|
|
68
|
+
getStringBytesZero(sample.sampleName)
|
|
64
69
|
);
|
|
65
70
|
const info = writeRIFFOddSize(
|
|
66
71
|
"INFO",
|
|
@@ -2,7 +2,7 @@ import { writeRIFFOddSize } from "../riff_chunk.js";
|
|
|
2
2
|
import { writeDword } from "../../../utils/byte_functions/little_endian.js";
|
|
3
3
|
import { combineArrays, IndexedByteArray } from "../../../utils/indexed_array.js";
|
|
4
4
|
import { writeLins } from "./lins.js";
|
|
5
|
-
import {
|
|
5
|
+
import { getStringBytesZero, writeStringAsBytes } from "../../../utils/byte_functions/string.js";
|
|
6
6
|
import { writeWavePool } from "./wvpl.js";
|
|
7
7
|
import { SpessaSynthGroupCollapsed, SpessaSynthGroupEnd, SpessaSynthInfo } from "../../../utils/loggin.js";
|
|
8
8
|
import { consoleColors } from "../../../utils/other.js";
|
|
@@ -80,7 +80,8 @@ export function writeDLS()
|
|
|
80
80
|
infos.push(
|
|
81
81
|
writeRIFFOddSize(
|
|
82
82
|
info,
|
|
83
|
-
|
|
83
|
+
getStringBytesZero(data),
|
|
84
|
+
true
|
|
84
85
|
)
|
|
85
86
|
);
|
|
86
87
|
}
|
|
@@ -37,8 +37,8 @@ export function writeWavesample(
|
|
|
37
37
|
// gain correction: Each unit of gain represents 1/655360 dB
|
|
38
38
|
const lGain = Math.floor(attenuationCb * -65536);
|
|
39
39
|
writeDword(wsmpData, lGain);
|
|
40
|
-
// fulOptions
|
|
41
|
-
writeDword(wsmpData,
|
|
40
|
+
// fulOptions: has to be 2 according to all DLS files I have
|
|
41
|
+
writeDword(wsmpData, 2);
|
|
42
42
|
|
|
43
43
|
const loopSize = loopEnd - loopStart;
|
|
44
44
|
let ulLoopType = 0;
|
|
@@ -188,13 +188,15 @@ function checkForSpecialDLSCombo(source, destination)
|
|
|
188
188
|
* @param destination {number}
|
|
189
189
|
* @param value {number}
|
|
190
190
|
* @param transform {number}
|
|
191
|
+
* @param msg {string}
|
|
191
192
|
*/
|
|
192
|
-
function modulatorConverterDebug(
|
|
193
|
+
export function modulatorConverterDebug(
|
|
193
194
|
source,
|
|
194
195
|
control,
|
|
195
196
|
destination,
|
|
196
197
|
value,
|
|
197
|
-
transform
|
|
198
|
+
transform,
|
|
199
|
+
msg = "Attempting to convert the following DLS Articulator to SF2 Modulator:"
|
|
198
200
|
)
|
|
199
201
|
{
|
|
200
202
|
const type = Object.keys(DLSDestinations).find(k => DLSDestinations[k] === destination);
|
|
@@ -204,7 +206,7 @@ function modulatorConverterDebug(
|
|
|
204
206
|
const srcString = srcType ? srcType : source.toString(16);
|
|
205
207
|
const ctrlString = ctrlType ? ctrlType : control.toString(16);
|
|
206
208
|
console.debug(
|
|
207
|
-
`%
|
|
209
|
+
`%c${msg}
|
|
208
210
|
Source: %c${srcString}%c
|
|
209
211
|
Control: %c${ctrlString}%c
|
|
210
212
|
Destination: %c${typeString}%c
|
|
@@ -240,6 +242,13 @@ export function getSF2ModulatorFromArticulator(
|
|
|
240
242
|
value
|
|
241
243
|
)
|
|
242
244
|
{
|
|
245
|
+
// modulatorConverterDebug(
|
|
246
|
+
// source,
|
|
247
|
+
// control,
|
|
248
|
+
// destination,
|
|
249
|
+
// value,
|
|
250
|
+
// transform
|
|
251
|
+
// );
|
|
243
252
|
// check for special combinations
|
|
244
253
|
const specialDestination = checkForSpecialDLSCombo(source, destination);
|
|
245
254
|
/**
|
|
@@ -320,13 +329,6 @@ export function getSF2ModulatorFromArticulator(
|
|
|
320
329
|
// special case: for attenuation, invert source (dls gain is the opposite of sf2 attenuation)
|
|
321
330
|
if (destinationGenerator === generatorTypes.initialAttenuation)
|
|
322
331
|
{
|
|
323
|
-
// modulatorConverterDebug(
|
|
324
|
-
// source,
|
|
325
|
-
// control,
|
|
326
|
-
// destination,
|
|
327
|
-
// value,
|
|
328
|
-
// transform
|
|
329
|
-
// );
|
|
330
332
|
// if the value is negative, the source shall be negative!
|
|
331
333
|
// why?
|
|
332
334
|
// Idk, it makes it work with ROCK.RMI and NOKIA_S30.dls
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Modulator } from "../basic_soundfont/modulator.js";
|
|
2
|
+
import { generatorTypes } from "../basic_soundfont/generator.js";
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* @enum {number}
|
|
3
6
|
*/
|
|
@@ -23,4 +26,36 @@ export const DLSSources = {
|
|
|
23
26
|
pitchWheelRange: 0x100,
|
|
24
27
|
fineTune: 0x101,
|
|
25
28
|
coarseTune: 0x102
|
|
26
|
-
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const DEFAULT_DLS_REVERB = new Modulator({
|
|
32
|
+
srcEnum: 0x00DB,
|
|
33
|
+
dest: generatorTypes.reverbEffectsSend,
|
|
34
|
+
amt: 1000,
|
|
35
|
+
secSrcEnum: 0x0,
|
|
36
|
+
transform: 0
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const DEFAULT_DLS_CHORUS = new Modulator({
|
|
40
|
+
srcEnum: 0x00DD,
|
|
41
|
+
dest: generatorTypes.chorusEffectsSend,
|
|
42
|
+
amt: 1000,
|
|
43
|
+
secSrcEnum: 0x0,
|
|
44
|
+
transform: 0
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const DLS_1_NO_VIBRATO_MOD = new Modulator({
|
|
48
|
+
srcEnum: 0x0081,
|
|
49
|
+
dest: generatorTypes.vibLfoToPitch,
|
|
50
|
+
amt: 0,
|
|
51
|
+
secSrcEnum: 0x0,
|
|
52
|
+
transform: 0
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export const DLS_1_NO_VIBRATO_PRESSURE = new Modulator({
|
|
56
|
+
srcEnum: 0x000D,
|
|
57
|
+
dest: generatorTypes.vibLfoToPitch,
|
|
58
|
+
amt: 0,
|
|
59
|
+
secSrcEnum: 0x0,
|
|
60
|
+
transform: 0
|
|
61
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readLittleEndian } from "../../utils/byte_functions/little_endian.js";
|
|
2
2
|
import { DLSDestinations } from "./dls_destinations.js";
|
|
3
|
-
import { DLSSources } from "./dls_sources.js";
|
|
3
|
+
import { DLS_1_NO_VIBRATO_MOD, DLS_1_NO_VIBRATO_PRESSURE, DLSSources } from "./dls_sources.js";
|
|
4
4
|
import { getSF2ModulatorFromArticulator } from "./articulator_converter.js";
|
|
5
5
|
import { SpessaSynthInfo, SpessaSynthWarn } from "../../utils/loggin.js";
|
|
6
6
|
import { consoleColors } from "../../utils/other.js";
|
|
@@ -306,21 +306,9 @@ export function readArticulation(chunk, disableVibrato)
|
|
|
306
306
|
{
|
|
307
307
|
modulators.push(
|
|
308
308
|
// mod to vib
|
|
309
|
-
|
|
310
|
-
srcEnum: 0x0081,
|
|
311
|
-
dest: generatorTypes.vibLfoToPitch,
|
|
312
|
-
amt: 0,
|
|
313
|
-
secSrcEnum: 0x0,
|
|
314
|
-
transform: 0
|
|
315
|
-
}),
|
|
309
|
+
Modulator.copy(DLS_1_NO_VIBRATO_MOD),
|
|
316
310
|
// press to vib
|
|
317
|
-
|
|
318
|
-
srcEnum: 0x000D,
|
|
319
|
-
dest: generatorTypes.vibLfoToPitch,
|
|
320
|
-
amt: 0,
|
|
321
|
-
secSrcEnum: 0x0,
|
|
322
|
-
transform: 0
|
|
323
|
-
})
|
|
311
|
+
Modulator.copy(DLS_1_NO_VIBRATO_PRESSURE)
|
|
324
312
|
);
|
|
325
313
|
}
|
|
326
314
|
|
|
@@ -7,6 +7,7 @@ import { BasicInstrumentZone } from "../basic_soundfont/basic_zones.js";
|
|
|
7
7
|
import { consoleColors } from "../../utils/other.js";
|
|
8
8
|
import { generatorLimits, generatorTypes } from "../basic_soundfont/generator.js";
|
|
9
9
|
import { Modulator } from "../basic_soundfont/modulator.js";
|
|
10
|
+
import { DEFAULT_DLS_CHORUS, DEFAULT_DLS_REVERB } from "./dls_sources.js";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* @this {DLSSoundFont}
|
|
@@ -85,24 +86,12 @@ export function readDLSInstrument(chunk)
|
|
|
85
86
|
// reverb
|
|
86
87
|
if (globalZone.modulators.find(m => m.modulatorDestination === generatorTypes.reverbEffectsSend) === undefined)
|
|
87
88
|
{
|
|
88
|
-
globalZone.modulators.push(
|
|
89
|
-
srcEnum: 0x00DB,
|
|
90
|
-
dest: generatorTypes.reverbEffectsSend,
|
|
91
|
-
amt: 1000,
|
|
92
|
-
secSrcEnum: 0x0,
|
|
93
|
-
transform: 0
|
|
94
|
-
}));
|
|
89
|
+
globalZone.modulators.push(Modulator.copy(DEFAULT_DLS_REVERB));
|
|
95
90
|
}
|
|
96
91
|
// chorus
|
|
97
92
|
if (globalZone.modulators.find(m => m.modulatorDestination === generatorTypes.chorusEffectsSend) === undefined)
|
|
98
93
|
{
|
|
99
|
-
globalZone.modulators.push(
|
|
100
|
-
srcEnum: 0x00DD,
|
|
101
|
-
dest: generatorTypes.chorusEffectsSend,
|
|
102
|
-
amt: 1000,
|
|
103
|
-
secSrcEnum: 0x0,
|
|
104
|
-
transform: 0
|
|
105
|
-
}));
|
|
94
|
+
globalZone.modulators.push(Modulator.copy(DEFAULT_DLS_CHORUS));
|
|
106
95
|
}
|
|
107
96
|
preset.DLSInstrument.instrumentZones.push(globalZone);
|
|
108
97
|
|
|
@@ -119,6 +119,12 @@ export class EventHandler
|
|
|
119
119
|
"allcontrollerreset": {},
|
|
120
120
|
"soundfonterror": {}
|
|
121
121
|
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Set to 0 to disabled, otherwise in seconds
|
|
125
|
+
* @type {number}
|
|
126
|
+
*/
|
|
127
|
+
this.timeDelay = 0;
|
|
122
128
|
}
|
|
123
129
|
|
|
124
130
|
/**
|
|
@@ -151,7 +157,17 @@ export class EventHandler
|
|
|
151
157
|
{
|
|
152
158
|
if (this.events[name])
|
|
153
159
|
{
|
|
154
|
-
|
|
160
|
+
if (this.timeDelay > 0)
|
|
161
|
+
{
|
|
162
|
+
setTimeout(() =>
|
|
163
|
+
{
|
|
164
|
+
Object.values(this.events[name]).forEach(ev => ev(eventData));
|
|
165
|
+
}, this.timeDelay * 1000);
|
|
166
|
+
}
|
|
167
|
+
else
|
|
168
|
+
{
|
|
169
|
+
Object.values(this.events[name]).forEach(ev => ev(eventData));
|
|
170
|
+
}
|
|
155
171
|
}
|
|
156
172
|
}
|
|
157
173
|
}
|