@marmooo/midy 0.1.4 → 0.1.5
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/esm/deps/cdn.jsdelivr.net/npm/@marmooo/{soundfont-parser@0.0.4 → soundfont-parser@0.0.6}/+esm.d.ts +16 -20
- package/esm/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.6/+esm.d.ts.map +1 -0
- package/esm/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.6/+esm.js +180 -0
- package/esm/midy-GM1.d.ts +29 -1
- package/esm/midy-GM1.d.ts.map +1 -1
- package/esm/midy-GM1.js +27 -32
- package/esm/midy-GM2.d.ts +53 -1
- package/esm/midy-GM2.d.ts.map +1 -1
- package/esm/midy-GM2.js +81 -79
- package/esm/midy-GMLite.d.ts +29 -1
- package/esm/midy-GMLite.d.ts.map +1 -1
- package/esm/midy-GMLite.js +27 -32
- package/esm/midy.d.ts +73 -1
- package/esm/midy.d.ts.map +1 -1
- package/esm/midy.js +104 -97
- package/package.json +1 -1
- package/script/deps/cdn.jsdelivr.net/npm/@marmooo/{soundfont-parser@0.0.4 → soundfont-parser@0.0.6}/+esm.d.ts +16 -20
- package/script/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.6/+esm.d.ts.map +1 -0
- package/script/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.6/+esm.js +190 -0
- package/script/midy-GM1.d.ts +29 -1
- package/script/midy-GM1.d.ts.map +1 -1
- package/script/midy-GM1.js +27 -32
- package/script/midy-GM2.d.ts +53 -1
- package/script/midy-GM2.d.ts.map +1 -1
- package/script/midy-GM2.js +81 -79
- package/script/midy-GMLite.d.ts +29 -1
- package/script/midy-GMLite.d.ts.map +1 -1
- package/script/midy-GMLite.js +27 -32
- package/script/midy.d.ts +73 -1
- package/script/midy.d.ts.map +1 -1
- package/script/midy.js +104 -97
- package/esm/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.4/+esm.d.ts.map +0 -1
- package/esm/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.4/+esm.js +0 -162
- package/script/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.4/+esm.d.ts.map +0 -1
- package/script/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.4/+esm.js +0 -169
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultInstrumentZone = exports.SoundFont = void 0;
|
|
4
|
-
exports.createGeneratorObject = I;
|
|
5
|
-
exports.parse = b;
|
|
6
|
-
exports.timecentToSecond = S;
|
|
7
|
-
/**
|
|
8
|
-
* Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.39.0.
|
|
9
|
-
* Original file: /npm/@marmooo/soundfont-parser@0.0.4/esm/mod.js
|
|
10
|
-
*
|
|
11
|
-
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
|
12
|
-
*/
|
|
13
|
-
class e {
|
|
14
|
-
constructor(e, t) { Object.defineProperty(this, "data", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "ip", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), this.data = e, this.ip = t; }
|
|
15
|
-
readString(e) { const t = this.data.subarray(this.ip, this.ip += e), n = String.fromCharCode(...Array.from(t)), r = n.indexOf("\0"); return r > 0 ? n.substring(0, r) : n; }
|
|
16
|
-
readWORD() { return this.data[this.ip++] | this.data[this.ip++] << 8; }
|
|
17
|
-
readDWORD(e = !1) { return e ? (this.data[this.ip++] << 24 | this.data[this.ip++] << 16 | this.data[this.ip++] << 8 | this.data[this.ip++]) >>> 0 : (this.data[this.ip++] | this.data[this.ip++] << 8 | this.data[this.ip++] << 16 | this.data[this.ip++] << 24) >>> 0; }
|
|
18
|
-
readByte() { return this.data[this.ip++]; }
|
|
19
|
-
readAt(e) { return this.data[this.ip + e]; }
|
|
20
|
-
readUInt8() { return this.readByte(); }
|
|
21
|
-
readInt8() { return this.readByte() << 24 >> 24; }
|
|
22
|
-
readUInt16() { return this.readWORD(); }
|
|
23
|
-
readInt16() { return this.readWORD() << 16 >> 16; }
|
|
24
|
-
readUInt32() { return this.readDWORD(); }
|
|
25
|
-
}
|
|
26
|
-
function t(t, n, a) { const i = new e(t, n), o = i.readString(4), s = i.readDWORD(a); return new r(o, s, i.ip); }
|
|
27
|
-
function n(e, n = 0, r, { padding: a = !0, bigEndian: i = !1 } = {}) { const o = [], s = r + n; let l = n; for (; l < s;) {
|
|
28
|
-
const r = t(e, l, i);
|
|
29
|
-
l = r.offset + r.size, a && 1 == (l - n & 1) && l++, o.push(r);
|
|
30
|
-
} return o; }
|
|
31
|
-
class r {
|
|
32
|
-
constructor(e, t, n) { Object.defineProperty(this, "type", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "size", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "offset", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), this.type = e, this.size = t, this.offset = n; }
|
|
33
|
-
}
|
|
34
|
-
const a = ["startAddrsOffset", "endAddrsOffset", "startloopAddrsOffset", "endloopAddrsOffset", "startAddrsCoarseOffset", "modLfoToPitch", "vibLfoToPitch", "modEnvToPitch", "initialFilterFc", "initialFilterQ", "modLfoToFilterFc", "modEnvToFilterFc", "endAddrsCoarseOffset", "modLfoToVolume", void 0, "chorusEffectsSend", "reverbEffectsSend", "pan", void 0, void 0, void 0, "delayModLFO", "freqModLFO", "delayVibLFO", "freqVibLFO", "delayModEnv", "attackModEnv", "holdModEnv", "decayModEnv", "sustainModEnv", "releaseModEnv", "keynumToModEnvHold", "keynumToModEnvDecay", "delayVolEnv", "attackVolEnv", "holdVolEnv", "decayVolEnv", "sustainVolEnv", "releaseVolEnv", "keynumToVolEnvHold", "keynumToVolEnvDecay", "instrument", void 0, "keyRange", "velRange", "startloopAddrsCoarseOffset", "keynum", "velocity", "initialAttenuation", void 0, "endloopAddrsCoarseOffset", "coarseTune", "fineTune", "sampleID", "sampleModes", void 0, "scaleTuning", "exclusiveClass", "overridingRootKey"];
|
|
35
|
-
class i {
|
|
36
|
-
constructor() { Object.defineProperty(this, "major", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "minor", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }); }
|
|
37
|
-
static parse(e) { const t = new i; return t.major = e.readInt8(), t.minor = e.readInt8(), t; }
|
|
38
|
-
}
|
|
39
|
-
class o {
|
|
40
|
-
constructor() { Object.defineProperty(this, "comment", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "copyright", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "creationDate", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "engineer", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "name", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "product", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "software", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "version", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "soundEngine", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "romName", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "romVersion", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }); }
|
|
41
|
-
static parse(t, n) { function r(e) { return n.find((t => t.type === e)); } function a(n) { return new e(t, n.offset); } function s(e) { const t = r(e); return t ? a(t).readString(t.size) : null; } function l(e) { const t = r(e); return t ? i.parse(a(t)) : null; } const d = new o; return d.comment = s("ICMT"), d.copyright = s("ICOP"), d.creationDate = s("ICRD"), d.engineer = s("IENG"), d.name = s("INAM"), d.product = s("IPRD"), d.software = s("ISFT"), d.version = l("ifil"), d.soundEngine = s("isng"), d.romName = s("irom"), d.romVersion = l("iver"), d; }
|
|
42
|
-
}
|
|
43
|
-
class s {
|
|
44
|
-
constructor() { Object.defineProperty(this, "generatorIndex", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "modulatorIndex", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }); }
|
|
45
|
-
static parse(e) { const t = new s; return t.generatorIndex = e.readWORD(), t.modulatorIndex = e.readWORD(), t; }
|
|
46
|
-
}
|
|
47
|
-
class l {
|
|
48
|
-
constructor() { Object.defineProperty(this, "presetName", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "preset", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "bank", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "presetBagIndex", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "library", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "genre", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "morphology", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }); }
|
|
49
|
-
get isEnd() { return "EOP" === this.presetName; }
|
|
50
|
-
static parse(e) { const t = new l; return t.presetName = e.readString(20), t.preset = e.readWORD(), t.bank = e.readWORD(), t.presetBagIndex = e.readWORD(), t.library = e.readDWORD(), t.genre = e.readDWORD(), t.morphology = e.readDWORD(), t; }
|
|
51
|
-
}
|
|
52
|
-
class d {
|
|
53
|
-
constructor(e, t) { Object.defineProperty(this, "lo", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "hi", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), this.lo = e, this.hi = t; }
|
|
54
|
-
in(e) { return this.lo <= e && e <= this.hi; }
|
|
55
|
-
static parse(e) { return new d(e.readByte(), e.readByte()); }
|
|
56
|
-
}
|
|
57
|
-
class u {
|
|
58
|
-
constructor() { Object.defineProperty(this, "sourceOper", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "destinationOper", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "value", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "amountSourceOper", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "transOper", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }); }
|
|
59
|
-
get type() { return a[this.destinationOper]; }
|
|
60
|
-
get isEnd() { return 0 === this.sourceOper && 0 === this.destinationOper && 0 === this.value && 0 === this.amountSourceOper && 0 === this.transOper; }
|
|
61
|
-
static parse(e) { const t = new u; switch (t.sourceOper = e.readWORD(), t.destinationOper = e.readWORD(), t.type) {
|
|
62
|
-
case "keyRange":
|
|
63
|
-
case "velRange":
|
|
64
|
-
t.value = d.parse(e);
|
|
65
|
-
break;
|
|
66
|
-
default: t.value = e.readInt16();
|
|
67
|
-
} return t.amountSourceOper = e.readWORD(), t.transOper = e.readWORD(), t; }
|
|
68
|
-
}
|
|
69
|
-
class c {
|
|
70
|
-
constructor() { Object.defineProperty(this, "code", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "value", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }); }
|
|
71
|
-
get type() { return a[this.code]; }
|
|
72
|
-
get isEnd() { return 0 === this.code && 0 === this.value; }
|
|
73
|
-
static parse(e) { const t = new c; switch (t.code = e.readWORD(), t.type) {
|
|
74
|
-
case "keyRange":
|
|
75
|
-
case "velRange":
|
|
76
|
-
t.value = d.parse(e);
|
|
77
|
-
break;
|
|
78
|
-
default: t.value = e.readInt16();
|
|
79
|
-
} return t; }
|
|
80
|
-
}
|
|
81
|
-
class f {
|
|
82
|
-
constructor() { Object.defineProperty(this, "instrumentName", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "instrumentBagIndex", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }); }
|
|
83
|
-
get isEnd() { return "EOI" === this.instrumentName; }
|
|
84
|
-
static parse(e) { const t = new f; return t.instrumentName = e.readString(20), t.instrumentBagIndex = e.readWORD(), t; }
|
|
85
|
-
}
|
|
86
|
-
class p {
|
|
87
|
-
constructor() { Object.defineProperty(this, "sampleName", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "start", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "end", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "loopStart", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "loopEnd", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "sampleRate", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "originalPitch", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "pitchCorrection", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "sampleLink", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "sampleType", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }); }
|
|
88
|
-
get isEnd() { return "EOS" === this.sampleName; }
|
|
89
|
-
static parse(e, t) { const n = new p; return n.sampleName = e.readString(20), n.start = e.readDWORD(), n.end = e.readDWORD(), n.loopStart = e.readDWORD(), n.loopEnd = e.readDWORD(), n.sampleRate = e.readDWORD(), n.originalPitch = e.readByte(), n.pitchCorrection = e.readInt8(), n.sampleLink = e.readWORD(), n.sampleType = e.readWORD(), t || (n.loopStart -= n.start, n.loopEnd -= n.start), n; }
|
|
90
|
-
}
|
|
91
|
-
class m {
|
|
92
|
-
constructor(e, t, n) { Object.defineProperty(this, "min", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "max", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), Object.defineProperty(this, "value", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), this.min = e, this.value = t, this.max = n; }
|
|
93
|
-
clamp() { return Math.max(this.min, Math.min(this.value, this.max)); }
|
|
94
|
-
}
|
|
95
|
-
function b(e, r = {}) { const a = n(e, 0, e.length, r); if (1 !== a.length)
|
|
96
|
-
throw new Error("wrong chunk length"); const i = a[0]; if (null === i)
|
|
97
|
-
throw new Error("chunk not found"); function s(e, t, n) { const r = v(e, t, "LIST", "pdta"); if (9 !== r.length)
|
|
98
|
-
throw new Error("invalid pdta chunk"); return { presetHeaders: g(r[0], t), presetZone: w(r[1], t), presetModulators: P(r[2], t), presetGenerators: k(r[3], t), instruments: O(r[4], t), instrumentZone: E(r[5], t), instrumentModulators: R(r[6], t), instrumentGenerators: D(r[7], t), sampleHeaders: j(r[8], t, n) }; } const l = function (e, n, r = {}) { const a = v(e, n, "RIFF", "sfbk", r); if (3 !== a.length)
|
|
99
|
-
throw new Error("invalid sfbk structure"); const i = function (e, t) { const n = v(e, t, "LIST", "INFO"); return o.parse(t, n); }(a[0], n), l = 3 === i.version.major; return l && "LIST" !== a[2].type && (a[2] = t(n, a[2].offset - 9, !1)), { info: i, samplingData: h(a[1], n), ...s(a[2], n, l) }; }(i, e, r), d = 3 === l.info.version.major; return { ...l, samples: T(l.sampleHeaders, l.samplingData.offsetMSB, l.samplingData.offsetLSB, e, d) }; }
|
|
100
|
-
function v(t, r, a, i, o = {}) { if (t.type !== a)
|
|
101
|
-
throw new Error("invalid chunk type:" + t.type); const s = new e(r, t.offset), l = s.readString(4); if (l !== i)
|
|
102
|
-
throw new Error("invalid signature:" + l); return n(r, s.ip, t.size - 4, o); }
|
|
103
|
-
function h(e, t) { const n = v(e, t, "LIST", "sdta"); return { offsetMSB: n[0].offset, offsetLSB: n[1]?.offset }; }
|
|
104
|
-
function y(t, n, r, a, i, o) { const s = []; if (t.type !== r)
|
|
105
|
-
throw new Error("invalid chunk type:" + t.type); const l = new e(n, t.offset), d = t.offset + t.size; for (; l.ip < d;) {
|
|
106
|
-
const e = a.parse(l, o);
|
|
107
|
-
if (i && i(e))
|
|
108
|
-
break;
|
|
109
|
-
s.push(e);
|
|
110
|
-
} return s; }
|
|
111
|
-
const g = (e, t) => y(e, t, "phdr", l, (e => e.isEnd)), w = (e, t) => y(e, t, "pbag", s), O = (e, t) => y(e, t, "inst", f, (e => e.isEnd)), E = (e, t) => y(e, t, "ibag", s), P = (e, t) => y(e, t, "pmod", u, (e => e.isEnd)), R = (e, t) => y(e, t, "imod", u, (e => e.isEnd)), k = (e, t) => y(e, t, "pgen", c, (e => e.isEnd)), D = (e, t) => y(e, t, "igen", c), j = (e, t, n) => y(e, t, "shdr", p, (e => e.isEnd), n);
|
|
112
|
-
function T(e, t, n, r, a) { return e.map((e => { let { start: n, end: i } = e; return a || (n *= 2, i *= 2), new Uint8Array(r.subarray(t + n, t + i)); })); }
|
|
113
|
-
function I(e) { const t = {}; for (const n of e) {
|
|
114
|
-
const e = n.type;
|
|
115
|
-
if (void 0 !== e)
|
|
116
|
-
if ("keyRange" === e || "velRange" === e)
|
|
117
|
-
t[e] = n.value;
|
|
118
|
-
else {
|
|
119
|
-
const r = L[e];
|
|
120
|
-
t[e] = new m(r.min, n.value, r.max);
|
|
121
|
-
}
|
|
122
|
-
} return t; }
|
|
123
|
-
const M = -32768, F = 32767, L = { startAddrsOffset: new m(0, 0, F), endAddrsOffset: new m(M, 0, 0), startloopAddrsOffset: new m(M, 0, F), endloopAddrsOffset: new m(M, 0, F), startAddrsCoarseOffset: new m(0, 0, F), modLfoToPitch: new m(-12e3, 0, 12e3), vibLfoToPitch: new m(-12e3, 0, 12e3), modEnvToPitch: new m(-12e3, 0, 12e3), initialFilterFc: new m(1500, 13500, 13500), initialFilterQ: new m(0, 0, 960), modLfoToFilterFc: new m(-12e3, 0, 12e3), modEnvToFilterFc: new m(-12e3, 0, 12e3), endAddrsCoarseOffset: new m(M, 0, 0), modLfoToVolume: new m(-960, 0, 960), chorusEffectsSend: new m(0, 0, 1e3), reverbEffectsSend: new m(0, 0, 1e3), pan: new m(-500, 0, 500), delayModLFO: new m(-12e3, -12e3, 5e3), freqModLFO: new m(-16e3, 0, 4500), delayVibLFO: new m(-12e3, -12e3, 5e3), freqVibLFO: new m(-16e3, 0, 4500), delayModEnv: new m(-12e3, -12e3, 5e3), attackModEnv: new m(-12e3, -12e3, 8e3), holdModEnv: new m(-12e3, -12e3, 5e3), decayModEnv: new m(-12e3, -12e3, 8e3), sustainModEnv: new m(0, 0, 1e3), releaseModEnv: new m(-12e3, -12e3, 8e3), keynumToModEnvHold: new m(-1200, 0, 1200), keynumToModEnvDecay: new m(-1200, 0, 1200), delayVolEnv: new m(-12e3, -12e3, 5e3), attackVolEnv: new m(-12e3, -12e3, 8e3), holdVolEnv: new m(-12e3, -12e3, 5e3), decayVolEnv: new m(-12e3, -12e3, 8e3), sustainVolEnv: new m(0, 0, 1440), releaseVolEnv: new m(-12e3, -12e3, 8e3), keynumToVolEnvHold: new m(-1200, 0, 1200), keynumToVolEnvDecay: new m(-1200, 0, 1200), instrument: new m(-1, -1, F), keyRange: new d(0, 127), velRange: new d(0, 127), startloopAddrsCoarseOffset: new m(M, 0, F), keynum: new m(-1, -1, 127), velocity: new m(-1, -1, 127), initialAttenuation: new m(0, 0, 1440), endloopAddrsCoarseOffset: new m(M, 0, F), coarseTune: new m(-120, 0, 120), fineTune: new m(-99, 0, 99), sampleID: new m(-1, -1, F), sampleModes: new m(0, 0, 3), scaleTuning: new m(0, 100, 100), exclusiveClass: new m(0, 0, 127), overridingRootKey: new m(-1, -1, 127) };
|
|
124
|
-
exports.defaultInstrumentZone = L;
|
|
125
|
-
class V {
|
|
126
|
-
constructor(e) { Object.defineProperty(this, "parsed", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), this.parsed = e; }
|
|
127
|
-
getGenerators(e, t, n, r) { const a = new Array(r - n); for (let i = n; i < r; i++) {
|
|
128
|
-
const r = t[i].generatorIndex, o = t[i + 1].generatorIndex;
|
|
129
|
-
a[i - n] = e.slice(r, o);
|
|
130
|
-
} return a; }
|
|
131
|
-
getPresetGenerators(e) { const t = this.parsed.presetHeaders[e], n = this.parsed.presetHeaders[e + 1], r = n ? n.presetBagIndex : this.parsed.presetZone.length - 1; return this.getGenerators(this.parsed.presetGenerators, this.parsed.presetZone, t.presetBagIndex, r); }
|
|
132
|
-
getInstrumentGenerators(e) { const t = this.parsed.instruments[e], n = this.parsed.instruments[e + 1], r = n ? n.instrumentBagIndex : this.parsed.instrumentZone.length - 1; return this.getGenerators(this.parsed.instrumentGenerators, this.parsed.instrumentZone, t.instrumentBagIndex, r); }
|
|
133
|
-
findInstrumentZone(e, t, n = 100) { const r = this.getInstrumentGenerators(e); let a; for (let e = 0; e < r.length; e++) {
|
|
134
|
-
const i = I(r[e]);
|
|
135
|
-
if (void 0 !== i.sampleID) {
|
|
136
|
-
if ((!i.keyRange || i.keyRange.in(t)) && (!i.velRange || i.velRange.in(n)))
|
|
137
|
-
return a ? { ...a, ...i } : i;
|
|
138
|
-
}
|
|
139
|
-
else
|
|
140
|
-
a = i;
|
|
141
|
-
} }
|
|
142
|
-
findInstrument(e, t, n = 100) { const r = this.getPresetGenerators(e); let a; for (let e = 0; e < r.length; e++) {
|
|
143
|
-
const i = I(r[e]);
|
|
144
|
-
if (void 0 === i.instrument) {
|
|
145
|
-
a = i;
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
if (i.keyRange && !i.keyRange.in(t))
|
|
149
|
-
continue;
|
|
150
|
-
if (i.velRange && !i.velRange.in(n))
|
|
151
|
-
continue;
|
|
152
|
-
const o = this.findInstrumentZone(i.instrument.value, t, n);
|
|
153
|
-
if (o)
|
|
154
|
-
return a ? this.getInstrument({ ...a, ...i }, o) : this.getInstrument(i, o);
|
|
155
|
-
} return null; }
|
|
156
|
-
getInstrument(e, t) { const n = { ...L, ...t }, r = Object.keys(e); for (const t of r)
|
|
157
|
-
if ("keyRange" !== t && "velRange" !== t) {
|
|
158
|
-
const r = n[t], a = e[t];
|
|
159
|
-
n[t] = new m(r.min, r.value + a.value, r.max);
|
|
160
|
-
} return n; }
|
|
161
|
-
getInstrumentKey(e, t, n, r = 100) { const a = this.parsed.presetHeaders.findIndex((n => n.preset === t && n.bank === e)); if (a < 0)
|
|
162
|
-
return console.warn("preset not found: bank=%s instrument=%s", e, t), null; const i = this.findInstrument(a, n, r); if (!i)
|
|
163
|
-
return console.warn("instrument not found: bank=%s instrument=%s", e, t), null; const o = this.parsed.samples[i.sampleID.value], s = this.parsed.sampleHeaders[i.sampleID.value], l = i.coarseTune.clamp() + i.fineTune.clamp() / 100, d = -1 === i.overridingRootKey.value ? s.originalPitch : i.overridingRootKey.clamp(), u = l + s.pitchCorrection / 100 - d, c = i.scaleTuning.clamp() / 100; return { start: 32768 * i.startAddrsCoarseOffset.clamp() + i.startAddrsOffset.clamp(), end: 32768 * i.endAddrsCoarseOffset.clamp() + i.endAddrsOffset.clamp(), loopStart: s.loopStart + 32768 * i.startloopAddrsCoarseOffset.clamp() + i.startloopAddrsOffset.clamp(), loopEnd: s.loopEnd + 32768 * i.endloopAddrsCoarseOffset.clamp() + i.endloopAddrsOffset.clamp(), modLfoToPitch: i.modLfoToPitch.clamp(), vibLfoToPitch: i.vibLfoToPitch.clamp(), modEnvToPitch: i.modEnvToPitch.clamp(), initialFilterFc: i.initialFilterFc.clamp(), initialFilterQ: i.initialFilterQ.clamp(), modLfoToFilterFc: i.modLfoToFilterFc.clamp(), modEnvToFilterFc: i.modEnvToFilterFc.clamp(), modLfoToVolume: i.modLfoToVolume.clamp(), chorusEffectsSend: i.chorusEffectsSend.clamp() / 1e3, reverbEffectsSend: i.reverbEffectsSend.clamp() / 1e3, pan: i.pan.clamp(), delayModLFO: S(i.delayModLFO.clamp()), freqModLFO: i.freqModLFO.clamp(), delayVibLFO: S(i.delayVibLFO.clamp()), freqVibLFO: i.freqVibLFO.clamp(), modDelay: S(i.delayModEnv.clamp()), modAttack: S(i.attackModEnv.clamp()), modHold: S(i.holdModEnv.clamp()), modDecay: S(i.decayModEnv.clamp()), modSustain: i.sustainModEnv.clamp() / 1e3, modRelease: S(i.releaseModEnv.clamp()), keynumToModEnvHold: i.keynumToModEnvHold.clamp(), keynumToModEnvDecay: i.keynumToModEnvDecay.clamp(), volDelay: S(i.delayVolEnv.clamp()), volAttack: S(i.attackVolEnv.clamp()), volHold: S(i.holdVolEnv.clamp()), volDecay: S(i.decayVolEnv.clamp()), volSustain: i.sustainVolEnv.clamp() / 1e3, volRelease: S(i.releaseVolEnv.clamp()), keynumToVolEnvHold: i.keynumToVolEnvHold.clamp(), keynumToVolEnvDecay: i.keynumToVolEnvDecay.clamp(), keyRange: i.keyRange, velRange: i.velRange, keynum: i.keynum.clamp(), velocity: i.velocity.clamp(), initialAttenuation: i.initialAttenuation.clamp(), playbackRate: e => Math.pow(Math.pow(2, 1 / 12), (e + u) * c), sample: o, sampleRate: s.sampleRate, sampleName: s.sampleName, sampleModes: i.sampleModes.clamp(), exclusiveClass: i.exclusiveClass.clamp() }; }
|
|
164
|
-
getPresetNames() { const e = {}; return this.parsed.presetHeaders.forEach((t => { e[t.bank] || (e[t.bank] = {}), e[t.bank][t.preset] = t.presetName; })), e; }
|
|
165
|
-
}
|
|
166
|
-
exports.SoundFont = V;
|
|
167
|
-
function S(e) { return Math.pow(2, e / 1200); }
|
|
168
|
-
exports.default = null;
|
|
169
|
-
//# sourceMappingURL=/sm/2e6aae3211f3eeb8dde2dd5dcc4214014a112db10099ab21cf37b9a7d590cd62.map
|