spessasynth_core 3.26.16 → 3.26.17
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/package.json +1 -1
- package/src/soundfont/basic_soundfont/modulator.js +53 -33
- package/src/soundfont/basic_soundfont/write_sf2/ibag.js +9 -1
- package/src/soundfont/basic_soundfont/write_sf2/igen.js +2 -2
- package/src/soundfont/basic_soundfont/write_sf2/imod.js +2 -2
- package/src/soundfont/basic_soundfont/write_sf2/pbag.js +9 -1
- package/src/soundfont/basic_soundfont/write_sf2/pgen.js +2 -2
- package/src/soundfont/basic_soundfont/write_sf2/pmod.js +2 -2
- package/src/soundfont/basic_soundfont/write_sf2/write.js +2 -2
package/package.json
CHANGED
|
@@ -32,18 +32,6 @@ export class Modulator
|
|
|
32
32
|
*/
|
|
33
33
|
currentValue = 0;
|
|
34
34
|
|
|
35
|
-
/**
|
|
36
|
-
* The source enumeration for this modulator
|
|
37
|
-
* @type {number}
|
|
38
|
-
*/
|
|
39
|
-
sourceEnum;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The secondary source enumeration for this modulator
|
|
43
|
-
* @type {number}
|
|
44
|
-
*/
|
|
45
|
-
secondarySourceEnum;
|
|
46
|
-
|
|
47
35
|
/**
|
|
48
36
|
* The generator destination of this modulator
|
|
49
37
|
* @type {generatorTypes}
|
|
@@ -72,9 +60,9 @@ export class Modulator
|
|
|
72
60
|
*/
|
|
73
61
|
constructor(srcEnum, secSrcEnum, destination, amount, transformType)
|
|
74
62
|
{
|
|
75
|
-
|
|
63
|
+
const sourceEnum = srcEnum;
|
|
76
64
|
this.modulatorDestination = destination;
|
|
77
|
-
|
|
65
|
+
const secondarySourceEnum = secSrcEnum;
|
|
78
66
|
this.transformAmount = amount;
|
|
79
67
|
this.transformType = transformType;
|
|
80
68
|
|
|
@@ -85,18 +73,18 @@ export class Modulator
|
|
|
85
73
|
}
|
|
86
74
|
|
|
87
75
|
// decode the source
|
|
88
|
-
this.sourcePolarity =
|
|
89
|
-
this.sourceDirection =
|
|
90
|
-
this.sourceUsesCC =
|
|
91
|
-
this.sourceIndex =
|
|
92
|
-
this.sourceCurveType =
|
|
76
|
+
this.sourcePolarity = sourceEnum >> 9 & 1;
|
|
77
|
+
this.sourceDirection = sourceEnum >> 8 & 1;
|
|
78
|
+
this.sourceUsesCC = sourceEnum >> 7 & 1;
|
|
79
|
+
this.sourceIndex = sourceEnum & 127;
|
|
80
|
+
this.sourceCurveType = sourceEnum >> 10 & 3;
|
|
93
81
|
|
|
94
82
|
// decode the secondary source
|
|
95
|
-
this.secSrcPolarity =
|
|
96
|
-
this.secSrcDirection =
|
|
97
|
-
this.secSrcUsesCC =
|
|
98
|
-
this.secSrcIndex =
|
|
99
|
-
this.secSrcCurveType =
|
|
83
|
+
this.secSrcPolarity = secondarySourceEnum >> 9 & 1;
|
|
84
|
+
this.secSrcDirection = secondarySourceEnum >> 8 & 1;
|
|
85
|
+
this.secSrcUsesCC = secondarySourceEnum >> 7 & 1;
|
|
86
|
+
this.secSrcIndex = secondarySourceEnum & 127;
|
|
87
|
+
this.secSrcCurveType = secondarySourceEnum >> 10 & 3;
|
|
100
88
|
|
|
101
89
|
/**
|
|
102
90
|
* Indicates if the given modulator is chorus or reverb effects modulator.
|
|
@@ -111,10 +99,10 @@ export class Modulator
|
|
|
111
99
|
*/
|
|
112
100
|
this.isEffectModulator =
|
|
113
101
|
(
|
|
114
|
-
|
|
115
|
-
||
|
|
102
|
+
sourceEnum === 0x00DB
|
|
103
|
+
|| sourceEnum === 0x00DD
|
|
116
104
|
)
|
|
117
|
-
&&
|
|
105
|
+
&& secondarySourceEnum === 0x0
|
|
118
106
|
&& (
|
|
119
107
|
this.modulatorDestination === generatorTypes.reverbEffectsSend
|
|
120
108
|
|| this.modulatorDestination === generatorTypes.chorusEffectsSend
|
|
@@ -128,8 +116,8 @@ export class Modulator
|
|
|
128
116
|
static copy(modulator)
|
|
129
117
|
{
|
|
130
118
|
return new Modulator(
|
|
131
|
-
modulator.
|
|
132
|
-
modulator.
|
|
119
|
+
modulator.getSourceEnum(),
|
|
120
|
+
modulator.getSecSrcEnum(),
|
|
133
121
|
modulator.modulatorDestination,
|
|
134
122
|
modulator.transformAmount,
|
|
135
123
|
modulator.transformType
|
|
@@ -144,9 +132,19 @@ export class Modulator
|
|
|
144
132
|
*/
|
|
145
133
|
static isIdentical(mod1, mod2, checkAmount = false)
|
|
146
134
|
{
|
|
147
|
-
return (mod1.
|
|
135
|
+
return (mod1.sourceIndex === mod2.sourceIndex)
|
|
136
|
+
&& (mod1.sourceUsesCC === mod2.sourceUsesCC)
|
|
137
|
+
&& (mod1.sourcePolarity === mod2.sourcePolarity)
|
|
138
|
+
&& (mod1.sourceDirection === mod2.sourceDirection)
|
|
139
|
+
&& (mod1.sourceCurveType === mod2.sourceCurveType)
|
|
140
|
+
|
|
141
|
+
&& (mod1.secSrcIndex === mod2.secSrcIndex)
|
|
142
|
+
&& (mod1.secSrcUsesCC === mod2.secSrcUsesCC)
|
|
143
|
+
&& (mod1.secSrcPolarity === mod2.secSrcPolarity)
|
|
144
|
+
&& (mod1.secSrcDirection === mod2.secSrcDirection)
|
|
145
|
+
&& (mod1.secSrcCurveType === mod2.secSrcCurveType)
|
|
146
|
+
|
|
148
147
|
&& (mod1.modulatorDestination === mod2.modulatorDestination)
|
|
149
|
-
&& (mod1.secondarySourceEnum === mod2.secondarySourceEnum)
|
|
150
148
|
&& (mod1.transformType === mod2.transformType)
|
|
151
149
|
&& (!checkAmount || (mod1.transformAmount === mod2.transformAmount));
|
|
152
150
|
}
|
|
@@ -194,6 +192,28 @@ export class Modulator
|
|
|
194
192
|
\n\n`;
|
|
195
193
|
}
|
|
196
194
|
|
|
195
|
+
getSourceEnum()
|
|
196
|
+
{
|
|
197
|
+
return getModSourceEnum(
|
|
198
|
+
this.sourceCurveType,
|
|
199
|
+
this.sourcePolarity,
|
|
200
|
+
this.sourceDirection,
|
|
201
|
+
this.sourceUsesCC,
|
|
202
|
+
this.sourceIndex
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
getSecSrcEnum()
|
|
207
|
+
{
|
|
208
|
+
return getModSourceEnum(
|
|
209
|
+
this.secSrcCurveType,
|
|
210
|
+
this.secSrcPolarity,
|
|
211
|
+
this.secSrcDirection,
|
|
212
|
+
this.secSrcUsesCC,
|
|
213
|
+
this.secSrcIndex
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
197
217
|
/**
|
|
198
218
|
* Sum transform and create a NEW modulator
|
|
199
219
|
* @param modulator {Modulator}
|
|
@@ -202,8 +222,8 @@ export class Modulator
|
|
|
202
222
|
sumTransform(modulator)
|
|
203
223
|
{
|
|
204
224
|
return new Modulator(
|
|
205
|
-
this.
|
|
206
|
-
this.
|
|
225
|
+
this.getSourceEnum(),
|
|
226
|
+
this.getSecSrcEnum(),
|
|
207
227
|
this.modulatorDestination,
|
|
208
228
|
this.transformAmount + modulator.transformAmount,
|
|
209
229
|
this.transformType
|
|
@@ -16,8 +16,16 @@ export function getIBAG()
|
|
|
16
16
|
let modulatorIndex = 0;
|
|
17
17
|
for (const inst of this.instruments)
|
|
18
18
|
{
|
|
19
|
+
// ensure that the first zone is global
|
|
20
|
+
const zones = inst.instrumentZones.filter(z => !z.isGlobal);
|
|
21
|
+
const global = inst.instrumentZones.filter(z => z.isGlobal);
|
|
22
|
+
// only take the first one
|
|
23
|
+
if (global?.[0])
|
|
24
|
+
{
|
|
25
|
+
zones.unshift(global?.[0]);
|
|
26
|
+
}
|
|
19
27
|
inst.instrumentZoneIndex = zoneID;
|
|
20
|
-
for (const ibag of
|
|
28
|
+
for (const ibag of zones)
|
|
21
29
|
{
|
|
22
30
|
ibag.zoneID = zoneID;
|
|
23
31
|
writeWord(ibagdata, generatorIndex);
|
|
@@ -24,7 +24,7 @@ export function getIGEN()
|
|
|
24
24
|
);
|
|
25
25
|
// add sample and ranges if necessary
|
|
26
26
|
// unshift vel then key (to make key first) and the instrument is last
|
|
27
|
-
if (z.
|
|
27
|
+
if (z.hasVelRange)
|
|
28
28
|
{
|
|
29
29
|
z.generators.unshift(new Generator(
|
|
30
30
|
generatorTypes.velRange,
|
|
@@ -32,7 +32,7 @@ export function getIGEN()
|
|
|
32
32
|
false
|
|
33
33
|
));
|
|
34
34
|
}
|
|
35
|
-
if (z.
|
|
35
|
+
if (z.hasKeyRange)
|
|
36
36
|
{
|
|
37
37
|
z.generators.unshift(new Generator(
|
|
38
38
|
generatorTypes.keyRange,
|
|
@@ -25,10 +25,10 @@ export function getIMOD()
|
|
|
25
25
|
ibag.modulatorZoneStartIndex = imodIndex;
|
|
26
26
|
for (const mod of ibag.modulators)
|
|
27
27
|
{
|
|
28
|
-
writeWord(imoddata, mod.
|
|
28
|
+
writeWord(imoddata, mod.getSourceEnum());
|
|
29
29
|
writeWord(imoddata, mod.modulatorDestination);
|
|
30
30
|
writeWord(imoddata, mod.transformAmount);
|
|
31
|
-
writeWord(imoddata, mod.
|
|
31
|
+
writeWord(imoddata, mod.getSecSrcEnum());
|
|
32
32
|
writeWord(imoddata, mod.transformType);
|
|
33
33
|
imodIndex++;
|
|
34
34
|
}
|
|
@@ -16,8 +16,16 @@ export function getPBAG()
|
|
|
16
16
|
let modulatorIndex = 0;
|
|
17
17
|
for (const preset of this.presets)
|
|
18
18
|
{
|
|
19
|
+
// ensure that the first zone is global
|
|
20
|
+
const zones = preset.presetZones.filter(z => !z.isGlobal);
|
|
21
|
+
const global = preset.presetZones.filter(z => z.isGlobal);
|
|
22
|
+
// only take the first one
|
|
23
|
+
if (global?.[0])
|
|
24
|
+
{
|
|
25
|
+
zones.unshift(global?.[0]);
|
|
26
|
+
}
|
|
19
27
|
preset.presetZoneStartIndex = zoneID;
|
|
20
|
-
for (const pbag of
|
|
28
|
+
for (const pbag of zones)
|
|
21
29
|
{
|
|
22
30
|
pbag.zoneID = zoneID;
|
|
23
31
|
writeWord(pbagdata, generatorIndex);
|
|
@@ -24,7 +24,7 @@ export function getPGEN()
|
|
|
24
24
|
g.generatorType !== generatorTypes.velRange
|
|
25
25
|
);
|
|
26
26
|
// unshift vel then key and instrument is last
|
|
27
|
-
if (z.
|
|
27
|
+
if (z.hasVelRange)
|
|
28
28
|
{
|
|
29
29
|
z.generators.unshift(new Generator(
|
|
30
30
|
generatorTypes.velRange,
|
|
@@ -32,7 +32,7 @@ export function getPGEN()
|
|
|
32
32
|
false
|
|
33
33
|
));
|
|
34
34
|
}
|
|
35
|
-
if (z.
|
|
35
|
+
if (z.hasKeyRange)
|
|
36
36
|
{
|
|
37
37
|
z.generators.unshift(new Generator(
|
|
38
38
|
generatorTypes.keyRange,
|
|
@@ -25,10 +25,10 @@ export function getPMOD()
|
|
|
25
25
|
pbag.modulatorZoneStartIndex = pmodIndex;
|
|
26
26
|
for (const mod of pbag.modulators)
|
|
27
27
|
{
|
|
28
|
-
writeWord(pmoddata, mod.
|
|
28
|
+
writeWord(pmoddata, mod.getSourceEnum());
|
|
29
29
|
writeWord(pmoddata, mod.modulatorDestination);
|
|
30
30
|
writeWord(pmoddata, mod.transformAmount);
|
|
31
|
-
writeWord(pmoddata, mod.
|
|
31
|
+
writeWord(pmoddata, mod.getSecSrcEnum());
|
|
32
32
|
writeWord(pmoddata, mod.transformType);
|
|
33
33
|
pmodIndex++;
|
|
34
34
|
}
|
|
@@ -112,10 +112,10 @@ export function write(options = DEFAULT_WRITE_OPTIONS)
|
|
|
112
112
|
const dmoddata = new IndexedByteArray(dmodsize);
|
|
113
113
|
for (const mod of mods)
|
|
114
114
|
{
|
|
115
|
-
writeWord(dmoddata, mod.
|
|
115
|
+
writeWord(dmoddata, mod.getSourceEnum());
|
|
116
116
|
writeWord(dmoddata, mod.modulatorDestination);
|
|
117
117
|
writeWord(dmoddata, mod.transformAmount);
|
|
118
|
-
writeWord(dmoddata, mod.
|
|
118
|
+
writeWord(dmoddata, mod.getSecSrcEnum());
|
|
119
119
|
writeWord(dmoddata, mod.transformType);
|
|
120
120
|
}
|
|
121
121
|
|