@marmooo/midy 0.1.6 → 0.1.7

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.
Files changed (37) hide show
  1. package/esm/midy-GM1.d.ts +5 -4
  2. package/esm/midy-GM1.d.ts.map +1 -1
  3. package/esm/midy-GM1.js +45 -16
  4. package/esm/midy-GM2.d.ts +5 -2
  5. package/esm/midy-GM2.d.ts.map +1 -1
  6. package/esm/midy-GM2.js +176 -66
  7. package/esm/midy-GMLite.d.ts +5 -4
  8. package/esm/midy-GMLite.d.ts.map +1 -1
  9. package/esm/midy-GMLite.js +45 -16
  10. package/esm/midy.d.ts +5 -2
  11. package/esm/midy.d.ts.map +1 -1
  12. package/esm/midy.js +177 -67
  13. package/package.json +5 -1
  14. package/script/midy-GM1.d.ts +5 -4
  15. package/script/midy-GM1.d.ts.map +1 -1
  16. package/script/midy-GM1.js +48 -19
  17. package/script/midy-GM2.d.ts +5 -2
  18. package/script/midy-GM2.d.ts.map +1 -1
  19. package/script/midy-GM2.js +179 -69
  20. package/script/midy-GMLite.d.ts +5 -4
  21. package/script/midy-GMLite.d.ts.map +1 -1
  22. package/script/midy-GMLite.js +48 -19
  23. package/script/midy.d.ts +5 -2
  24. package/script/midy.d.ts.map +1 -1
  25. package/script/midy.js +180 -70
  26. package/esm/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.6/+esm.d.ts +0 -149
  27. package/esm/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.6/+esm.d.ts.map +0 -1
  28. package/esm/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.6/+esm.js +0 -180
  29. package/esm/deps/cdn.jsdelivr.net/npm/midi-file@1.2.4/+esm.d.ts +0 -84
  30. package/esm/deps/cdn.jsdelivr.net/npm/midi-file@1.2.4/+esm.d.ts.map +0 -1
  31. package/esm/deps/cdn.jsdelivr.net/npm/midi-file@1.2.4/+esm.js +0 -216
  32. package/script/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.6/+esm.d.ts +0 -149
  33. package/script/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.6/+esm.d.ts.map +0 -1
  34. package/script/deps/cdn.jsdelivr.net/npm/@marmooo/soundfont-parser@0.0.6/+esm.js +0 -190
  35. package/script/deps/cdn.jsdelivr.net/npm/midi-file@1.2.4/+esm.d.ts +0 -84
  36. package/script/deps/cdn.jsdelivr.net/npm/midi-file@1.2.4/+esm.d.ts.map +0 -1
  37. package/script/deps/cdn.jsdelivr.net/npm/midi-file@1.2.4/+esm.js +0 -221
@@ -1,190 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultInstrumentZone = exports.SoundFont = exports.RangeGeneratorNames = void 0;
4
- exports.createInstrumentGeneratorObject = S;
5
- exports.createPresetGeneratorObject = V;
6
- exports.isRangeGenerator = L;
7
- exports.parse = p;
8
- exports.timecentToSecond = H;
9
- /**
10
- * Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.39.0.
11
- * Original file: /npm/@marmooo/soundfont-parser@0.0.6/esm/mod.js
12
- *
13
- * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
14
- */
15
- class e {
16
- constructor(e, t) { Object.defineProperty(this, "data", { enumerable: !0, configurable: !0, writable: !0, value: e }), Object.defineProperty(this, "offset", { enumerable: !0, configurable: !0, writable: !0, value: t }); }
17
- readString(e) { const t = this.data.subarray(this.offset, this.offset += e), n = String.fromCharCode(...Array.from(t)), r = n.indexOf("\0"); return r > 0 ? n.substring(0, r) : n; }
18
- readWORD() { return this.data[this.offset++] | this.data[this.offset++] << 8; }
19
- readDWORD(e = !1) { return e ? (this.data[this.offset++] << 24 | this.data[this.offset++] << 16 | this.data[this.offset++] << 8 | this.data[this.offset++]) >>> 0 : (this.data[this.offset++] | this.data[this.offset++] << 8 | this.data[this.offset++] << 16 | this.data[this.offset++] << 24) >>> 0; }
20
- readByte() { return this.data[this.offset++]; }
21
- readAt(e) { return this.data[this.offset + e]; }
22
- readUInt8() { return this.readByte(); }
23
- readInt8() { return this.readByte() << 24 >> 24; }
24
- readUInt16() { return this.readWORD(); }
25
- readInt16() { return this.readWORD() << 16 >> 16; }
26
- readUInt32() { return this.readDWORD(); }
27
- }
28
- function t(t, n, a) { const o = new e(t, n), s = o.readString(4), i = o.readDWORD(a); return new r(s, i, o.offset); }
29
- function n(e, n = 0, r, { padding: a = !0, bigEndian: o = !1 } = {}) { const s = [], i = r + n; let l = n; for (; l < i;) {
30
- const r = t(e, l, o);
31
- l = r.offset + r.size, a && 1 == (l - n & 1) && l++, s.push(r);
32
- } return s; }
33
- class r {
34
- constructor(e, t, n) { Object.defineProperty(this, "type", { enumerable: !0, configurable: !0, writable: !0, value: e }), Object.defineProperty(this, "size", { enumerable: !0, configurable: !0, writable: !0, value: t }), Object.defineProperty(this, "offset", { enumerable: !0, configurable: !0, writable: !0, value: n }); }
35
- }
36
- 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"];
37
- class o {
38
- constructor(e, t) { Object.defineProperty(this, "major", { enumerable: !0, configurable: !0, writable: !0, value: e }), Object.defineProperty(this, "minor", { enumerable: !0, configurable: !0, writable: !0, value: t }); }
39
- static parse(e) { const t = e.readInt8(), n = e.readInt8(); return new o(t, n); }
40
- }
41
- class s {
42
- constructor(e, t, n, r, a, o, s, i, l, d, u) { Object.defineProperty(this, "comment", { enumerable: !0, configurable: !0, writable: !0, value: e }), Object.defineProperty(this, "copyright", { enumerable: !0, configurable: !0, writable: !0, value: t }), Object.defineProperty(this, "creationDate", { enumerable: !0, configurable: !0, writable: !0, value: n }), Object.defineProperty(this, "engineer", { enumerable: !0, configurable: !0, writable: !0, value: r }), Object.defineProperty(this, "name", { enumerable: !0, configurable: !0, writable: !0, value: a }), Object.defineProperty(this, "product", { enumerable: !0, configurable: !0, writable: !0, value: o }), Object.defineProperty(this, "software", { enumerable: !0, configurable: !0, writable: !0, value: s }), Object.defineProperty(this, "version", { enumerable: !0, configurable: !0, writable: !0, value: i }), Object.defineProperty(this, "soundEngine", { enumerable: !0, configurable: !0, writable: !0, value: l }), Object.defineProperty(this, "romName", { enumerable: !0, configurable: !0, writable: !0, value: d }), Object.defineProperty(this, "romVersion", { enumerable: !0, configurable: !0, writable: !0, value: u }); }
43
- static parse(t, n) { function r(e) { for (let t = 0; t < n.length; t++)
44
- if (n[t].type === e)
45
- return n[t]; } function a(n) { return new e(t, n.offset); } function i(e) { const t = r(e); return t ? a(t).readString(t.size) : null; } function l(e) { const t = r(e); return t ? o.parse(a(t)) : null; } const d = i("ICMT"), u = i("ICOP"), f = i("ICRD"), c = i("IENG"), b = i("INAM"), m = i("IPRD"), p = i("ISFT"), h = l("ifil"), v = i("isng"), g = i("irom"), w = l("iver"); return new s(d, u, f, c, b, m, p, h, v, g, w); }
46
- }
47
- class i {
48
- constructor(e, t) { Object.defineProperty(this, "generatorIndex", { enumerable: !0, configurable: !0, writable: !0, value: e }), Object.defineProperty(this, "modulatorIndex", { enumerable: !0, configurable: !0, writable: !0, value: t }); }
49
- static parse(e) { const t = e.readWORD(), n = e.readWORD(); return new i(t, n); }
50
- }
51
- class l {
52
- constructor(e, t, n, r, a, o, s) { Object.defineProperty(this, "presetName", { enumerable: !0, configurable: !0, writable: !0, value: e }), Object.defineProperty(this, "preset", { enumerable: !0, configurable: !0, writable: !0, value: t }), Object.defineProperty(this, "bank", { enumerable: !0, configurable: !0, writable: !0, value: n }), Object.defineProperty(this, "presetBagIndex", { enumerable: !0, configurable: !0, writable: !0, value: r }), Object.defineProperty(this, "library", { enumerable: !0, configurable: !0, writable: !0, value: a }), Object.defineProperty(this, "genre", { enumerable: !0, configurable: !0, writable: !0, value: o }), Object.defineProperty(this, "morphology", { enumerable: !0, configurable: !0, writable: !0, value: s }); }
53
- get isEnd() { return "EOP" === this.presetName; }
54
- static parse(e) { const t = e.readString(20), n = e.readWORD(), r = e.readWORD(), a = e.readWORD(), o = e.readDWORD(), s = e.readDWORD(), i = e.readDWORD(); return new l(t, n, r, a, o, s, i); }
55
- }
56
- class d {
57
- 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; }
58
- in(e) { return this.lo <= e && e <= this.hi; }
59
- static parse(e) { const t = e.readByte(), n = e.readByte(); return new d(t, n); }
60
- }
61
- class u {
62
- constructor(e, t, n, r, a) { Object.defineProperty(this, "sourceOper", { enumerable: !0, configurable: !0, writable: !0, value: e }), Object.defineProperty(this, "destinationOper", { enumerable: !0, configurable: !0, writable: !0, value: t }), Object.defineProperty(this, "value", { enumerable: !0, configurable: !0, writable: !0, value: n }), Object.defineProperty(this, "amountSourceOper", { enumerable: !0, configurable: !0, writable: !0, value: r }), Object.defineProperty(this, "transOper", { enumerable: !0, configurable: !0, writable: !0, value: a }); }
63
- get isEnd() { return 0 === this.sourceOper && 0 === this.destinationOper && 0 === this.value && 0 === this.amountSourceOper && 0 === this.transOper; }
64
- static parse(e) { const t = e.readWORD(), n = e.readWORD(), r = e.readInt16(), a = e.readWORD(), o = e.readWORD(); return new u(t, n, r, a, o); }
65
- }
66
- class f {
67
- constructor(e, t) { Object.defineProperty(this, "code", { enumerable: !0, configurable: !0, writable: !0, value: e }), Object.defineProperty(this, "value", { enumerable: !0, configurable: !0, writable: !0, value: t }); }
68
- get type() { return a[this.code]; }
69
- get isEnd() { return 0 === this.code && 0 === this.value; }
70
- static parse(e) { const t = e.readWORD(); let n; switch (a[t]) {
71
- case "keyRange":
72
- case "velRange":
73
- n = d.parse(e);
74
- break;
75
- default: n = e.readInt16();
76
- } return new f(t, n); }
77
- }
78
- class c {
79
- 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 }); }
80
- get isEnd() { return "EOI" === this.instrumentName; }
81
- static parse(e) { const t = new c; return t.instrumentName = e.readString(20), t.instrumentBagIndex = e.readWORD(), t; }
82
- }
83
- class b {
84
- constructor(e, t, n, r, a, o, s, i, l, d) { Object.defineProperty(this, "sampleName", { enumerable: !0, configurable: !0, writable: !0, value: e }), Object.defineProperty(this, "start", { enumerable: !0, configurable: !0, writable: !0, value: t }), Object.defineProperty(this, "end", { enumerable: !0, configurable: !0, writable: !0, value: n }), Object.defineProperty(this, "loopStart", { enumerable: !0, configurable: !0, writable: !0, value: r }), Object.defineProperty(this, "loopEnd", { enumerable: !0, configurable: !0, writable: !0, value: a }), Object.defineProperty(this, "sampleRate", { enumerable: !0, configurable: !0, writable: !0, value: o }), Object.defineProperty(this, "originalPitch", { enumerable: !0, configurable: !0, writable: !0, value: s }), Object.defineProperty(this, "pitchCorrection", { enumerable: !0, configurable: !0, writable: !0, value: i }), Object.defineProperty(this, "sampleLink", { enumerable: !0, configurable: !0, writable: !0, value: l }), Object.defineProperty(this, "sampleType", { enumerable: !0, configurable: !0, writable: !0, value: d }); }
85
- get isEnd() { return "EOS" === this.sampleName; }
86
- static parse(e, t) { const n = e.readString(20), r = e.readDWORD(), a = e.readDWORD(); let o = e.readDWORD(), s = e.readDWORD(); const i = e.readDWORD(), l = e.readByte(), d = e.readInt8(), u = e.readWORD(), f = e.readWORD(); return t || (o -= r, s -= r), new b(n, r, a, o, s, i, l, d, u, f); }
87
- }
88
- class m {
89
- 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; }
90
- clamp() { return Math.max(this.min, Math.min(this.value, this.max)); }
91
- }
92
- function p(e, r = {}) { const a = n(e, 0, e.length, r); if (1 !== a.length)
93
- throw new Error("wrong chunk length"); const o = a[0]; if (null === o)
94
- throw new Error("chunk not found"); function i(e, t, n) { const r = h(e, t, "LIST", "pdta"); if (9 !== r.length)
95
- throw new Error("invalid pdta chunk"); return { presetHeaders: w(r[0], t), presetZone: y(r[1], t), presetModulators: P(r[2], t), presetGenerators: R(r[3], t), instruments: O(r[4], t), instrumentZone: E(r[5], t), instrumentModulators: D(r[6], t), instrumentGenerators: j(r[7], t), sampleHeaders: k(r[8], t, n) }; } const l = function (e, n, r = {}) { const a = h(e, n, "RIFF", "sfbk", r); if (3 !== a.length)
96
- throw new Error("invalid sfbk structure"); const o = function (e, t) { const n = h(e, t, "LIST", "INFO"); return s.parse(t, n); }(a[0], n), l = 3 === o.version.major; return l && "LIST" !== a[2].type && (a[2] = t(n, a[2].offset - 9, !1)), { info: o, samplingData: v(a[1], n), ...i(a[2], n, l) }; }(o, e, r), d = 3 === l.info.version.major; return { ...l, samples: T(l.sampleHeaders, l.samplingData.offsetMSB, l.samplingData.offsetLSB, e, d) }; }
97
- function h(t, r, a, o, s = {}) { if (t.type !== a)
98
- throw new Error("invalid chunk type:" + t.type); const i = new e(r, t.offset), l = i.readString(4); if (l !== o)
99
- throw new Error("invalid signature:" + l); return n(r, i.offset, t.size - 4, s); }
100
- function v(e, t) { const n = h(e, t, "LIST", "sdta"); return { offsetMSB: n[0].offset, offsetLSB: n[1]?.offset }; }
101
- function g(t, n, r, a, o, s) { const i = []; if (t.type !== r)
102
- throw new Error("invalid chunk type:" + t.type); const l = new e(n, t.offset), d = t.offset + t.size; for (; l.offset < d;) {
103
- const e = a.parse(l, s);
104
- if (o && o(e))
105
- break;
106
- i.push(e);
107
- } return i; }
108
- const w = (e, t) => g(e, t, "phdr", l, (e => e.isEnd)), y = (e, t) => g(e, t, "pbag", i), O = (e, t) => g(e, t, "inst", c, (e => e.isEnd)), E = (e, t) => g(e, t, "ibag", i), P = (e, t) => g(e, t, "pmod", u, (e => e.isEnd)), D = (e, t) => g(e, t, "imod", u, (e => e.isEnd)), R = (e, t) => g(e, t, "pgen", f, (e => e.isEnd)), j = (e, t) => g(e, t, "igen", f), k = (e, t, n) => g(e, t, "shdr", b, (e => e.isEnd), n);
109
- function T(e, t, n, r, a) { return e.map((e => { let { start: n, end: o } = e; return a || (n *= 2, o *= 2), new Uint8Array(r.subarray(t + n, t + o)); })); }
110
- const I = new Map(a.map(((e, t) => [e, t]))), M = ["keyRange", "velRange"], F = new Set(["startAddrsOffset", "endAddrsOffset", "startloopAddrsOffset", "endloopAddrsOffset", "startAddrsCoarseOffset", "endAddrsCoarseOffset", "startloopAddrsCoarseOffset", "endloopAddrsCoarseOffset", "sampleModes", "exclusiveClass", "overridingRootKey", "keynum", "velocity"].map((e => I.get(e)))), A = [["keynum", "keyRange"], ["velocity", "velRange"]];
111
- exports.RangeGeneratorNames = M;
112
- function L(e) { return M.includes(e); }
113
- function V(e) { const t = {}; for (let n = 0; n < e.length; n++) {
114
- const r = e[n], a = r.type;
115
- if (void 0 !== a && !F.has(r.code))
116
- if (L(a))
117
- t[a] = r.value;
118
- else {
119
- const e = a, n = W[e];
120
- t[e] = new m(n.min, r.value, n.max);
121
- }
122
- } return t; }
123
- function S(e) { const t = {}; for (let n = 0; n < e.length; n++) {
124
- const r = e[n], a = r.type;
125
- if (void 0 !== a)
126
- if (L(a))
127
- t[a] = r.value;
128
- else {
129
- const e = a, n = W[e];
130
- t[e] = new m(n.min, r.value, n.max);
131
- }
132
- } for (let e = 0; e < A.length; e++) {
133
- const [n, r] = A[e], a = t[n];
134
- a instanceof m && 0 <= a.value && (t[r] = new d(a.value, a.value));
135
- } return t; }
136
- const C = -32768, x = 32767, W = { startAddrsOffset: new m(0, 0, x), endAddrsOffset: new m(C, 0, 0), startloopAddrsOffset: new m(C, 0, x), endloopAddrsOffset: new m(C, 0, x), startAddrsCoarseOffset: new m(0, 0, x), 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(C, 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, x), keyRange: new d(0, 127), velRange: new d(0, 127), startloopAddrsCoarseOffset: new m(C, 0, x), keynum: new m(-1, -1, 127), velocity: new m(-1, -1, 127), initialAttenuation: new m(0, 0, 1440), endloopAddrsCoarseOffset: new m(C, 0, x), coarseTune: new m(-120, 0, 120), fineTune: new m(-99, 0, 99), sampleID: new m(-1, -1, x), sampleModes: new m(0, 0, 3), scaleTuning: new m(0, 100, 100), exclusiveClass: new m(0, 0, 127), overridingRootKey: new m(-1, -1, 127) };
137
- exports.defaultInstrumentZone = W;
138
- class B {
139
- constructor(e) { Object.defineProperty(this, "parsed", { enumerable: !0, configurable: !0, writable: !0, value: void 0 }), this.parsed = e; }
140
- getGenerators(e, t, n, r) { const a = new Array(r - n); for (let o = n; o < r; o++) {
141
- const r = t[o].generatorIndex, s = t[o + 1].generatorIndex;
142
- a[o - n] = e.slice(r, s);
143
- } return a; }
144
- 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); }
145
- 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); }
146
- findInstrumentZone(e, t, n) { const r = this.getInstrumentGenerators(e); let a; for (let e = 0; e < r.length; e++) {
147
- const o = S(r[e]);
148
- if (void 0 !== o.sampleID) {
149
- if ((!o.keyRange || o.keyRange.in(t)) && (!o.velRange || o.velRange.in(n)))
150
- return a ? { ...a, ...o } : o;
151
- }
152
- else
153
- a = o;
154
- } }
155
- findInstrument(e, t, n) { const r = this.getPresetGenerators(e); let a; for (let e = 0; e < r.length; e++) {
156
- const o = V(r[e]);
157
- if (void 0 === o.instrument) {
158
- a = o;
159
- continue;
160
- }
161
- if (o.keyRange && !o.keyRange.in(t))
162
- continue;
163
- if (o.velRange && !o.velRange.in(n))
164
- continue;
165
- const s = this.findInstrumentZone(o.instrument.value, t, n);
166
- if (s)
167
- return a ? this.getInstrument({ ...a, ...o }, s) : this.getInstrument(o, s);
168
- } return null; }
169
- getInstrument(e, t) { const n = { ...W, ...t }, r = Object.keys(e); for (let t = 0; t < r.length; t++) {
170
- const a = r[t];
171
- if (L(a))
172
- continue;
173
- const o = n[a], s = e[a];
174
- n[a] = new m(o.min, o.value + s.value, o.max);
175
- } return n; }
176
- getInstrumentKey(e, t, n, r) { const a = this.parsed.presetHeaders.findIndex((n => n.preset === t && n.bank === e)); if (a < 0)
177
- return console.warn("preset not found: bank=%s instrument=%s", e, t), null; const o = this.findInstrument(a, n, r); if (!o)
178
- return console.warn("instrument not found: bank=%s instrument=%s", e, t), null; const s = {}, i = Object.keys(o); for (let e = 0; e < i.length; e++) {
179
- const t = i[e];
180
- L(t) ? s[t] = o[t] : s[t] = o[t].clamp();
181
- } const l = H(s.holdModEnv + (n - 60) * s.keynumToModEnvHold), d = H(s.decayModEnv + (n - 60) * s.keynumToModEnvDecay), u = H(s.holdVolEnv + (n - 60) * s.keynumToVolEnvHold), f = H(s.decayVolEnv + (n - 60) * s.keynumToVolEnvDecay), c = this.parsed.samples[s.sampleID], b = this.parsed.sampleHeaders[s.sampleID], m = s.coarseTune + s.fineTune / 100, p = -1 === s.overridingRootKey ? b.originalPitch : s.overridingRootKey, h = m + b.pitchCorrection / 100 - p, v = s.scaleTuning / 100; return { start: 32768 * s.startAddrsCoarseOffset + s.startAddrsOffset, end: 32768 * s.endAddrsCoarseOffset + s.endAddrsOffset, loopStart: b.loopStart + 32768 * s.startloopAddrsCoarseOffset + s.startloopAddrsOffset, loopEnd: b.loopEnd + 32768 * s.endloopAddrsCoarseOffset + s.endloopAddrsOffset, modLfoToPitch: s.modLfoToPitch, vibLfoToPitch: s.vibLfoToPitch, modEnvToPitch: s.modEnvToPitch, initialFilterFc: s.initialFilterFc, initialFilterQ: s.initialFilterQ, modLfoToFilterFc: s.modLfoToFilterFc, modEnvToFilterFc: s.modEnvToFilterFc, modLfoToVolume: s.modLfoToVolume, chorusEffectsSend: s.chorusEffectsSend / 1e3, reverbEffectsSend: s.reverbEffectsSend / 1e3, pan: s.pan, delayModLFO: H(s.delayModLFO), freqModLFO: s.freqModLFO, delayVibLFO: H(s.delayVibLFO), freqVibLFO: s.freqVibLFO, modDelay: H(s.delayModEnv), modAttack: H(s.attackModEnv), modHold: l, modDecay: d, modSustain: s.sustainModEnv / 1e3, modRelease: H(s.releaseModEnv), volDelay: H(s.delayVolEnv), volAttack: H(s.attackVolEnv), volHold: u, volDecay: f, volSustain: s.sustainVolEnv / 1e3, volRelease: H(s.releaseVolEnv), initialAttenuation: s.initialAttenuation, playbackRate: e => Math.pow(Math.pow(2, 1 / 12), (e + h) * v), sample: c, sampleRate: b.sampleRate, sampleName: b.sampleName, sampleModes: s.sampleModes, exclusiveClass: s.exclusiveClass }; }
182
- getPresetNames() { const e = {}, t = this.parsed.presetHeaders; for (let n = 0; n < t.length; n++) {
183
- const r = t[n];
184
- e[r.bank] || (e[r.bank] = {}), e[r.bank][r.preset] = r.presetName;
185
- } return e; }
186
- }
187
- exports.SoundFont = B;
188
- function H(e) { return Math.pow(2, e / 1200); }
189
- exports.default = null;
190
- //# sourceMappingURL=/sm/2fff1026e5ca926c33bde270b79b6c4b0445a8dd5401fdf4af3e7cae85b156e4.map
@@ -1,84 +0,0 @@
1
- declare namespace t {
2
- export { n as parseMidi };
3
- export { s as writeMidi };
4
- }
5
- declare function I(t: any): {
6
- header: {
7
- format: any;
8
- numTracks: any;
9
- };
10
- tracks: {
11
- deltaTime: any;
12
- type: string;
13
- data: any;
14
- meta: boolean;
15
- number: any;
16
- text: string;
17
- channel: any;
18
- port: any;
19
- microsecondsPerBeat: any;
20
- frameRate: number | undefined;
21
- hour: number;
22
- min: any;
23
- sec: any;
24
- frame: any;
25
- subFrame: any;
26
- numerator: any;
27
- denominator: number;
28
- metronome: any;
29
- thirtyseconds: any;
30
- key: any;
31
- scale: any;
32
- metatypeByte: any;
33
- running: boolean;
34
- noteNumber: any;
35
- velocity: any;
36
- byte9: boolean;
37
- amount: any;
38
- controllerType: any;
39
- value: any;
40
- programNumber: any;
41
- }[][];
42
- };
43
- declare function c(t: any, e: any): any[];
44
- declare function n(t: any): {
45
- header: {
46
- format: any;
47
- numTracks: any;
48
- };
49
- tracks: {
50
- deltaTime: any;
51
- type: string;
52
- data: any;
53
- meta: boolean;
54
- number: any;
55
- text: string;
56
- channel: any;
57
- port: any;
58
- microsecondsPerBeat: any;
59
- frameRate: number | undefined;
60
- hour: number;
61
- min: any;
62
- sec: any;
63
- frame: any;
64
- subFrame: any;
65
- numerator: any;
66
- denominator: number;
67
- metronome: any;
68
- thirtyseconds: any;
69
- key: any;
70
- scale: any;
71
- metatypeByte: any;
72
- running: boolean;
73
- noteNumber: any;
74
- velocity: any;
75
- byte9: boolean;
76
- amount: any;
77
- controllerType: any;
78
- value: any;
79
- programNumber: any;
80
- }[][];
81
- };
82
- declare function s(t: any, e: any): any[];
83
- export { t as default, I as parseMidi, c as writeMidi };
84
- //# sourceMappingURL=+esm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"+esm.d.ts","sourceRoot":"","sources":["../../../../../src/deps/cdn.jsdelivr.net/npm/midi-file@1.2.4/+esm.js"],"names":[],"mappings":";;;;AAMosI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAggB;AAAm6I,0CAAugB;AAA16K;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAggB;AAAm6I,0CAAugB"}
@@ -1,221 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeMidi = exports.parseMidi = exports.default = void 0;
4
- /**
5
- * Bundled by jsDelivr using Rollup v2.79.1 and Terser v5.19.2.
6
- * Original file: /npm/midi-file@1.2.4/index.js
7
- *
8
- * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
9
- */
10
- var t = {};
11
- exports.default = t;
12
- function e(t) { for (var e, n = new r(t), i = []; !n.eof();) {
13
- var a = o();
14
- i.push(a);
15
- } return i; function o() { var t = {}; t.deltaTime = n.readVarInt(); var r = n.readUInt8(); if (240 == (240 & r)) {
16
- if (255 !== r) {
17
- if (240 == r) {
18
- t.type = "sysEx";
19
- a = n.readVarInt();
20
- return t.data = n.readBytes(a), t;
21
- }
22
- if (247 == r) {
23
- t.type = "endSysEx";
24
- a = n.readVarInt();
25
- return t.data = n.readBytes(a), t;
26
- }
27
- throw "Unrecognised MIDI event type byte: " + r;
28
- }
29
- t.meta = !0;
30
- var i = n.readUInt8(), a = n.readVarInt();
31
- switch (i) {
32
- case 0:
33
- if (t.type = "sequenceNumber", 2 !== a)
34
- throw "Expected length for sequenceNumber event is 2, got " + a;
35
- return t.number = n.readUInt16(), t;
36
- case 1: return t.type = "text", t.text = n.readString(a), t;
37
- case 2: return t.type = "copyrightNotice", t.text = n.readString(a), t;
38
- case 3: return t.type = "trackName", t.text = n.readString(a), t;
39
- case 4: return t.type = "instrumentName", t.text = n.readString(a), t;
40
- case 5: return t.type = "lyrics", t.text = n.readString(a), t;
41
- case 6: return t.type = "marker", t.text = n.readString(a), t;
42
- case 7: return t.type = "cuePoint", t.text = n.readString(a), t;
43
- case 32:
44
- if (t.type = "channelPrefix", 1 != a)
45
- throw "Expected length for channelPrefix event is 1, got " + a;
46
- return t.channel = n.readUInt8(), t;
47
- case 33:
48
- if (t.type = "portPrefix", 1 != a)
49
- throw "Expected length for portPrefix event is 1, got " + a;
50
- return t.port = n.readUInt8(), t;
51
- case 47:
52
- if (t.type = "endOfTrack", 0 != a)
53
- throw "Expected length for endOfTrack event is 0, got " + a;
54
- return t;
55
- case 81:
56
- if (t.type = "setTempo", 3 != a)
57
- throw "Expected length for setTempo event is 3, got " + a;
58
- return t.microsecondsPerBeat = n.readUInt24(), t;
59
- case 84:
60
- if (t.type = "smpteOffset", 5 != a)
61
- throw "Expected length for smpteOffset event is 5, got " + a;
62
- var o = n.readUInt8();
63
- return t.frameRate = { 0: 24, 32: 25, 64: 29, 96: 30 }[96 & o], t.hour = 31 & o, t.min = n.readUInt8(), t.sec = n.readUInt8(), t.frame = n.readUInt8(), t.subFrame = n.readUInt8(), t;
64
- case 88:
65
- if (t.type = "timeSignature", 2 != a && 4 != a)
66
- throw "Expected length for timeSignature event is 4 or 2, got " + a;
67
- return t.numerator = n.readUInt8(), t.denominator = 1 << n.readUInt8(), 4 === a ? (t.metronome = n.readUInt8(), t.thirtyseconds = n.readUInt8()) : (t.metronome = 36, t.thirtyseconds = 8), t;
68
- case 89:
69
- if (t.type = "keySignature", 2 != a)
70
- throw "Expected length for keySignature event is 2, got " + a;
71
- return t.key = n.readInt8(), t.scale = n.readUInt8(), t;
72
- case 127: return t.type = "sequencerSpecific", t.data = n.readBytes(a), t;
73
- default: return t.type = "unknownMeta", t.data = n.readBytes(a), t.metatypeByte = i, t;
74
- }
75
- }
76
- else {
77
- var s;
78
- if (0 == (128 & r)) {
79
- if (null === e)
80
- throw "Running status byte encountered before status byte";
81
- s = r, r = e, t.running = !0;
82
- }
83
- else
84
- s = n.readUInt8(), e = r;
85
- var I = r >> 4;
86
- switch (t.channel = 15 & r, I) {
87
- case 8: return t.type = "noteOff", t.noteNumber = s, t.velocity = n.readUInt8(), t;
88
- case 9:
89
- var c = n.readUInt8();
90
- return t.type = 0 === c ? "noteOff" : "noteOn", t.noteNumber = s, t.velocity = c, 0 === c && (t.byte9 = !0), t;
91
- case 10: return t.type = "noteAftertouch", t.noteNumber = s, t.amount = n.readUInt8(), t;
92
- case 11: return t.type = "controller", t.controllerType = s, t.value = n.readUInt8(), t;
93
- case 12: return t.type = "programChange", t.programNumber = s, t;
94
- case 13: return t.type = "channelAftertouch", t.amount = s, t;
95
- case 14: return t.type = "pitchBend", t.value = s + (n.readUInt8() << 7) - 8192, t;
96
- default: throw "Unrecognised MIDI event type: " + I;
97
- }
98
- } } }
99
- function r(t) { this.buffer = t, this.bufferLen = this.buffer.length, this.pos = 0; }
100
- r.prototype.eof = function () { return this.pos >= this.bufferLen; }, r.prototype.readUInt8 = function () { var t = this.buffer[this.pos]; return this.pos += 1, t; }, r.prototype.readInt8 = function () { var t = this.readUInt8(); return 128 & t ? t - 256 : t; }, r.prototype.readUInt16 = function () { return (this.readUInt8() << 8) + this.readUInt8(); }, r.prototype.readInt16 = function () { var t = this.readUInt16(); return 32768 & t ? t - 65536 : t; }, r.prototype.readUInt24 = function () { return (this.readUInt8() << 16) + (this.readUInt8() << 8) + this.readUInt8(); }, r.prototype.readInt24 = function () { var t = this.readUInt24(); return 8388608 & t ? t - 16777216 : t; }, r.prototype.readUInt32 = function () { return (this.readUInt8() << 24) + (this.readUInt8() << 16) + (this.readUInt8() << 8) + this.readUInt8(); }, r.prototype.readBytes = function (t) { var e = this.buffer.slice(this.pos, this.pos + t); return this.pos += t, e; }, r.prototype.readString = function (t) { var e = this.readBytes(t); return String.fromCharCode.apply(null, e); }, r.prototype.readVarInt = function () { for (var t = 0; !this.eof();) {
101
- var e = this.readUInt8();
102
- if (!(128 & e))
103
- return t + e;
104
- t += 127 & e, t <<= 7;
105
- } return t; }, r.prototype.readChunk = function () { var t = this.readString(4), e = this.readUInt32(); return { id: t, length: e, data: this.readBytes(e) }; };
106
- var n = function (t) { var n = new r(t), i = n.readChunk(); if ("MThd" != i.id)
107
- throw "Bad MIDI file. Expected 'MHdr', got: '" + i.id + "'"; for (var a = function (t) { var e = new r(t), n = e.readUInt16(), i = e.readUInt16(), a = { format: n, numTracks: i }, o = e.readUInt16(); 32768 & o ? (a.framesPerSecond = 256 - (o >> 8), a.ticksPerFrame = 255 & o) : a.ticksPerBeat = o; return a; }(i.data), o = [], s = 0; !n.eof() && s < a.numTracks; s++) {
108
- var I = n.readChunk();
109
- if ("MTrk" != I.id)
110
- throw "Bad MIDI file. Expected 'MTrk', got: '" + I.id + "'";
111
- var c = e(I.data);
112
- o.push(c);
113
- } return { header: a, tracks: o }; };
114
- function i(t, e, r) { var n, i = new o, s = e.length, I = null; for (n = 0; n < s; n++)
115
- !1 !== r.running && (r.running || e[n].running) || (I = null), I = a(i, e[n], I, r.useByte9ForNoteOff); t.writeChunk("MTrk", i.buffer); }
116
- function a(t, e, r, n) { var i = e.type, a = e.deltaTime, o = e.text || "", s = e.data || [], I = null; switch (t.writeVarInt(a), i) {
117
- case "sequenceNumber":
118
- t.writeUInt8(255), t.writeUInt8(0), t.writeVarInt(2), t.writeUInt16(e.number);
119
- break;
120
- case "text":
121
- t.writeUInt8(255), t.writeUInt8(1), t.writeVarInt(o.length), t.writeString(o);
122
- break;
123
- case "copyrightNotice":
124
- t.writeUInt8(255), t.writeUInt8(2), t.writeVarInt(o.length), t.writeString(o);
125
- break;
126
- case "trackName":
127
- t.writeUInt8(255), t.writeUInt8(3), t.writeVarInt(o.length), t.writeString(o);
128
- break;
129
- case "instrumentName":
130
- t.writeUInt8(255), t.writeUInt8(4), t.writeVarInt(o.length), t.writeString(o);
131
- break;
132
- case "lyrics":
133
- t.writeUInt8(255), t.writeUInt8(5), t.writeVarInt(o.length), t.writeString(o);
134
- break;
135
- case "marker":
136
- t.writeUInt8(255), t.writeUInt8(6), t.writeVarInt(o.length), t.writeString(o);
137
- break;
138
- case "cuePoint":
139
- t.writeUInt8(255), t.writeUInt8(7), t.writeVarInt(o.length), t.writeString(o);
140
- break;
141
- case "channelPrefix":
142
- t.writeUInt8(255), t.writeUInt8(32), t.writeVarInt(1), t.writeUInt8(e.channel);
143
- break;
144
- case "portPrefix":
145
- t.writeUInt8(255), t.writeUInt8(33), t.writeVarInt(1), t.writeUInt8(e.port);
146
- break;
147
- case "endOfTrack":
148
- t.writeUInt8(255), t.writeUInt8(47), t.writeVarInt(0);
149
- break;
150
- case "setTempo":
151
- t.writeUInt8(255), t.writeUInt8(81), t.writeVarInt(3), t.writeUInt24(e.microsecondsPerBeat);
152
- break;
153
- case "smpteOffset":
154
- t.writeUInt8(255), t.writeUInt8(84), t.writeVarInt(5);
155
- var c = 31 & e.hour | { 24: 0, 25: 32, 29: 64, 30: 96 }[e.frameRate];
156
- t.writeUInt8(c), t.writeUInt8(e.min), t.writeUInt8(e.sec), t.writeUInt8(e.frame), t.writeUInt8(e.subFrame);
157
- break;
158
- case "timeSignature":
159
- t.writeUInt8(255), t.writeUInt8(88), t.writeVarInt(4), t.writeUInt8(e.numerator);
160
- var u = 255 & Math.floor(Math.log(e.denominator) / Math.LN2);
161
- t.writeUInt8(u), t.writeUInt8(e.metronome), t.writeUInt8(e.thirtyseconds || 8);
162
- break;
163
- case "keySignature":
164
- t.writeUInt8(255), t.writeUInt8(89), t.writeVarInt(2), t.writeInt8(e.key), t.writeUInt8(e.scale);
165
- break;
166
- case "sequencerSpecific":
167
- t.writeUInt8(255), t.writeUInt8(127), t.writeVarInt(s.length), t.writeBytes(s);
168
- break;
169
- case "unknownMeta":
170
- null != e.metatypeByte && (t.writeUInt8(255), t.writeUInt8(e.metatypeByte), t.writeVarInt(s.length), t.writeBytes(s));
171
- break;
172
- case "sysEx":
173
- t.writeUInt8(240), t.writeVarInt(s.length), t.writeBytes(s);
174
- break;
175
- case "endSysEx":
176
- t.writeUInt8(247), t.writeVarInt(s.length), t.writeBytes(s);
177
- break;
178
- case "noteOff":
179
- (I = (!1 !== n && e.byte9 || n && 0 == e.velocity ? 144 : 128) | e.channel) !== r && t.writeUInt8(I), t.writeUInt8(e.noteNumber), t.writeUInt8(e.velocity);
180
- break;
181
- case "noteOn":
182
- (I = 144 | e.channel) !== r && t.writeUInt8(I), t.writeUInt8(e.noteNumber), t.writeUInt8(e.velocity);
183
- break;
184
- case "noteAftertouch":
185
- (I = 160 | e.channel) !== r && t.writeUInt8(I), t.writeUInt8(e.noteNumber), t.writeUInt8(e.amount);
186
- break;
187
- case "controller":
188
- (I = 176 | e.channel) !== r && t.writeUInt8(I), t.writeUInt8(e.controllerType), t.writeUInt8(e.value);
189
- break;
190
- case "programChange":
191
- (I = 192 | e.channel) !== r && t.writeUInt8(I), t.writeUInt8(e.programNumber);
192
- break;
193
- case "channelAftertouch":
194
- (I = 208 | e.channel) !== r && t.writeUInt8(I), t.writeUInt8(e.amount);
195
- break;
196
- case "pitchBend":
197
- (I = 224 | e.channel) !== r && t.writeUInt8(I);
198
- var w = 8192 + e.value, h = 127 & w, f = w >> 7 & 127;
199
- t.writeUInt8(h), t.writeUInt8(f);
200
- break;
201
- default: throw "Unrecognized event type: " + i;
202
- } return I; }
203
- function o() { this.buffer = []; }
204
- o.prototype.writeUInt8 = function (t) { this.buffer.push(255 & t); }, o.prototype.writeInt8 = o.prototype.writeUInt8, o.prototype.writeUInt16 = function (t) { var e = t >> 8 & 255, r = 255 & t; this.writeUInt8(e), this.writeUInt8(r); }, o.prototype.writeInt16 = o.prototype.writeUInt16, o.prototype.writeUInt24 = function (t) { var e = t >> 16 & 255, r = t >> 8 & 255, n = 255 & t; this.writeUInt8(e), this.writeUInt8(r), this.writeUInt8(n); }, o.prototype.writeInt24 = o.prototype.writeUInt24, o.prototype.writeUInt32 = function (t) { var e = t >> 24 & 255, r = t >> 16 & 255, n = t >> 8 & 255, i = 255 & t; this.writeUInt8(e), this.writeUInt8(r), this.writeUInt8(n), this.writeUInt8(i); }, o.prototype.writeInt32 = o.prototype.writeUInt32, o.prototype.writeBytes = function (t) { this.buffer = this.buffer.concat(Array.prototype.slice.call(t, 0)); }, o.prototype.writeString = function (t) { var e, r = t.length, n = []; for (e = 0; e < r; e++)
205
- n.push(t.codePointAt(e)); this.writeBytes(n); }, o.prototype.writeVarInt = function (t) { if (t < 0)
206
- throw "Cannot write negative variable-length integer"; if (t <= 127)
207
- this.writeUInt8(t);
208
- else {
209
- var e = t, r = [];
210
- for (r.push(127 & e), e >>= 7; e;) {
211
- var n = 127 & e | 128;
212
- r.push(n), e >>= 7;
213
- }
214
- this.writeBytes(r.reverse());
215
- } }, o.prototype.writeChunk = function (t, e) { this.writeString(t), this.writeUInt32(e.length), this.writeBytes(e); };
216
- var s = function (t, e) { if ("object" != typeof t)
217
- throw "Invalid MIDI data"; e = e || {}; var r, n = t.header || {}, a = t.tracks || [], s = a.length, I = new o; for (function (t, e, r) { var n = null == e.format ? 1 : e.format, i = 128; e.timeDivision ? i = e.timeDivision : e.ticksPerFrame && e.framesPerSecond ? i = -(255 & e.framesPerSecond) << 8 | 255 & e.ticksPerFrame : e.ticksPerBeat && (i = 32767 & e.ticksPerBeat); var a = new o; a.writeUInt16(n), a.writeUInt16(r), a.writeUInt16(i), t.writeChunk("MThd", a.buffer); }(I, n, s), r = 0; r < s; r++)
218
- i(I, a[r], e); return I.buffer; }, I = t.parseMidi = n, c = t.writeMidi = s;
219
- exports.parseMidi = I;
220
- exports.writeMidi = c;
221
- //# sourceMappingURL=/sm/4ef9545b018e4043d7034a9272f1e66ac6dc613c64c28b528c827714a6c09f4f.map