spessasynth_core 3.26.15 → 3.26.16
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
CHANGED
|
@@ -49,6 +49,12 @@ class BasicSoundBank
|
|
|
49
49
|
*/
|
|
50
50
|
defaultModulators = defaultModulators.map(m => Modulator.copy(m));
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* If the bank has custom default modulators (DMOD).
|
|
54
|
+
* @type {boolean}
|
|
55
|
+
*/
|
|
56
|
+
customDefaultModulators = false;
|
|
57
|
+
|
|
52
58
|
/**
|
|
53
59
|
* Checks for XG drumsets and considers if this soundfont is XG.
|
|
54
60
|
* @type {boolean}
|
|
@@ -12,7 +12,7 @@ import { getPGEN } from "./pgen.js";
|
|
|
12
12
|
import { getPMOD } from "./pmod.js";
|
|
13
13
|
import { getPBAG } from "./pbag.js";
|
|
14
14
|
import { getPHDR } from "./phdr.js";
|
|
15
|
-
import { writeWord } from "../../../utils/byte_functions/little_endian.js";
|
|
15
|
+
import { writeLittleEndian, writeWord } from "../../../utils/byte_functions/little_endian.js";
|
|
16
16
|
import { SpessaSynthGroupCollapsed, SpessaSynthGroupEnd, SpessaSynthInfo } from "../../../utils/loggin.js";
|
|
17
17
|
/**
|
|
18
18
|
* @typedef {Object} SoundFont2WriteOptions
|
|
@@ -72,6 +72,17 @@ export function write(options = DEFAULT_WRITE_OPTIONS)
|
|
|
72
72
|
this.soundFontInfo["ifil"] = "3.0"; // set version to 3
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
if (this.defaultModulators.length > 0)
|
|
76
|
+
{
|
|
77
|
+
// trigger the DMOD write
|
|
78
|
+
this.soundFontInfo["DMOD"] = `${this.defaultModulators.length} Modulators`;
|
|
79
|
+
this.customDefaultModulators = true;
|
|
80
|
+
}
|
|
81
|
+
else
|
|
82
|
+
{
|
|
83
|
+
delete this.soundFontInfo["DMOD"];
|
|
84
|
+
}
|
|
85
|
+
|
|
75
86
|
for (const [type, data] of Object.entries(this.soundFontInfo))
|
|
76
87
|
{
|
|
77
88
|
if (type === "ifil" || type === "iver")
|
|
@@ -89,10 +100,32 @@ export function write(options = DEFAULT_WRITE_OPTIONS)
|
|
|
89
100
|
}
|
|
90
101
|
else if (type === "DMOD")
|
|
91
102
|
{
|
|
103
|
+
|
|
104
|
+
const mods = this.defaultModulators;
|
|
105
|
+
SpessaSynthInfo(
|
|
106
|
+
`%cWriting %c${mods.length}%c default modulators...`,
|
|
107
|
+
consoleColors.info,
|
|
108
|
+
consoleColors.recognized,
|
|
109
|
+
consoleColors.info
|
|
110
|
+
);
|
|
111
|
+
let dmodsize = 10 + mods.length * 10;
|
|
112
|
+
const dmoddata = new IndexedByteArray(dmodsize);
|
|
113
|
+
for (const mod of mods)
|
|
114
|
+
{
|
|
115
|
+
writeWord(dmoddata, mod.sourceEnum);
|
|
116
|
+
writeWord(dmoddata, mod.modulatorDestination);
|
|
117
|
+
writeWord(dmoddata, mod.transformAmount);
|
|
118
|
+
writeWord(dmoddata, mod.secondarySourceEnum);
|
|
119
|
+
writeWord(dmoddata, mod.transformType);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// terminal modulator, is zero
|
|
123
|
+
writeLittleEndian(dmoddata, 0, 10);
|
|
124
|
+
|
|
92
125
|
infoArrays.push(writeRIFFChunk(new RiffChunk(
|
|
93
126
|
type,
|
|
94
|
-
|
|
95
|
-
|
|
127
|
+
dmoddata.length,
|
|
128
|
+
dmoddata
|
|
96
129
|
)));
|
|
97
130
|
}
|
|
98
131
|
else
|
|
@@ -87,15 +87,11 @@ export class SoundFont2 extends BasicSoundBank
|
|
|
87
87
|
const newModulators = readModulators(chunk);
|
|
88
88
|
newModulators.pop(); // remove the terminal record
|
|
89
89
|
text = `Modulators: ${newModulators.length}`;
|
|
90
|
-
// override default modulators
|
|
91
|
-
const oldDefaults = this.defaultModulators;
|
|
92
90
|
|
|
91
|
+
// override default modulators
|
|
93
92
|
this.defaultModulators = newModulators;
|
|
94
|
-
this.
|
|
95
|
-
|
|
96
|
-
mm
|
|
97
|
-
))));
|
|
98
|
-
this.soundFontInfo[chunk.header] = chunk.chunkData;
|
|
93
|
+
this.customDefaultModulators = true;
|
|
94
|
+
this.soundFontInfo[chunk.header] = text;
|
|
99
95
|
break;
|
|
100
96
|
|
|
101
97
|
default:
|