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