rlo-engine 1.0.3
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/README.md +493 -0
- package/dist/AudioEffects.d.ts +16 -0
- package/dist/AudioEffects.d.ts.map +1 -0
- package/dist/AudioEffects.js +41 -0
- package/dist/AudioEffects.js.map +1 -0
- package/dist/Instruments/Analog/AnalogSynthBase.d.ts +22 -0
- package/dist/Instruments/Analog/AnalogSynthBase.d.ts.map +1 -0
- package/dist/Instruments/Analog/AnalogSynthBase.js +30 -0
- package/dist/Instruments/Analog/AnalogSynthBase.js.map +1 -0
- package/dist/Instruments/Analog/BassSynth.d.ts +14 -0
- package/dist/Instruments/Analog/BassSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/BassSynth.js +25 -0
- package/dist/Instruments/Analog/BassSynth.js.map +1 -0
- package/dist/Instruments/Analog/ChiptuneSynth.d.ts +14 -0
- package/dist/Instruments/Analog/ChiptuneSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/ChiptuneSynth.js +19 -0
- package/dist/Instruments/Analog/ChiptuneSynth.js.map +1 -0
- package/dist/Instruments/Analog/FMSynth.d.ts +15 -0
- package/dist/Instruments/Analog/FMSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/FMSynth.js +23 -0
- package/dist/Instruments/Analog/FMSynth.js.map +1 -0
- package/dist/Instruments/Analog/FormantSynth.d.ts +14 -0
- package/dist/Instruments/Analog/FormantSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/FormantSynth.js +26 -0
- package/dist/Instruments/Analog/FormantSynth.js.map +1 -0
- package/dist/Instruments/Analog/LeadSynth.d.ts +13 -0
- package/dist/Instruments/Analog/LeadSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/LeadSynth.js +21 -0
- package/dist/Instruments/Analog/LeadSynth.js.map +1 -0
- package/dist/Instruments/Analog/OrganSynth.d.ts +13 -0
- package/dist/Instruments/Analog/OrganSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/OrganSynth.js +24 -0
- package/dist/Instruments/Analog/OrganSynth.js.map +1 -0
- package/dist/Instruments/Analog/PadSynth.d.ts +14 -0
- package/dist/Instruments/Analog/PadSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/PadSynth.js +22 -0
- package/dist/Instruments/Analog/PadSynth.js.map +1 -0
- package/dist/Instruments/Analog/ReeseBassSynth.d.ts +14 -0
- package/dist/Instruments/Analog/ReeseBassSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/ReeseBassSynth.js +22 -0
- package/dist/Instruments/Analog/ReeseBassSynth.js.map +1 -0
- package/dist/Instruments/Analog/StringSynth.d.ts +13 -0
- package/dist/Instruments/Analog/StringSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/StringSynth.js +19 -0
- package/dist/Instruments/Analog/StringSynth.js.map +1 -0
- package/dist/Instruments/Analog/WoodwindSynth.d.ts +14 -0
- package/dist/Instruments/Analog/WoodwindSynth.d.ts.map +1 -0
- package/dist/Instruments/Analog/WoodwindSynth.js +35 -0
- package/dist/Instruments/Analog/WoodwindSynth.js.map +1 -0
- package/dist/Instruments/CoreSynthBase.d.ts +29 -0
- package/dist/Instruments/CoreSynthBase.d.ts.map +1 -0
- package/dist/Instruments/CoreSynthBase.js +91 -0
- package/dist/Instruments/CoreSynthBase.js.map +1 -0
- package/dist/Instruments/Decay/AdditiveSynth.d.ts +15 -0
- package/dist/Instruments/Decay/AdditiveSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/AdditiveSynth.js +24 -0
- package/dist/Instruments/Decay/AdditiveSynth.js.map +1 -0
- package/dist/Instruments/Decay/BrassSynth.d.ts +13 -0
- package/dist/Instruments/Decay/BrassSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/BrassSynth.js +29 -0
- package/dist/Instruments/Decay/BrassSynth.js.map +1 -0
- package/dist/Instruments/Decay/ChromaticPercussionSynth.d.ts +15 -0
- package/dist/Instruments/Decay/ChromaticPercussionSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/ChromaticPercussionSynth.js +23 -0
- package/dist/Instruments/Decay/ChromaticPercussionSynth.js.map +1 -0
- package/dist/Instruments/Decay/DecaySynthBase.d.ts +23 -0
- package/dist/Instruments/Decay/DecaySynthBase.d.ts.map +1 -0
- package/dist/Instruments/Decay/DecaySynthBase.js +35 -0
- package/dist/Instruments/Decay/DecaySynthBase.js.map +1 -0
- package/dist/Instruments/Decay/ElectricGuitarSynth.d.ts +15 -0
- package/dist/Instruments/Decay/ElectricGuitarSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/ElectricGuitarSynth.js +31 -0
- package/dist/Instruments/Decay/ElectricGuitarSynth.js.map +1 -0
- package/dist/Instruments/Decay/EthnicSynth.d.ts +15 -0
- package/dist/Instruments/Decay/EthnicSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/EthnicSynth.js +21 -0
- package/dist/Instruments/Decay/EthnicSynth.js.map +1 -0
- package/dist/Instruments/Decay/GuitarSynth.d.ts +14 -0
- package/dist/Instruments/Decay/GuitarSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/GuitarSynth.js +23 -0
- package/dist/Instruments/Decay/GuitarSynth.js.map +1 -0
- package/dist/Instruments/Decay/KarplusSynth.d.ts +10 -0
- package/dist/Instruments/Decay/KarplusSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/KarplusSynth.js +34 -0
- package/dist/Instruments/Decay/KarplusSynth.js.map +1 -0
- package/dist/Instruments/Decay/PianoSynth.d.ts +14 -0
- package/dist/Instruments/Decay/PianoSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/PianoSynth.js +32 -0
- package/dist/Instruments/Decay/PianoSynth.js.map +1 -0
- package/dist/Instruments/Decay/SlapBassSynth.d.ts +15 -0
- package/dist/Instruments/Decay/SlapBassSynth.d.ts.map +1 -0
- package/dist/Instruments/Decay/SlapBassSynth.js +28 -0
- package/dist/Instruments/Decay/SlapBassSynth.js.map +1 -0
- package/dist/Instruments/ISynthInstrument.d.ts +16 -0
- package/dist/Instruments/ISynthInstrument.d.ts.map +1 -0
- package/dist/Instruments/ISynthInstrument.js +2 -0
- package/dist/Instruments/ISynthInstrument.js.map +1 -0
- package/dist/Instruments/InstrumentFactory.d.ts +2 -0
- package/dist/Instruments/InstrumentFactory.d.ts.map +1 -0
- package/dist/Instruments/InstrumentFactory.js +4 -0
- package/dist/Instruments/InstrumentFactory.js.map +1 -0
- package/dist/Instruments/Speciality/DrumSynth.d.ts +11 -0
- package/dist/Instruments/Speciality/DrumSynth.d.ts.map +1 -0
- package/dist/Instruments/Speciality/DrumSynth.js +61 -0
- package/dist/Instruments/Speciality/DrumSynth.js.map +1 -0
- package/dist/Instruments/Speciality/SoundEffectsSynth.d.ts +12 -0
- package/dist/Instruments/Speciality/SoundEffectsSynth.d.ts.map +1 -0
- package/dist/Instruments/Speciality/SoundEffectsSynth.js +27 -0
- package/dist/Instruments/Speciality/SoundEffectsSynth.js.map +1 -0
- package/dist/Instruments/Synthesizer.d.ts +15 -0
- package/dist/Instruments/Synthesizer.d.ts.map +1 -0
- package/dist/Instruments/Synthesizer.js +27 -0
- package/dist/Instruments/Synthesizer.js.map +1 -0
- package/dist/RLO-Player.d.ts +298 -0
- package/dist/RLO-Player.d.ts.map +1 -0
- package/dist/RLO-Player.js +724 -0
- package/dist/RLO-Player.js.map +1 -0
- package/dist/RLO-Transpiler.d.ts +22 -0
- package/dist/RLO-Transpiler.d.ts.map +1 -0
- package/dist/RLO-Transpiler.js +133 -0
- package/dist/RLO-Transpiler.js.map +1 -0
- package/dist/compiler.d.ts +40 -0
- package/dist/compiler.d.ts.map +1 -0
- package/dist/compiler.js +268 -0
- package/dist/compiler.js.map +1 -0
- package/dist/crush.d.ts +9 -0
- package/dist/crush.d.ts.map +1 -0
- package/dist/crush.js +20 -0
- package/dist/crush.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/midi-parser.d.ts +10 -0
- package/dist/midi-parser.d.ts.map +1 -0
- package/dist/midi-parser.js +130 -0
- package/dist/midi-parser.js.map +1 -0
- package/dist/rlo-engine.min.js +655 -0
- package/dist/rlo-engine.min.js.map +1 -0
- package/dist/rlo-engine.min.umd.js +2 -0
- package/dist/rlo-engine.min.umd.js.map +1 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/vite.config.d.ts +7 -0
- package/dist/vite.config.d.ts.map +1 -0
- package/dist/vite.config.js +244 -0
- package/dist/vite.config.js.map +1 -0
- package/dist/vite.config.js13k.d.ts +7 -0
- package/dist/vite.config.js13k.d.ts.map +1 -0
- package/dist/vite.config.js13k.js +72 -0
- package/dist/vite.config.js13k.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,655 @@
|
|
|
1
|
+
class t {
|
|
2
|
+
constructor(t2, s2, i2) {
|
|
3
|
+
this.h = t2, this.o = s2, this.u = i2;
|
|
4
|
+
}
|
|
5
|
+
l(t2, s2, i2, h2, e2) {
|
|
6
|
+
const n2 = 0.6 * e2 * Math.min(1, 1600 / i2), r2 = this.u[t2] || this.u[0];
|
|
7
|
+
globalThis.DEBUG_MIDI, r2 && r2.l(this.h, this.o, s2, i2, h2, n2);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const _s = class _s {
|
|
11
|
+
static _(t2, s2 = "studio") {
|
|
12
|
+
if ("concert" === s2 && this.p) return this.p;
|
|
13
|
+
if ("studio" === s2 && this.M) return this.M;
|
|
14
|
+
const i2 = "studio" === s2, h2 = t2.sampleRate * (i2 ? 0.2 : 1.5), e2 = i2 ? 8 : 4, n2 = t2.createBuffer(2, h2, t2.sampleRate);
|
|
15
|
+
for (let t3 = 0; t3 < 2; t3++) {
|
|
16
|
+
const s3 = n2.getChannelData(t3);
|
|
17
|
+
let i3 = 0;
|
|
18
|
+
for (let t4 = 0; t4 < h2; t4++) i3 += 0.3 * (2 * Math.random() - 1 - i3), s3[t4] = i3 * Math.exp(t4 / h2 * -e2) * (1 - t4 / h2);
|
|
19
|
+
}
|
|
20
|
+
return i2 ? this.M = n2 : this.p = n2;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
_s.p = null;
|
|
24
|
+
_s.M = null;
|
|
25
|
+
let s = _s;
|
|
26
|
+
class i {
|
|
27
|
+
static S(t2, s2 = false) {
|
|
28
|
+
const i2 = t2.notes.length / 5, h2 = s2 ? new Float32Array(i2) : new Uint8Array(i2), e2 = new Uint16Array(i2), n2 = new Uint16Array(i2), r2 = new Uint8Array(i2), o2 = new Uint8Array(i2);
|
|
29
|
+
let a2 = 0;
|
|
30
|
+
for (let c2 = 0, u2 = 0; c2 < i2; c2++, u2 += 5) {
|
|
31
|
+
const i3 = t2.notes[u2 + 1], l2 = t2.notes[u2];
|
|
32
|
+
h2[c2] = s2 ? l2 : l2 > 0 ? Math.max(0, Math.min(255, Math.round(12 * Math.log2(l2 / 440) + 69))) : 0;
|
|
33
|
+
const d2 = Math.max(0, Math.round(1e3 * i3));
|
|
34
|
+
e2[c2] = Math.min(65535, d2 - a2), n2[c2] = Math.min(65535, Math.max(0, Math.round(1e3 * t2.notes[u2 + 2]))), r2[c2] = Math.max(0, Math.min(255, Math.round(255 * t2.notes[u2 + 3]))), o2[c2] = t2.notes[u2 + 4], a2 += e2[c2];
|
|
35
|
+
}
|
|
36
|
+
return { durationSecs: t2.durationSecs, f: h2, t: e2, d: n2, v: r2, i: o2 };
|
|
37
|
+
}
|
|
38
|
+
static U(t2, s2 = false) {
|
|
39
|
+
const i2 = 1 === new Uint8Array(new Uint16Array([1]).buffer)[0], h2 = this.S(t2, s2), e2 = h2.f.length, n2 = new ArrayBuffer(12 + (s2 ? 10 : 7) * e2), r2 = new DataView(n2);
|
|
40
|
+
if (r2.setUint8(0, 82), r2.setUint8(1, 76), r2.setUint8(2, 79), r2.setUint8(3, s2 ? 70 : 50), r2.setFloat32(4, h2.durationSecs, true), r2.setUint32(8, e2, true), i2) new Uint16Array(n2, 12, e2).set(h2.t), new Uint16Array(n2, 12 + 2 * e2, e2).set(h2.d), s2 && new Float32Array(n2, 12 + 4 * e2, e2).set(h2.f);
|
|
41
|
+
else for (let t3 = 0; t3 < e2; t3++) r2.setUint16(12 + 2 * t3, h2.t[t3], true), r2.setUint16(12 + 2 * e2 + 2 * t3, h2.d[t3], true), s2 && r2.setFloat32(12 + 4 * e2 + 4 * t3, h2.f[t3], true);
|
|
42
|
+
return s2 ? (new Uint8Array(n2, 12 + 8 * e2, e2).set(h2.v), new Uint8Array(n2, 12 + 9 * e2, e2).set(h2.i)) : (new Uint8Array(n2, 12 + 4 * e2, e2).set(h2.f), new Uint8Array(n2, 12 + 5 * e2, e2).set(h2.v), new Uint8Array(n2, 12 + 6 * e2, e2).set(h2.i)), n2;
|
|
43
|
+
}
|
|
44
|
+
static R(t2) {
|
|
45
|
+
const s2 = new DataView(t2), i2 = String.fromCharCode(s2.getUint8(0), s2.getUint8(1), s2.getUint8(2), s2.getUint8(3));
|
|
46
|
+
if ("RLO2" !== i2 && "RLOF" !== i2) throw Error("Invalid RLO Binary format. Please recompile tracks.");
|
|
47
|
+
const h2 = "RLOF" === i2, e2 = s2.getFloat32(4, true), n2 = s2.getUint32(8, true), r2 = h2 ? null : new Uint8Array(t2, 12 + 4 * n2, n2), o2 = new Uint8Array(t2, 12 + (h2 ? 8 : 5) * n2, n2), a2 = new Uint8Array(t2, 12 + (h2 ? 9 : 6) * n2, n2), c2 = Array(5 * n2);
|
|
48
|
+
let u2 = 0;
|
|
49
|
+
for (let t3 = 0, i3 = 0; t3 < n2; t3++, i3 += 5) {
|
|
50
|
+
const e3 = s2.getUint16(12 + 2 * t3, true), l2 = s2.getUint16(12 + 2 * n2 + 2 * t3, true), d2 = h2 ? s2.getFloat32(12 + 4 * n2 + 4 * t3, true) : r2[t3];
|
|
51
|
+
u2 += e3 / 1e3, c2[i3] = h2 ? d2 : d2 > 0 ? 440 * Math.pow(2, (d2 - 69) / 12) : 0, c2[i3 + 1] = u2, c2[i3 + 2] = l2 / 1e3, c2[i3 + 3] = o2[t3] / 255, c2[i3 + 4] = a2[t3];
|
|
52
|
+
}
|
|
53
|
+
return { durationSecs: e2, notes: c2 };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const h = { l: () => {
|
|
57
|
+
} };
|
|
58
|
+
function e(t2) {
|
|
59
|
+
const s2 = Array(129).fill(null);
|
|
60
|
+
return t2.forEach((t3) => {
|
|
61
|
+
t3.ids.forEach((i2) => s2[i2] = t3.synth);
|
|
62
|
+
}), s2;
|
|
63
|
+
}
|
|
64
|
+
function n(t2) {
|
|
65
|
+
const s2 = Array(129).fill(null);
|
|
66
|
+
t2.forEach((t3) => {
|
|
67
|
+
for (let i2 = t3.start; i2 <= t3.end; i2++) s2[i2] = t3.synth;
|
|
68
|
+
});
|
|
69
|
+
for (let t3 = 0; t3 < 129; t3++) if (null === s2[t3]) {
|
|
70
|
+
let i2 = null, h2 = 1 / 0;
|
|
71
|
+
for (let e2 = 0; e2 < 129; e2++) if (null !== s2[e2]) {
|
|
72
|
+
const n2 = Math.abs(t3 - e2);
|
|
73
|
+
n2 < h2 && (h2 = n2, i2 = s2[e2]);
|
|
74
|
+
}
|
|
75
|
+
s2[t3] = i2;
|
|
76
|
+
}
|
|
77
|
+
return s2;
|
|
78
|
+
}
|
|
79
|
+
function r(t2, s2) {
|
|
80
|
+
const i2 = [...t2];
|
|
81
|
+
return s2.forEach((t3) => {
|
|
82
|
+
for (let s3 = t3.start; s3 <= t3.end; s3++) i2[s3] = t3.synth;
|
|
83
|
+
}), i2;
|
|
84
|
+
}
|
|
85
|
+
let o = class {
|
|
86
|
+
constructor(t2, s2 = []) {
|
|
87
|
+
this.N = false, this.T = null, this.V = null, this.I = 0, this.L = 0, this.O = 0, this.j = [], this.q = 0.5, this.k = null, this.playbackRate = 1, this.X = null, this.h = t2, this.H = s2;
|
|
88
|
+
}
|
|
89
|
+
get J() {
|
|
90
|
+
return this.h.currentTime;
|
|
91
|
+
}
|
|
92
|
+
setVolume(t2) {
|
|
93
|
+
this.q = t2;
|
|
94
|
+
}
|
|
95
|
+
seek(t2) {
|
|
96
|
+
this.O > 0 && (this.k = Math.max(0, t2) % this.O);
|
|
97
|
+
}
|
|
98
|
+
stop() {
|
|
99
|
+
this.N = false, this.I++, this.T && clearTimeout(this.T), this.V && this.V.postMessage("stop");
|
|
100
|
+
const t2 = this.j;
|
|
101
|
+
this.j = [], t2.forEach((t3) => {
|
|
102
|
+
try {
|
|
103
|
+
t3.disconnect();
|
|
104
|
+
} catch (t4) {
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
dispose() {
|
|
109
|
+
this.stop(), this.V && (this.V.terminate(), this.V = null), this.X && (URL.revokeObjectURL(this.X), this.X = null);
|
|
110
|
+
}
|
|
111
|
+
P() {
|
|
112
|
+
return this.h.createGain();
|
|
113
|
+
}
|
|
114
|
+
$(t2, s2, i2) {
|
|
115
|
+
t2.setValueAtTime(i2 > 0 ? 0 : s2, this.J), i2 > 0 && t2.linearRampToValueAtTime(s2, this.J + i2);
|
|
116
|
+
}
|
|
117
|
+
K(t2 = this.h) {
|
|
118
|
+
const s2 = t2.createDynamicsCompressor();
|
|
119
|
+
return s2.threshold.value = -24, s2.knee.value = 12, s2.ratio.value = 8, s2.attack.value = 1e-3, s2.release.value = 0.25, s2;
|
|
120
|
+
}
|
|
121
|
+
W(t2 = 0) {
|
|
122
|
+
const s2 = this.P();
|
|
123
|
+
return this.$(s2.gain, this.q, t2), s2.connect(this.h.destination), this.j.push(s2), { destination: s2 };
|
|
124
|
+
}
|
|
125
|
+
playSequence(s2, i2 = true, h2 = 0) {
|
|
126
|
+
let e2 = true, n2 = h2;
|
|
127
|
+
"object" == typeof i2 ? (e2 = i2.loop ?? true, n2 = i2.fadeInTime ?? 0, void 0 !== i2.playbackRate && (this.playbackRate = i2.playbackRate), void 0 !== i2.volume && this.setVolume(i2.volume)) : e2 = i2, this.stop(), "suspended" === this.h.state && this.h.resume(), this.N = true;
|
|
128
|
+
const r2 = ++this.I;
|
|
129
|
+
this.O = s2.durationSecs;
|
|
130
|
+
const { destination: o2 } = this.W(n2), a2 = new t(this.h, o2, this.H);
|
|
131
|
+
this.L = -0.05 * this.playbackRate;
|
|
132
|
+
let c2 = this.J, u2 = 0, l2 = 0;
|
|
133
|
+
const d2 = s2.notes, p2 = d2.length, y2 = () => {
|
|
134
|
+
if (!this.N || this.I !== r2) return;
|
|
135
|
+
const t2 = this.J, i3 = t2 - c2;
|
|
136
|
+
if (c2 = t2, null !== this.k) {
|
|
137
|
+
for (this.L = this.k, u2 = 0, l2 = 0; l2 < p2 && d2[l2 + 1] < this.k; ) l2 += 5;
|
|
138
|
+
this.k = null;
|
|
139
|
+
} else this.L += i3 * this.playbackRate;
|
|
140
|
+
const h3 = s2.durationSecs;
|
|
141
|
+
for (; l2 < p2; ) {
|
|
142
|
+
const s3 = d2[l2], i4 = d2[l2 + 1], h4 = d2[l2 + 2], e3 = d2[l2 + 3], n3 = d2[l2 + 4], r3 = u2 + i4;
|
|
143
|
+
if (!(r3 < this.L + 0.5 * this.playbackRate)) break;
|
|
144
|
+
{
|
|
145
|
+
const i5 = t2 + Math.max(0, (r3 - this.L) / this.playbackRate);
|
|
146
|
+
a2.l(n3, i5, s3, h4 / this.playbackRate, e3), l2 += 5;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
l2 >= p2 ? e2 ? (l2 = 0, u2 += h3, y2()) : this.V && this.V.postMessage("stop") : this.V || (this.T = setTimeout(y2, 50));
|
|
150
|
+
};
|
|
151
|
+
this.V && (this.V.onmessage = () => y2(), this.V.postMessage("start")), y2();
|
|
152
|
+
}
|
|
153
|
+
}, a = class extends o {
|
|
154
|
+
constructor(t2, i2 = []) {
|
|
155
|
+
super(t2, i2), this.o = null, this.Y = null, this.Z = null, this.tt = /* @__PURE__ */ new Map(), this.st = 20, this.it = "concert", s._(this.h, "concert"), s._(this.h, "studio"), this.ht = () => {
|
|
156
|
+
document.hidden ? this.h.suspend() : this.N && this.h.resume();
|
|
157
|
+
}, "undefined" != typeof document && document.addEventListener("visibilitychange", this.ht);
|
|
158
|
+
}
|
|
159
|
+
setReverbMode(t2) {
|
|
160
|
+
this.it = t2, this.Y && this.Z && (this.Y.buffer = s._(this.h, t2), this.Z.gain.setTargetAtTime("studio" === t2 ? 0.05 : 0.2, this.J, 0.1));
|
|
161
|
+
}
|
|
162
|
+
dispose() {
|
|
163
|
+
super.dispose(), "undefined" != typeof document && document.removeEventListener("visibilitychange", this.ht), this.tt.clear();
|
|
164
|
+
}
|
|
165
|
+
setVolume(t2) {
|
|
166
|
+
super.setVolume(t2), this.o && this.o.gain.setTargetAtTime(t2, this.J, 0.1);
|
|
167
|
+
}
|
|
168
|
+
getCurrentTime() {
|
|
169
|
+
return 0 !== this.O && this.N ? Math.max(0, this.L) % this.O : 0;
|
|
170
|
+
}
|
|
171
|
+
getTotalDuration() {
|
|
172
|
+
return this.O;
|
|
173
|
+
}
|
|
174
|
+
W(t2 = 0) {
|
|
175
|
+
this.Y = this.h.createConvolver(), this.Y.buffer = s._(this.h, this.it), this.o = this.P(), this.j.push(this.Y, this.o), this.$(this.o.gain, this.q, t2), this.Z = this.P(), this.Z.gain.value = "studio" === this.it ? 0.05 : 0.2, this.j.push(this.Z);
|
|
176
|
+
const i2 = this.h.createBiquadFilter();
|
|
177
|
+
i2.type = "lowpass", i2.frequency.value = Math.min(this.h.sampleRate / 2 - 1, 6500), this.j.push(i2);
|
|
178
|
+
const h2 = this.K();
|
|
179
|
+
return this.j.push(h2), this.o.connect(i2).connect(h2).connect(this.h.destination), this.o.connect(this.Y).connect(this.Z).connect(i2), { destination: this.o };
|
|
180
|
+
}
|
|
181
|
+
async play(t2, s2 = 0, h2 = true) {
|
|
182
|
+
let e2, n2 = 0, r2 = {};
|
|
183
|
+
if ("object" == typeof s2 ? (n2 = s2.fadeInTime ?? 0, r2 = s2) : (n2 = s2, r2 = { fadeInTime: n2, loop: h2 }), "string" == typeof t2) if (this.tt.has(t2)) e2 = this.tt.get(t2);
|
|
184
|
+
else {
|
|
185
|
+
const s3 = await fetch(t2);
|
|
186
|
+
if (t2.toLowerCase().endsWith(".json")) {
|
|
187
|
+
const t3 = await s3.text();
|
|
188
|
+
e2 = JSON.parse(t3);
|
|
189
|
+
} else {
|
|
190
|
+
const t3 = await s3.arrayBuffer(), h3 = new DataView(t3);
|
|
191
|
+
if (h3.byteLength >= 3 && 82 === h3.getUint8(0) && 76 === h3.getUint8(1) && 79 === h3.getUint8(2)) e2 = i.R(t3);
|
|
192
|
+
else {
|
|
193
|
+
const s4 = new window.DecompressionStream("gzip"), h4 = s4.writable.getWriter();
|
|
194
|
+
h4.write(t3), h4.close(), e2 = i.R(await new Response(s4.readable).arrayBuffer());
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (this.tt.set(t2, e2), this.tt.size > this.st) {
|
|
198
|
+
const t3 = this.tt.keys().next().value;
|
|
199
|
+
t3 && this.tt.delete(t3);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else e2 = t2;
|
|
203
|
+
this.playSequence(e2, r2);
|
|
204
|
+
}
|
|
205
|
+
stop() {
|
|
206
|
+
if (this.o) {
|
|
207
|
+
const t2 = this.J;
|
|
208
|
+
this.o.gain.cancelScheduledValues(t2), this.o.gain.setValueAtTime(0, t2), this.o = null, this.Z = null, this.Y = null;
|
|
209
|
+
}
|
|
210
|
+
super.stop();
|
|
211
|
+
}
|
|
212
|
+
}, c = class extends o {
|
|
213
|
+
constructor(s2, i2 = []) {
|
|
214
|
+
super(s2, i2), this.o = this.P(), this.o.gain.value = this.q;
|
|
215
|
+
const h2 = this.K();
|
|
216
|
+
this.o.connect(h2).connect(this.h.destination), this.et = this.P(), this.et.connect(this.o), this.nt = this.P(), this.nt.connect(this.o), this.rt = new t(this.h, this.nt, this.H);
|
|
217
|
+
}
|
|
218
|
+
setVolume(t2) {
|
|
219
|
+
super.setVolume(t2), this.o.gain.setTargetAtTime(t2, this.J, 0.1);
|
|
220
|
+
}
|
|
221
|
+
setMusicVolume(t2) {
|
|
222
|
+
this.et.gain.setTargetAtTime(t2, this.J, 0.1);
|
|
223
|
+
}
|
|
224
|
+
setSFXVolume(t2) {
|
|
225
|
+
this.nt.gain.setTargetAtTime(t2, this.J, 0.1);
|
|
226
|
+
}
|
|
227
|
+
W(t2 = 0) {
|
|
228
|
+
const s2 = this.P();
|
|
229
|
+
return s2.connect(this.et), this.j.push(s2), this.$(s2.gain, 1, t2), { destination: s2 };
|
|
230
|
+
}
|
|
231
|
+
playSFX(t2, s2, i2, h2 = 1, e2 = 0) {
|
|
232
|
+
"suspended" === this.h.state && this.h.resume();
|
|
233
|
+
let n2 = 1, r2 = e2;
|
|
234
|
+
"object" == typeof h2 ? (n2 = h2.velocity ?? 1, r2 = h2.timeOffset ?? 0) : n2 = h2, this.rt.l(t2, this.J + r2, function(t3) {
|
|
235
|
+
if ("number" == typeof t3) return t3;
|
|
236
|
+
const s3 = t3.match(/^([a-gA-G])([#b]?)(\d)$/);
|
|
237
|
+
if (!s3) return 0;
|
|
238
|
+
const [, i3, h3, e3] = s3;
|
|
239
|
+
let n3 = { C: -9, D: -7, E: -5, F: -4, G: -2, A: 0, B: 2 }[i3.toUpperCase()];
|
|
240
|
+
return "#" === h3 && n3++, "b" === h3 && n3--, n3 += 12 * (parseInt(e3, 10) - 4), +(440 * Math.pow(2, n3 / 12)).toFixed(2);
|
|
241
|
+
}(s2), i2, n2);
|
|
242
|
+
}
|
|
243
|
+
playSFXSequence(t2, s2 = 0) {
|
|
244
|
+
"suspended" === this.h.state && this.h.resume();
|
|
245
|
+
const i2 = this.J + s2, h2 = t2.notes, e2 = h2.length;
|
|
246
|
+
for (let t3 = 0; t3 < e2; t3 += 5) this.rt.l(h2[t3 + 4], i2 + h2[t3 + 1], h2[t3], h2[t3 + 2], h2[t3 + 3]);
|
|
247
|
+
}
|
|
248
|
+
playMusic(t2, s2 = true, i2 = 0) {
|
|
249
|
+
let h2 = s2;
|
|
250
|
+
"object" == typeof s2 && void 0 !== s2.volume && (this.setMusicVolume(s2.volume), h2 = { ...s2 }, delete h2.volume), this.playSequence(t2, h2, i2);
|
|
251
|
+
}
|
|
252
|
+
stopMusic() {
|
|
253
|
+
super.stop();
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
var u = ((t2) => (t2[t2.Sine = 0] = "Sine", t2[t2.Square = 1] = "Square", t2[t2.Sawtooth = 2] = "Sawtooth", t2[t2.Triangle = 3] = "Triangle", t2))(u || {}), l = ((t2) => (t2[t2.Lowpass = 0] = "Lowpass", t2[t2.Highpass = 1] = "Highpass", t2[t2.Bandpass = 2] = "Bandpass", t2))(l || {});
|
|
257
|
+
class d {
|
|
258
|
+
ot(t2, s2, i2, h2) {
|
|
259
|
+
const e2 = t2.createOscillator();
|
|
260
|
+
return e2.type = ["sine", "square", "sawtooth", "triangle"][s2], i2 && (e2.frequency.value = Math.min(22e3, i2)), h2 && e2.connect(h2), e2;
|
|
261
|
+
}
|
|
262
|
+
P(t2, s2, i2) {
|
|
263
|
+
const h2 = t2.createGain();
|
|
264
|
+
return h2.gain.value = s2, i2 && h2.connect(i2), h2;
|
|
265
|
+
}
|
|
266
|
+
ct(t2, s2) {
|
|
267
|
+
const i2 = t2.createBiquadFilter();
|
|
268
|
+
return i2.type = ["lowpass", "highpass", "bandpass"][s2], i2;
|
|
269
|
+
}
|
|
270
|
+
ut(t2, s2, i2) {
|
|
271
|
+
const h2 = t2.createStereoPanner();
|
|
272
|
+
return h2.pan.value = s2, i2 && h2.connect(i2), h2;
|
|
273
|
+
}
|
|
274
|
+
lt(t2, s2, ...i2) {
|
|
275
|
+
i2.forEach((i3) => {
|
|
276
|
+
i3.start(t2), i3.stop(s2);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
dt(t2, s2, i2) {
|
|
280
|
+
t2.setValueAtTime(Math.min(22e3, s2), i2);
|
|
281
|
+
}
|
|
282
|
+
yt(t2, s2, i2) {
|
|
283
|
+
t2.linearRampToValueAtTime(Math.min(22e3, s2), i2);
|
|
284
|
+
}
|
|
285
|
+
Mt(t2, s2, i2) {
|
|
286
|
+
t2.exponentialRampToValueAtTime(Math.min(22e3, s2), i2);
|
|
287
|
+
}
|
|
288
|
+
ft(t2, s2, i2, h2, e2, n2, r2, o2 = 0) {
|
|
289
|
+
const a2 = this.P(t2, 0, h2);
|
|
290
|
+
this.dt(a2.gain, o2 > 0 ? 0 : n2, e2), o2 > 0 && this.yt(a2.gain, n2, e2 + o2), this.Mt(a2.gain, 1e-3, e2 + r2), this.lt(e2, e2 + r2, this.ot(t2, s2, i2, a2));
|
|
291
|
+
}
|
|
292
|
+
wt(t2, s2, i2, h2, e2, n2) {
|
|
293
|
+
const r2 = this.ct(t2, s2);
|
|
294
|
+
return this.dt(r2.frequency, i2, e2), this.Mt(r2.frequency, h2, e2 + n2), r2;
|
|
295
|
+
}
|
|
296
|
+
_t(t2, s2, i2, h2, e2, n2) {
|
|
297
|
+
return [this.ot(t2, s2, i2, this.ut(t2, -e2, n2)), this.ot(t2, s2, i2 * h2, this.ut(t2, e2, n2))];
|
|
298
|
+
}
|
|
299
|
+
St(t2, s2, i2, h2, e2, n2, r2, o2 = 0) {
|
|
300
|
+
const a2 = this.P(t2, 0, r2);
|
|
301
|
+
return this.dt(a2.gain, 0, h2), o2 > 0 && this.dt(a2.gain, 0, h2 + o2), this.yt(a2.gain, i2, h2 + o2 + e2), this.lt(h2, n2, this.ot(t2, 0, s2, a2)), a2;
|
|
302
|
+
}
|
|
303
|
+
vt(t2, s2, i2, ...h2) {
|
|
304
|
+
{
|
|
305
|
+
const e2 = t2.createOscillator();
|
|
306
|
+
e2.onended = () => {
|
|
307
|
+
h2.forEach((t3) => {
|
|
308
|
+
try {
|
|
309
|
+
t3.disconnect();
|
|
310
|
+
} catch (t4) {
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}, e2.start(s2), e2.stop(i2);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
class p extends d {
|
|
318
|
+
constructor() {
|
|
319
|
+
super(...arguments), this.xt = { v: 0.5, a: 0.02, d: 0.2, m: 4 };
|
|
320
|
+
}
|
|
321
|
+
l(t2, s2, i2, h2, e2, n2) {
|
|
322
|
+
const r2 = t2.createGain(), o2 = this.gt(), a2 = Math.max(1e-3, n2 * o2.v), c2 = Math.max(0.02, Math.min(e2, o2.m));
|
|
323
|
+
this.dt(r2.gain, 0, i2), this.yt(r2.gain, a2, i2 + o2.a), this.At(r2.gain, a2, i2, o2.a, c2, o2.d);
|
|
324
|
+
const u2 = i2 + c2 + o2.d + 0.1, l2 = this.Ut(t2, s2, r2, i2, h2, n2, c2, u2) || r2;
|
|
325
|
+
l2.connect(s2), this.vt(t2, i2, u2 + 2, l2);
|
|
326
|
+
}
|
|
327
|
+
gt() {
|
|
328
|
+
return this.xt;
|
|
329
|
+
}
|
|
330
|
+
At(t2, s2, i2, h2, e2, n2) {
|
|
331
|
+
this.Mt(t2, 1e-3, i2 + e2 + n2);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
class y extends p {
|
|
335
|
+
constructor() {
|
|
336
|
+
super(...arguments), this.xt = { v: 0.8, a: 0.015, d: 0.1, m: 5 };
|
|
337
|
+
}
|
|
338
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
339
|
+
const a2 = this.wt(t2, l.Lowpass, e2 + 800 + 1e3 * n2, e2 + 200, h2, Math.min(r2, 1)), c2 = this.ot(t2, u.Triangle, e2, i2), d2 = this.P(t2, 0), p2 = this.ot(t2, u.Sine, 2.003 * e2, d2), y2 = this.ot(t2, u.Sine, 3.007 * e2, d2), M2 = this.ut(t2, Math.max(-0.8, Math.min(0.8, (e2 - 261.6) / 800)));
|
|
340
|
+
return this.dt(d2.gain, 0, h2), this.yt(d2.gain, Math.max(1e-3, 0.15 * n2), h2 + 0.01), this.Mt(d2.gain, 1e-3, h2 + Math.min(r2, 0.5)), d2.connect(M2), this.ft(t2, u.Sine, 60, M2, h2, Math.max(1e-3, 0.4 * n2), 0.05, 5e-3), i2.connect(M2).connect(a2), this.lt(h2, o2, c2, p2, y2), a2;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
class M extends p {
|
|
344
|
+
constructor() {
|
|
345
|
+
super(...arguments), this.xt = { v: 0.7, a: 5e-3, d: 0.5, m: 6 };
|
|
346
|
+
}
|
|
347
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
348
|
+
const a2 = this.ot(t2, u.Sine, 0, i2);
|
|
349
|
+
this.dt(a2.frequency, 1.1 * e2, h2), this.Mt(a2.frequency, e2, h2 + 0.02);
|
|
350
|
+
const c2 = this.P(t2, 0, s2);
|
|
351
|
+
this.dt(c2.gain, Math.max(1e-3, 0.25 * n2), h2), this.Mt(c2.gain, 1e-3, h2 + r2);
|
|
352
|
+
const l2 = this.ot(t2, u.Sine, 2.76 * e2, c2);
|
|
353
|
+
c2.connect(s2), this.lt(h2, o2, a2, l2);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
class f extends d {
|
|
357
|
+
constructor() {
|
|
358
|
+
super(...arguments), this.xt = { v: 0.5, a: 0.05, r: 0.1 };
|
|
359
|
+
}
|
|
360
|
+
l(t2, s2, i2, h2, e2, n2) {
|
|
361
|
+
const r2 = t2.createGain(), o2 = this.gt(e2), a2 = Math.max(1e-3, n2 * o2.v);
|
|
362
|
+
this.dt(r2.gain, 0, i2), this.yt(r2.gain, a2, i2 + o2.a);
|
|
363
|
+
const c2 = Math.max(o2.a, e2);
|
|
364
|
+
this.dt(r2.gain, a2, i2 + c2), this.yt(r2.gain, 1e-3, i2 + c2 + o2.r);
|
|
365
|
+
const u2 = i2 + c2 + o2.r, l2 = this.Ut(t2, r2, i2, h2, n2, c2, o2.r, u2) || r2;
|
|
366
|
+
l2.connect(s2), this.vt(t2, i2, u2 + 0.1, l2);
|
|
367
|
+
}
|
|
368
|
+
gt(t2) {
|
|
369
|
+
return this.xt;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
class w extends f {
|
|
373
|
+
constructor() {
|
|
374
|
+
super(...arguments), this.xt = { v: 0.4, a: 0.01, r: 0.05 };
|
|
375
|
+
}
|
|
376
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
377
|
+
const a2 = this.ot(t2, u.Sine, h2, s2), c2 = this.P(t2, 0.5, s2), l2 = this.ot(t2, u.Sine, 2 * h2, c2), d2 = this.P(t2, 0.25, s2), p2 = this.ot(t2, u.Sine, 3 * h2, d2), y2 = this.P(t2, 0.7);
|
|
378
|
+
return this.St(t2, 6.5, 0.3, i2, 0, o2, y2.gain), s2.connect(y2), this.ft(t2, u.Square, 4e3, y2, i2, Math.max(1e-3, 0.1 * e2), 0.015), this.lt(i2, o2, a2, l2, p2), y2;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
class _ extends p {
|
|
382
|
+
constructor() {
|
|
383
|
+
super(...arguments), this.xt = { v: 0.6, a: 0.02, d: 0.2, m: 4 };
|
|
384
|
+
}
|
|
385
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
386
|
+
const a2 = this.wt(t2, l.Lowpass, 2e3 + 1e3 * n2, 200, h2, r2), c2 = this.ot(t2, u.Sawtooth, 0, i2);
|
|
387
|
+
return this.dt(c2.frequency, 1.02 * e2, h2), this.Mt(c2.frequency, e2, h2 + 0.05), i2.connect(a2), this.ft(t2, u.Square, 3500, s2, h2, Math.max(1e-3, 0.25 * n2), 0.015), this.lt(h2, o2, c2), a2;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
class S extends p {
|
|
391
|
+
constructor() {
|
|
392
|
+
super(...arguments), this.xt = { v: 0.5, a: 0.02, d: 0.2, m: 4 };
|
|
393
|
+
}
|
|
394
|
+
At(t2, s2, i2, h2, e2, n2) {
|
|
395
|
+
this.Mt(t2, Math.max(1e-3, 0.4 * s2), i2 + Math.min(0.5, e2)), this.Mt(t2, 1e-3, i2 + e2 + n2);
|
|
396
|
+
}
|
|
397
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
398
|
+
const a2 = this.wt(t2, l.Lowpass, 2500 + 1500 * n2, 600, h2, r2), [c2, d2] = this._t(t2, u.Sawtooth, 0, 1, 0, i2);
|
|
399
|
+
return this.dt(c2.frequency, 1.02 * e2, h2), this.Mt(c2.frequency, e2, h2 + 0.05), this.dt(d2.frequency, 1.022 * e2, h2), this.Mt(d2.frequency, 1.002 * e2, h2 + 0.05), this.St(t2, 5, 0.015 * e2, h2, 0.2, o2, c2.frequency, 0.4).connect(d2.frequency), i2.connect(a2), this.ft(t2, u.Square, 3500, s2, h2, Math.max(1e-3, 0.25 * n2), 0.015), this.lt(h2, o2, c2, d2), a2;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
class m extends p {
|
|
403
|
+
constructor() {
|
|
404
|
+
super(...arguments), this.xt = { v: 0.8, a: 0.05, d: 0.1, m: 4 };
|
|
405
|
+
}
|
|
406
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
407
|
+
const a2 = this.wt(t2, l.Lowpass, 300 + 500 * n2, 100, h2, r2), c2 = this.ot(t2, u.Sawtooth, 0, i2);
|
|
408
|
+
this.dt(c2.frequency, 0.92 * e2, h2), this.Mt(c2.frequency, e2, h2 + 0.04);
|
|
409
|
+
const d2 = this.P(t2, 0.6, i2), p2 = this.ot(t2, u.Sine, 0, d2);
|
|
410
|
+
return this.dt(p2.frequency, e2 / 2 * 0.92, h2), this.Mt(p2.frequency, e2 / 2, h2 + 0.04), i2.connect(a2), this.lt(h2, o2, c2, p2), a2;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
class v extends f {
|
|
414
|
+
gt(t2) {
|
|
415
|
+
return { v: 0.3, a: t2 < 0.4 ? 0.05 : 0.2, r: t2 < 0.4 ? 0.1 : 0.5 };
|
|
416
|
+
}
|
|
417
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
418
|
+
const [a2, c2] = this._t(t2, u.Sawtooth, h2, 1.005, 0.6, s2);
|
|
419
|
+
this.St(t2, 4.5, 0.012 * h2, i2, 0.3, o2, a2.frequency).connect(c2.frequency);
|
|
420
|
+
const d2 = this.wt(t2, l.Lowpass, h2 + 1200 + 1e3 * e2, h2 + 800, i2, n2 + r2);
|
|
421
|
+
return s2.connect(d2), this.lt(i2, o2, a2, c2), d2;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
class x extends f {
|
|
425
|
+
constructor() {
|
|
426
|
+
super(...arguments), this.xt = { v: 0.5, a: 0.1, r: 0.1 };
|
|
427
|
+
}
|
|
428
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
429
|
+
const a2 = this.ot(t2, u.Square, 0, s2);
|
|
430
|
+
this.dt(a2.frequency, 0.95 * h2, i2), this.Mt(a2.frequency, h2, i2 + 0.05);
|
|
431
|
+
const c2 = this.P(t2, 0, s2);
|
|
432
|
+
this.dt(c2.gain, 0, i2), this.yt(c2.gain, Math.max(1e-3, 0.25 * e2), i2 + 0.05), this.Mt(c2.gain, 1e-3, i2 + 0.2);
|
|
433
|
+
const d2 = this.ot(t2, u.Sawtooth, 2 * h2, c2), p2 = this.ct(t2, l.Lowpass);
|
|
434
|
+
return this.dt(p2.frequency, h2 + 400, i2), this.yt(p2.frequency, h2 + 1500 + 1e3 * e2, i2 + 0.1), this.Mt(p2.frequency, h2 + 400, i2 + n2 + r2), s2.connect(p2), this.lt(i2, o2, a2), this.lt(i2, i2 + 0.2, d2), p2;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
class g extends f {
|
|
438
|
+
constructor() {
|
|
439
|
+
super(...arguments), this.xt = { v: 0.7, a: 0.05, r: 0.1 };
|
|
440
|
+
}
|
|
441
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
442
|
+
const a2 = this.ot(t2, u.Sine, h2, s2), c2 = this.P(t2, 0, s2);
|
|
443
|
+
this.dt(c2.gain, 0.3, i2), this.Mt(c2.gain, 0.05, i2 + 0.2);
|
|
444
|
+
const d2 = this.ot(t2, u.Triangle, h2, c2), p2 = this.ct(t2, l.Lowpass);
|
|
445
|
+
this.dt(p2.frequency, h2 + 800, i2);
|
|
446
|
+
const y2 = this.St(t2, 5.5, 0.015 * h2, i2, 0.4, o2, a2.frequency);
|
|
447
|
+
y2.connect(d2.frequency);
|
|
448
|
+
const M2 = this.P(t2, 1), f2 = this.P(t2, 0.15, M2.gain);
|
|
449
|
+
return y2.connect(f2), s2.connect(M2).connect(p2), this.lt(i2, o2, a2, d2), p2;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
class A extends f {
|
|
453
|
+
constructor() {
|
|
454
|
+
super(...arguments), this.xt = { v: 0.4, a: 0.05, r: 0.1 };
|
|
455
|
+
}
|
|
456
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
457
|
+
const a2 = this.ot(t2, u.Sawtooth, 0);
|
|
458
|
+
this.dt(a2.frequency, h2, i2), this.St(t2, 5, 0.02 * h2, i2, 0.2, o2, a2.frequency);
|
|
459
|
+
const c2 = this.wt(t2, l.Lowpass, h2, 3 * h2, i2, 0.05);
|
|
460
|
+
this.Mt(c2.frequency, 1.5 * h2, i2 + n2), c2.Q.value = 3, a2.connect(c2).connect(s2), this.lt(i2, o2, a2);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
class U extends f {
|
|
464
|
+
gt(t2) {
|
|
465
|
+
return { v: 0.4, a: t2 < 0.4 ? 0.05 : 0.3, r: t2 < 0.4 ? 0.1 : 0.8 };
|
|
466
|
+
}
|
|
467
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
468
|
+
const [a2, c2] = this._t(t2, u.Triangle, h2, 1.01, 0.7, s2), d2 = this.ct(t2, l.Lowpass);
|
|
469
|
+
return this.dt(d2.frequency, h2 + 400, i2), this.yt(d2.frequency, h2 + 1e3 + 500 * e2, i2 + n2), this.St(t2, 0.5, 10, i2, 0, o2, c2.frequency), this.St(t2, 0.1, 400, i2, 0, o2, d2.frequency), s2.connect(d2), this.lt(i2, o2, a2, c2), d2;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
class b extends d {
|
|
473
|
+
l(t2, s2, i2, h2, e2, n2) {
|
|
474
|
+
const r2 = this.P(t2, 0), o2 = this.ot(t2, u.Sawtooth, 0, r2);
|
|
475
|
+
this.dt(o2.frequency, h2, i2), this.Mt(o2.frequency, Math.max(1, h2 / 2), i2 + Math.max(0.05, e2));
|
|
476
|
+
const a2 = this.P(t2, 0.5, s2);
|
|
477
|
+
this.St(t2, 15, 0.5, i2, 0, i2 + e2 + 0.2, a2.gain), r2.connect(a2), this.dt(r2.gain, 0, i2), this.yt(r2.gain, Math.max(1e-3, 0.5 * n2), i2 + 0.05), this.Mt(r2.gain, 1e-3, i2 + e2 + 0.2), this.lt(i2, i2 + e2 + 0.2, o2), this.vt(t2, i2, i2 + e2 + 0.3, r2, a2);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
class R extends p {
|
|
481
|
+
constructor() {
|
|
482
|
+
super(...arguments), this.xt = { v: 0.6, a: 0.02, d: 0.1, m: 4 };
|
|
483
|
+
}
|
|
484
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
485
|
+
const a2 = this.ot(t2, u.Square, 0, i2);
|
|
486
|
+
this.dt(a2.frequency, 1.05 * e2, h2), this.Mt(a2.frequency, e2, h2 + 0.08);
|
|
487
|
+
const c2 = this.wt(t2, l.Bandpass, 2.5 * e2, e2, h2, r2);
|
|
488
|
+
c2.Q.value = 2, c2.connect(i2), this.lt(h2, o2, a2);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
const _N = class _N extends d {
|
|
492
|
+
static Rt(t2) {
|
|
493
|
+
if (!_N.bt || _N.bt.sampleRate !== t2.sampleRate) {
|
|
494
|
+
const s2 = 1 * t2.sampleRate, i2 = t2.createBuffer(1, s2, t2.sampleRate), h2 = i2.getChannelData(0);
|
|
495
|
+
for (let t3 = 0; t3 < s2; t3++) h2[t3] = 2 * Math.random() - 1;
|
|
496
|
+
_N.bt = i2;
|
|
497
|
+
}
|
|
498
|
+
return _N.bt;
|
|
499
|
+
}
|
|
500
|
+
l(t2, s2, i2, h2, e2, n2) {
|
|
501
|
+
if (h2 < 70) {
|
|
502
|
+
const h3 = this.P(t2, 0, s2), e3 = this.ot(t2, u.Sine, 0, h3);
|
|
503
|
+
this.dt(e3.frequency, 150, i2), this.Mt(e3.frequency, 30, i2 + 0.1), this.dt(h3.gain, Math.max(1e-3, 1.5 * n2), i2), this.Mt(h3.gain, 1e-3, i2 + 0.5), this.lt(i2, i2 + 0.5, e3), this.vt(t2, i2, i2 + 0.6, h3);
|
|
504
|
+
} else {
|
|
505
|
+
const e3 = h2 < 90, r2 = t2.createBufferSource();
|
|
506
|
+
r2.buffer = _N.Rt(t2);
|
|
507
|
+
const o2 = this.P(t2, 0, s2), a2 = this.ct(t2, e3 ? l.Bandpass : l.Highpass), c2 = this.ut(t2, e3 ? 0 : 0.6 * Math.random() - 0.3);
|
|
508
|
+
if (a2.frequency.value = e3 ? 1500 : 5e3, this.dt(o2.gain, Math.max(1e-3, n2), i2), this.Mt(o2.gain, 1e-3, i2 + (e3 ? 0.2 : 0.05)), r2.connect(a2).connect(o2).connect(c2), this.lt(i2, i2 + (e3 ? 0.2 : 0.05), r2), e3) {
|
|
509
|
+
const s3 = this.ot(t2, u.Triangle, 0, o2);
|
|
510
|
+
this.dt(s3.frequency, 300, i2), this.Mt(s3.frequency, 100, i2 + 0.1), this.lt(i2, i2 + 0.2, s3);
|
|
511
|
+
} else this.ft(t2, u.Square, 7e3, c2, i2, Math.max(1e-3, 0.2 * n2), 0.05);
|
|
512
|
+
this.vt(t2, i2, i2 + 0.4, a2, o2, c2);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
_N.bt = null;
|
|
517
|
+
let N = _N;
|
|
518
|
+
class T extends f {
|
|
519
|
+
constructor() {
|
|
520
|
+
super(...arguments), this.xt = { v: 0.6, a: 0.01, r: 0.1 };
|
|
521
|
+
}
|
|
522
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
523
|
+
const a2 = this.ot(t2, u.Sine, h2, s2), c2 = 2 * h2, l2 = 4 * c2, d2 = this.P(t2, 0, a2.frequency);
|
|
524
|
+
this.dt(d2.gain, l2 * e2, i2), this.Mt(d2.gain, 0.01, i2 + n2);
|
|
525
|
+
const p2 = this.ot(t2, u.Sine, c2, d2);
|
|
526
|
+
this.lt(i2, o2, a2, p2);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
class F extends p {
|
|
530
|
+
constructor() {
|
|
531
|
+
super(...arguments), this.xt = { v: 0.6, a: 5e-3, d: 0.5, m: 5 };
|
|
532
|
+
}
|
|
533
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
534
|
+
const a2 = [1, 0.6, 0.4, 0.2, 0.1];
|
|
535
|
+
[1, 2.76, 5.4, 8.9, 13.3].forEach((s3, o3) => {
|
|
536
|
+
const c2 = e2 * s3;
|
|
537
|
+
if (c2 < 22e3) {
|
|
538
|
+
const s4 = Math.max(1e-3, n2 * (1 / (o3 + 1.5))), e3 = Math.max(0.1, r2 * a2[o3]);
|
|
539
|
+
this.ft(t2, u.Sine, c2, i2, h2, s4, e3, 5e-3);
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
class V extends d {
|
|
545
|
+
l(t2, s2, i2, h2, e2, n2) {
|
|
546
|
+
const r2 = 1 / h2, o2 = t2.createBuffer(1, Math.max(1, t2.sampleRate * r2), t2.sampleRate), a2 = o2.getChannelData(0);
|
|
547
|
+
for (let t3 = 0; t3 < a2.length; t3++) a2[t3] = (2 * Math.random() - 1) * n2;
|
|
548
|
+
const c2 = t2.createBufferSource();
|
|
549
|
+
c2.buffer = o2;
|
|
550
|
+
const u2 = t2.createDelay(r2);
|
|
551
|
+
u2.delayTime.value = r2;
|
|
552
|
+
const d2 = this.ct(t2, l.Lowpass);
|
|
553
|
+
d2.frequency.value = Math.min(22e3, 6 * h2);
|
|
554
|
+
const p2 = this.P(t2, 0.98);
|
|
555
|
+
c2.connect(u2).connect(d2).connect(p2).connect(u2);
|
|
556
|
+
const y2 = this.P(t2, 0, s2);
|
|
557
|
+
this.dt(y2.gain, 1, i2), this.Mt(y2.gain, 1e-3, i2 + e2), u2.connect(y2), this.lt(i2, i2 + e2, c2), this.vt(t2, i2, i2 + e2 + 3, y2, u2, d2, p2);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
class B extends f {
|
|
561
|
+
constructor() {
|
|
562
|
+
super(...arguments), this.xt = { v: 0.7, a: 0.05, r: 0.2 };
|
|
563
|
+
}
|
|
564
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
565
|
+
const a2 = this.ct(t2, l.Lowpass);
|
|
566
|
+
this.dt(a2.frequency, 2 * h2, i2), this.St(t2, 6, 3 * h2, i2, 0, o2, a2.frequency);
|
|
567
|
+
const [c2, d2] = this._t(t2, u.Sawtooth, h2 / 2, 1.015, 0.4, a2);
|
|
568
|
+
a2.connect(s2), this.lt(i2, o2, c2, d2);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
class D extends f {
|
|
572
|
+
constructor() {
|
|
573
|
+
super(...arguments), this.xt = { v: 0.8, a: 0.1, r: 0.4 };
|
|
574
|
+
}
|
|
575
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
576
|
+
const a2 = this.ot(t2, u.Sawtooth, h2);
|
|
577
|
+
this.St(t2, 5, 0.015 * h2, i2, 0.2, o2, a2.frequency), [730, 1090, 2440].forEach((i3) => {
|
|
578
|
+
if (i3 < 22e3) {
|
|
579
|
+
const h3 = this.ct(t2, l.Bandpass);
|
|
580
|
+
h3.frequency.value = i3, h3.Q.value = 12, a2.connect(h3).connect(s2);
|
|
581
|
+
}
|
|
582
|
+
}), this.lt(i2, o2, a2);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
class I extends f {
|
|
586
|
+
constructor() {
|
|
587
|
+
super(...arguments), this.xt = { v: 0.4, a: 5e-3, r: 0.05 };
|
|
588
|
+
}
|
|
589
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
590
|
+
const a2 = this.ot(t2, u.Square, 0, s2);
|
|
591
|
+
this.dt(a2.frequency, 2 * h2, i2), this.dt(a2.frequency, h2, i2 + 0.02), this.lt(i2, o2, a2);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
class L extends p {
|
|
595
|
+
constructor() {
|
|
596
|
+
super(...arguments), this.xt = { v: 0.9, a: 5e-3, d: 0.15, m: 3 };
|
|
597
|
+
}
|
|
598
|
+
Ut(t2, s2, i2, h2, e2, n2, r2, o2) {
|
|
599
|
+
const a2 = this.wt(t2, l.Lowpass, 8 * e2 + 3e3 * n2, e2 + 100, h2, 0.1);
|
|
600
|
+
a2.Q.value = 3;
|
|
601
|
+
const c2 = this.ot(t2, u.Sawtooth, e2, i2), d2 = this.ot(t2, u.Sine, e2 / 2, i2);
|
|
602
|
+
return this.ft(t2, u.Square, 3.5 * e2, a2, h2, Math.max(1e-3, 0.4 * n2), 0.04), i2.connect(a2), this.lt(h2, o2, c2, d2), a2;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
const O = n([{ synth: new y(), start: 0, end: 7 }, { synth: new M(), start: 8, end: 15 }, { synth: new w(), start: 16, end: 23 }, { synth: new _(), start: 24, end: 26 }, { synth: new S(), start: 27, end: 31 }, { synth: new m(), start: 32, end: 39 }, { synth: new v(), start: 40, end: 55 }, { synth: new x(), start: 56, end: 71 }, { synth: new g(), start: 72, end: 79 }, { synth: new A(), start: 83, end: 87 }, { synth: new U(), start: 88, end: 95 }, { synth: new b(), start: 96, end: 103 }, { synth: new b(), start: 120, end: 127 }, { synth: new R(), start: 104, end: 111 }, { synth: new N(), start: 112, end: 119 }, { synth: new N(), start: 128, end: 128 }]), j = n([{ synth: new I(), start: 0, end: 127 }, { synth: new N(), start: 128, end: 128 }]);
|
|
606
|
+
class q extends o {
|
|
607
|
+
constructor(t2, s2) {
|
|
608
|
+
super(t2, s2 || O);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
class k extends a {
|
|
612
|
+
constructor(t2, s2) {
|
|
613
|
+
super(t2, s2 || O);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
class X extends c {
|
|
617
|
+
constructor(t2, s2) {
|
|
618
|
+
super(t2, s2 || O);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
export {
|
|
622
|
+
F as AdditiveSynth,
|
|
623
|
+
m as BassSynth,
|
|
624
|
+
x as BrassSynth,
|
|
625
|
+
I as ChiptuneSynth,
|
|
626
|
+
M as ChromaticPercussionSynth,
|
|
627
|
+
N as DrumSynth,
|
|
628
|
+
S as ElectricGuitarSynth,
|
|
629
|
+
R as EthnicSynth,
|
|
630
|
+
T as FMSynth,
|
|
631
|
+
D as FormantSynth,
|
|
632
|
+
_ as GuitarSynth,
|
|
633
|
+
V as KarplusSynth,
|
|
634
|
+
A as LeadSynth,
|
|
635
|
+
O as MasterInstrumentMap,
|
|
636
|
+
w as OrganSynth,
|
|
637
|
+
U as PadSynth,
|
|
638
|
+
y as PianoSynth,
|
|
639
|
+
q as RLOCore,
|
|
640
|
+
X as RLOGameEngine,
|
|
641
|
+
k as RLOMusicPlayer,
|
|
642
|
+
i as RLOTranspiler,
|
|
643
|
+
B as ReeseBassSynth,
|
|
644
|
+
j as RetroInstrumentMap,
|
|
645
|
+
h as SilentSynth,
|
|
646
|
+
L as SlapBassSynth,
|
|
647
|
+
b as SoundEffectsSynth,
|
|
648
|
+
O as StandardInstrumentMap,
|
|
649
|
+
v as StringSynth,
|
|
650
|
+
g as WoodwindSynth,
|
|
651
|
+
e as createDirectMap,
|
|
652
|
+
n as createInstrumentMap,
|
|
653
|
+
r as extendInstrumentMap
|
|
654
|
+
};
|
|
655
|
+
//# sourceMappingURL=rlo-engine.min.js.map
|