@famibee/skynovel 1.65.0 → 2.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/README.md +3 -3
- package/dist/Button.js +131 -163
- package/dist/Button.js.map +1 -1
- package/dist/CallStack.js +19 -22
- package/dist/CallStack.js.map +1 -1
- package/dist/CmnInterface.js +91 -0
- package/dist/CmnInterface.js.map +1 -0
- package/dist/CmnLib.js +94 -0
- package/dist/CmnLib.js.map +1 -0
- package/dist/Config.js +26 -0
- package/dist/Config.js.map +1 -0
- package/dist/ConfigBase.js +152 -0
- package/dist/ConfigBase.js.map +1 -0
- package/dist/DebugMng.js +89 -102
- package/dist/DebugMng.js.map +1 -1
- package/dist/EventListenerCtn.js +21 -0
- package/dist/EventListenerCtn.js.map +1 -0
- package/dist/EventMng.js +1435 -1577
- package/dist/EventMng.js.map +1 -1
- package/dist/Grammar.js +194 -0
- package/dist/Grammar.js.map +1 -0
- package/dist/GrpLayer.js +163 -195
- package/dist/GrpLayer.js.map +1 -1
- package/dist/Layer.js +260 -0
- package/dist/Layer.js.map +1 -0
- package/dist/LayerMng.js +810 -991
- package/dist/LayerMng.js.map +1 -1
- package/dist/Main.js +144 -393
- package/dist/Main.js.map +1 -1
- package/dist/PropParser.js +936 -834
- package/dist/PropParser.js.map +1 -1
- package/dist/Reading.js +917 -786
- package/dist/Reading.js.map +1 -1
- package/dist/RubySpliter.js +59 -92
- package/dist/RubySpliter.js.map +1 -1
- package/dist/ScriptIterator.js +805 -1034
- package/dist/ScriptIterator.js.map +1 -1
- package/dist/SndBuf.js +1097 -1332
- package/dist/SndBuf.js.map +1 -1
- package/dist/SoundMng.js +124 -135
- package/dist/SoundMng.js.map +1 -1
- package/dist/SpritesMng.js +220 -232
- package/dist/SpritesMng.js.map +1 -1
- package/dist/SysBase.js +1729 -0
- package/dist/SysBase.js.map +1 -0
- package/dist/TxtLayer.js +1212 -1397
- package/dist/TxtLayer.js.map +1 -1
- package/dist/Variable.js +398 -466
- package/dist/Variable.js.map +1 -1
- package/dist/chunk.js +18 -0
- package/dist/gamepad.js +723 -511
- package/dist/gamepad.js.map +1 -1
- package/dist/pixi.js +13422 -0
- package/dist/pixi.js.map +1 -0
- package/dist/platform.js +424 -369
- package/dist/platform.js.map +1 -1
- package/dist/sn/AnalyzeTagArg.d.ts +1 -1
- package/dist/sn/AnalyzeTagArg.d.ts.map +1 -1
- package/dist/sn/CmnInterface.d.ts +3 -1
- package/dist/sn/CmnInterface.d.ts.map +1 -1
- package/dist/sn/CmnLib.d.ts.map +1 -1
- package/dist/sn/CmnTween.d.ts +3 -3
- package/dist/sn/CmnTween.d.ts.map +1 -1
- package/dist/sn/EventMng.d.ts.map +1 -1
- package/dist/sn/Grammar.d.ts +1 -1
- package/dist/sn/Grammar.d.ts.map +1 -1
- package/dist/sn/PropParser.d.ts +2 -2
- package/dist/sn/PropParser.d.ts.map +1 -1
- package/dist/sn/Reading.d.ts +6 -0
- package/dist/sn/Reading.d.ts.map +1 -1
- package/dist/sn/ScriptIterator.d.ts.map +1 -1
- package/dist/sn/SndBuf.d.ts +27 -16
- package/dist/sn/SndBuf.d.ts.map +1 -1
- package/dist/sn/SoundMng.d.ts +4 -1
- package/dist/sn/SoundMng.d.ts.map +1 -1
- package/dist/sn/SysBase.d.ts.map +1 -1
- package/dist/sn/TxtStage.d.ts +2 -1
- package/dist/sn/TxtStage.d.ts.map +1 -1
- package/dist/test/ValTest.d.ts +1 -1
- package/dist/test/ValTest.d.ts.map +1 -1
- package/dist/web.js +653 -8
- package/dist/web.js.map +1 -1
- package/dist_app/Button.js +131 -163
- package/dist_app/Button.js.map +1 -1
- package/dist_app/CallStack.js +19 -22
- package/dist_app/CallStack.js.map +1 -1
- package/dist_app/CmnInterface.js +91 -0
- package/dist_app/CmnInterface.js.map +1 -0
- package/dist_app/CmnLib.js +94 -0
- package/dist_app/CmnLib.js.map +1 -0
- package/dist_app/Config.js +26 -0
- package/dist_app/Config.js.map +1 -0
- package/dist_app/ConfigBase.js +152 -0
- package/dist_app/ConfigBase.js.map +1 -0
- package/dist_app/DebugMng.js +92 -0
- package/dist_app/DebugMng.js.map +1 -0
- package/dist_app/EventListenerCtn.js +21 -0
- package/dist_app/EventListenerCtn.js.map +1 -0
- package/dist_app/EventMng.js +1435 -1577
- package/dist_app/EventMng.js.map +1 -1
- package/dist_app/Grammar.js +194 -0
- package/dist_app/Grammar.js.map +1 -0
- package/dist_app/GrpLayer.js +163 -195
- package/dist_app/GrpLayer.js.map +1 -1
- package/dist_app/Layer.js +260 -0
- package/dist_app/Layer.js.map +1 -0
- package/dist_app/LayerMng.js +810 -991
- package/dist_app/LayerMng.js.map +1 -1
- package/dist_app/Main.js +144 -392
- package/dist_app/Main.js.map +1 -1
- package/dist_app/PropParser.js +936 -834
- package/dist_app/PropParser.js.map +1 -1
- package/dist_app/Reading.js +917 -786
- package/dist_app/Reading.js.map +1 -1
- package/dist_app/RubySpliter.js +59 -92
- package/dist_app/RubySpliter.js.map +1 -1
- package/dist_app/ScriptIterator.js +805 -1033
- package/dist_app/ScriptIterator.js.map +1 -1
- package/dist_app/SndBuf.js +1097 -1332
- package/dist_app/SndBuf.js.map +1 -1
- package/dist_app/SoundMng.js +124 -135
- package/dist_app/SoundMng.js.map +1 -1
- package/dist_app/SpritesMng.js +220 -231
- package/dist_app/SpritesMng.js.map +1 -1
- package/dist_app/SysBase.js +1729 -0
- package/dist_app/SysBase.js.map +1 -0
- package/dist_app/TxtLayer.js +1212 -1396
- package/dist_app/TxtLayer.js.map +1 -1
- package/dist_app/Variable.js +398 -466
- package/dist_app/Variable.js.map +1 -1
- package/dist_app/app.js +211 -8
- package/dist_app/app.js.map +1 -1
- package/dist_app/appMain.js +20 -21
- package/dist_app/appMain.js.map +1 -1
- package/dist_app/chunk.js +18 -0
- package/dist_app/gamepad.js +723 -511
- package/dist_app/gamepad.js.map +1 -1
- package/dist_app/pixi.js +11181 -0
- package/dist_app/pixi.js.map +1 -0
- package/dist_app/platform.js +424 -369
- package/dist_app/platform.js.map +1 -1
- package/dist_app/preload.js +2 -2
- package/dist_app/preload.js.map +1 -1
- package/dist_app/sn/AnalyzeTagArg.d.ts +1 -1
- package/dist_app/sn/AnalyzeTagArg.d.ts.map +1 -1
- package/dist_app/sn/CmnInterface.d.ts +3 -1
- package/dist_app/sn/CmnInterface.d.ts.map +1 -1
- package/dist_app/sn/CmnLib.d.ts.map +1 -1
- package/dist_app/sn/CmnTween.d.ts +3 -3
- package/dist_app/sn/CmnTween.d.ts.map +1 -1
- package/dist_app/sn/EventMng.d.ts.map +1 -1
- package/dist_app/sn/Grammar.d.ts +1 -1
- package/dist_app/sn/Grammar.d.ts.map +1 -1
- package/dist_app/sn/PropParser.d.ts +2 -2
- package/dist_app/sn/PropParser.d.ts.map +1 -1
- package/dist_app/sn/Reading.d.ts +6 -0
- package/dist_app/sn/Reading.d.ts.map +1 -1
- package/dist_app/sn/ScriptIterator.d.ts.map +1 -1
- package/dist_app/sn/SndBuf.d.ts +27 -16
- package/dist_app/sn/SndBuf.d.ts.map +1 -1
- package/dist_app/sn/SoundMng.d.ts +4 -1
- package/dist_app/sn/SoundMng.d.ts.map +1 -1
- package/dist_app/sn/SysBase.d.ts.map +1 -1
- package/dist_app/sn/TxtStage.d.ts +2 -1
- package/dist_app/sn/TxtStage.d.ts.map +1 -1
- package/dist_app/test/ValTest.d.ts +1 -1
- package/dist_app/test/ValTest.d.ts.map +1 -1
- package/package.json +23 -13
- package/dist/CmnTween.js +0 -1005
- package/dist/CmnTween.js.map +0 -1
- package/dist/web2.js +0 -21644
- package/dist/web2.js.map +0 -1
- package/dist_app/CmnTween.js +0 -1005
- package/dist_app/CmnTween.js.map +0 -1
- package/dist_app/app2.js +0 -18547
- package/dist_app/app2.js.map +0 -1
package/dist_app/SndBuf.js
CHANGED
|
@@ -1,1336 +1,1101 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { t as __commonJSMin } from "./chunk.js";
|
|
2
|
+
import { l as argChk_Num, s as argChk_Boolean, t as CmnLib } from "./CmnLib.js";
|
|
3
|
+
import { n as SEARCH_PATH_ARG_EXT } from "./ConfigBase.js";
|
|
4
|
+
import { t as Reading } from "./Reading.js";
|
|
5
|
+
var require_howler = /* @__PURE__ */ __commonJSMin(((e) => {
|
|
6
|
+
(function() {
|
|
7
|
+
var n = function() {
|
|
8
|
+
this.init();
|
|
9
|
+
};
|
|
10
|
+
n.prototype = {
|
|
11
|
+
init: function() {
|
|
12
|
+
var e = this || r;
|
|
13
|
+
return e._counter = 1e3, e._html5AudioPool = [], e.html5PoolSize = 10, e._codecs = {}, e._howls = [], e._muted = !1, e._volume = 1, e._canPlayEvent = "canplaythrough", e._navigator = typeof window < "u" && window.navigator ? window.navigator : null, e.masterGain = null, e.noAudio = !1, e.usingWebAudio = !0, e.autoSuspend = !0, e.ctx = null, e.autoUnlock = !0, e._setup(), e;
|
|
14
|
+
},
|
|
15
|
+
volume: function(e) {
|
|
16
|
+
var n = this || r;
|
|
17
|
+
if (e = parseFloat(e), n.ctx || d(), e !== void 0 && e >= 0 && e <= 1) {
|
|
18
|
+
if (n._volume = e, n._muted) return n;
|
|
19
|
+
n.usingWebAudio && n.masterGain.gain.setValueAtTime(e, r.ctx.currentTime);
|
|
20
|
+
for (var i = 0; i < n._howls.length; i++) if (!n._howls[i]._webAudio) for (var a = n._howls[i]._getSoundIds(), o = 0; o < a.length; o++) {
|
|
21
|
+
var s = n._howls[i]._soundById(a[o]);
|
|
22
|
+
s && s._node && (s._node.volume = s._volume * e);
|
|
23
|
+
}
|
|
24
|
+
return n;
|
|
25
|
+
}
|
|
26
|
+
return n._volume;
|
|
27
|
+
},
|
|
28
|
+
mute: function(e) {
|
|
29
|
+
var n = this || r;
|
|
30
|
+
n.ctx || d(), n._muted = e, n.usingWebAudio && n.masterGain.gain.setValueAtTime(e ? 0 : n._volume, r.ctx.currentTime);
|
|
31
|
+
for (var i = 0; i < n._howls.length; i++) if (!n._howls[i]._webAudio) for (var a = n._howls[i]._getSoundIds(), o = 0; o < a.length; o++) {
|
|
32
|
+
var s = n._howls[i]._soundById(a[o]);
|
|
33
|
+
s && s._node && (s._node.muted = e ? !0 : s._muted);
|
|
34
|
+
}
|
|
35
|
+
return n;
|
|
36
|
+
},
|
|
37
|
+
stop: function() {
|
|
38
|
+
for (var e = this || r, n = 0; n < e._howls.length; n++) e._howls[n].stop();
|
|
39
|
+
return e;
|
|
40
|
+
},
|
|
41
|
+
unload: function() {
|
|
42
|
+
for (var e = this || r, n = e._howls.length - 1; n >= 0; n--) e._howls[n].unload();
|
|
43
|
+
return e.usingWebAudio && e.ctx && e.ctx.close !== void 0 && (e.ctx.close(), e.ctx = null, d()), e;
|
|
44
|
+
},
|
|
45
|
+
codecs: function(e) {
|
|
46
|
+
return (this || r)._codecs[e.replace(/^x-/, "")];
|
|
47
|
+
},
|
|
48
|
+
_setup: function() {
|
|
49
|
+
var e = this || r;
|
|
50
|
+
if (e.state = e.ctx && e.ctx.state || "suspended", e._autoSuspend(), !e.usingWebAudio) if (typeof Audio < "u") try {
|
|
51
|
+
var n = new Audio();
|
|
52
|
+
n.oncanplaythrough === void 0 && (e._canPlayEvent = "canplay");
|
|
53
|
+
} catch {
|
|
54
|
+
e.noAudio = !0;
|
|
55
|
+
}
|
|
56
|
+
else e.noAudio = !0;
|
|
57
|
+
try {
|
|
58
|
+
var n = new Audio();
|
|
59
|
+
n.muted && (e.noAudio = !0);
|
|
60
|
+
} catch {}
|
|
61
|
+
return e.noAudio || e._setupCodecs(), e;
|
|
62
|
+
},
|
|
63
|
+
_setupCodecs: function() {
|
|
64
|
+
var e = this || r, n = null;
|
|
65
|
+
try {
|
|
66
|
+
n = typeof Audio < "u" ? new Audio() : null;
|
|
67
|
+
} catch {
|
|
68
|
+
return e;
|
|
69
|
+
}
|
|
70
|
+
if (!n || typeof n.canPlayType != "function") return e;
|
|
71
|
+
var i = n.canPlayType("audio/mpeg;").replace(/^no$/, ""), a = e._navigator ? e._navigator.userAgent : "", o = a.match(/OPR\/(\d+)/g), s = o && parseInt(o[0].split("/")[1], 10) < 33, c = a.indexOf("Safari") !== -1 && a.indexOf("Chrome") === -1, l = a.match(/Version\/(.*?) /), u = c && l && parseInt(l[1], 10) < 15;
|
|
72
|
+
return e._codecs = {
|
|
73
|
+
mp3: !!(!s && (i || n.canPlayType("audio/mp3;").replace(/^no$/, ""))),
|
|
74
|
+
mpeg: !!i,
|
|
75
|
+
opus: !!n.canPlayType("audio/ogg; codecs=\"opus\"").replace(/^no$/, ""),
|
|
76
|
+
ogg: !!n.canPlayType("audio/ogg; codecs=\"vorbis\"").replace(/^no$/, ""),
|
|
77
|
+
oga: !!n.canPlayType("audio/ogg; codecs=\"vorbis\"").replace(/^no$/, ""),
|
|
78
|
+
wav: !!(n.canPlayType("audio/wav; codecs=\"1\"") || n.canPlayType("audio/wav")).replace(/^no$/, ""),
|
|
79
|
+
aac: !!n.canPlayType("audio/aac;").replace(/^no$/, ""),
|
|
80
|
+
caf: !!n.canPlayType("audio/x-caf;").replace(/^no$/, ""),
|
|
81
|
+
m4a: !!(n.canPlayType("audio/x-m4a;") || n.canPlayType("audio/m4a;") || n.canPlayType("audio/aac;")).replace(/^no$/, ""),
|
|
82
|
+
m4b: !!(n.canPlayType("audio/x-m4b;") || n.canPlayType("audio/m4b;") || n.canPlayType("audio/aac;")).replace(/^no$/, ""),
|
|
83
|
+
mp4: !!(n.canPlayType("audio/x-mp4;") || n.canPlayType("audio/mp4;") || n.canPlayType("audio/aac;")).replace(/^no$/, ""),
|
|
84
|
+
weba: !!(!u && n.canPlayType("audio/webm; codecs=\"vorbis\"").replace(/^no$/, "")),
|
|
85
|
+
webm: !!(!u && n.canPlayType("audio/webm; codecs=\"vorbis\"").replace(/^no$/, "")),
|
|
86
|
+
dolby: !!n.canPlayType("audio/mp4; codecs=\"ec-3\"").replace(/^no$/, ""),
|
|
87
|
+
flac: !!(n.canPlayType("audio/x-flac;") || n.canPlayType("audio/flac;")).replace(/^no$/, "")
|
|
88
|
+
}, e;
|
|
89
|
+
},
|
|
90
|
+
_unlockAudio: function() {
|
|
91
|
+
var e = this || r;
|
|
92
|
+
if (!(e._audioUnlocked || !e.ctx)) {
|
|
93
|
+
e._audioUnlocked = !1, e.autoUnlock = !1, !e._mobileUnloaded && e.ctx.sampleRate !== 44100 && (e._mobileUnloaded = !0, e.unload()), e._scratchBuffer = e.ctx.createBuffer(1, 1, 22050);
|
|
94
|
+
var n = function(r) {
|
|
95
|
+
for (; e._html5AudioPool.length < e.html5PoolSize;) try {
|
|
96
|
+
var i = new Audio();
|
|
97
|
+
i._unlocked = !0, e._releaseHtml5Audio(i);
|
|
98
|
+
} catch {
|
|
99
|
+
e.noAudio = !0;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
for (var a = 0; a < e._howls.length; a++) if (!e._howls[a]._webAudio) for (var o = e._howls[a]._getSoundIds(), s = 0; s < o.length; s++) {
|
|
103
|
+
var c = e._howls[a]._soundById(o[s]);
|
|
104
|
+
c && c._node && !c._node._unlocked && (c._node._unlocked = !0, c._node.load());
|
|
105
|
+
}
|
|
106
|
+
e._autoResume();
|
|
107
|
+
var l = e.ctx.createBufferSource();
|
|
108
|
+
l.buffer = e._scratchBuffer, l.connect(e.ctx.destination), l.start === void 0 ? l.noteOn(0) : l.start(0), typeof e.ctx.resume == "function" && e.ctx.resume(), l.onended = function() {
|
|
109
|
+
l.disconnect(0), e._audioUnlocked = !0, document.removeEventListener("touchstart", n, !0), document.removeEventListener("touchend", n, !0), document.removeEventListener("click", n, !0), document.removeEventListener("keydown", n, !0);
|
|
110
|
+
for (var r = 0; r < e._howls.length; r++) e._howls[r]._emit("unlock");
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
return document.addEventListener("touchstart", n, !0), document.addEventListener("touchend", n, !0), document.addEventListener("click", n, !0), document.addEventListener("keydown", n, !0), e;
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
_obtainHtml5Audio: function() {
|
|
117
|
+
var e = this || r;
|
|
118
|
+
if (e._html5AudioPool.length) return e._html5AudioPool.pop();
|
|
119
|
+
var n = new Audio().play();
|
|
120
|
+
return n && typeof Promise < "u" && (n instanceof Promise || typeof n.then == "function") && n.catch(function() {
|
|
121
|
+
console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.");
|
|
122
|
+
}), new Audio();
|
|
123
|
+
},
|
|
124
|
+
_releaseHtml5Audio: function(e) {
|
|
125
|
+
var n = this || r;
|
|
126
|
+
return e._unlocked && n._html5AudioPool.push(e), n;
|
|
127
|
+
},
|
|
128
|
+
_autoSuspend: function() {
|
|
129
|
+
var e = this;
|
|
130
|
+
if (!(!e.autoSuspend || !e.ctx || e.ctx.suspend === void 0 || !r.usingWebAudio)) {
|
|
131
|
+
for (var n = 0; n < e._howls.length; n++) if (e._howls[n]._webAudio) {
|
|
132
|
+
for (var i = 0; i < e._howls[n]._sounds.length; i++) if (!e._howls[n]._sounds[i]._paused) return e;
|
|
133
|
+
}
|
|
134
|
+
return e._suspendTimer && clearTimeout(e._suspendTimer), e._suspendTimer = setTimeout(function() {
|
|
135
|
+
if (e.autoSuspend) {
|
|
136
|
+
e._suspendTimer = null, e.state = "suspending";
|
|
137
|
+
var n = function() {
|
|
138
|
+
e.state = "suspended", e._resumeAfterSuspend && (delete e._resumeAfterSuspend, e._autoResume());
|
|
139
|
+
};
|
|
140
|
+
e.ctx.suspend().then(n, n);
|
|
141
|
+
}
|
|
142
|
+
}, 3e4), e;
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
_autoResume: function() {
|
|
146
|
+
var e = this;
|
|
147
|
+
if (!(!e.ctx || e.ctx.resume === void 0 || !r.usingWebAudio)) return e.state === "running" && e.ctx.state !== "interrupted" && e._suspendTimer ? (clearTimeout(e._suspendTimer), e._suspendTimer = null) : e.state === "suspended" || e.state === "running" && e.ctx.state === "interrupted" ? (e.ctx.resume().then(function() {
|
|
148
|
+
e.state = "running";
|
|
149
|
+
for (var n = 0; n < e._howls.length; n++) e._howls[n]._emit("resume");
|
|
150
|
+
}), e._suspendTimer &&= (clearTimeout(e._suspendTimer), null)) : e.state === "suspending" && (e._resumeAfterSuspend = !0), e;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
var r = new n(), i = function(e) {
|
|
154
|
+
var n = this;
|
|
155
|
+
if (!e.src || e.src.length === 0) {
|
|
156
|
+
console.error("An array of source files must be passed with any new Howl.");
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
n.init(e);
|
|
160
|
+
};
|
|
161
|
+
i.prototype = {
|
|
162
|
+
init: function(e) {
|
|
163
|
+
var n = this;
|
|
164
|
+
return r.ctx || d(), n._autoplay = e.autoplay || !1, n._format = typeof e.format == "string" ? [e.format] : e.format, n._html5 = e.html5 || !1, n._muted = e.mute || !1, n._loop = e.loop || !1, n._pool = e.pool || 5, n._preload = typeof e.preload == "boolean" || e.preload === "metadata" ? e.preload : !0, n._rate = e.rate || 1, n._sprite = e.sprite || {}, n._src = typeof e.src == "string" ? [e.src] : e.src, n._volume = e.volume === void 0 ? 1 : e.volume, n._xhr = {
|
|
165
|
+
method: e.xhr && e.xhr.method ? e.xhr.method : "GET",
|
|
166
|
+
headers: e.xhr && e.xhr.headers ? e.xhr.headers : null,
|
|
167
|
+
withCredentials: e.xhr && e.xhr.withCredentials ? e.xhr.withCredentials : !1
|
|
168
|
+
}, n._duration = 0, n._state = "unloaded", n._sounds = [], n._endTimers = {}, n._queue = [], n._playLock = !1, n._onend = e.onend ? [{ fn: e.onend }] : [], n._onfade = e.onfade ? [{ fn: e.onfade }] : [], n._onload = e.onload ? [{ fn: e.onload }] : [], n._onloaderror = e.onloaderror ? [{ fn: e.onloaderror }] : [], n._onplayerror = e.onplayerror ? [{ fn: e.onplayerror }] : [], n._onpause = e.onpause ? [{ fn: e.onpause }] : [], n._onplay = e.onplay ? [{ fn: e.onplay }] : [], n._onstop = e.onstop ? [{ fn: e.onstop }] : [], n._onmute = e.onmute ? [{ fn: e.onmute }] : [], n._onvolume = e.onvolume ? [{ fn: e.onvolume }] : [], n._onrate = e.onrate ? [{ fn: e.onrate }] : [], n._onseek = e.onseek ? [{ fn: e.onseek }] : [], n._onunlock = e.onunlock ? [{ fn: e.onunlock }] : [], n._onresume = [], n._webAudio = r.usingWebAudio && !n._html5, r.ctx !== void 0 && r.ctx && r.autoUnlock && r._unlockAudio(), r._howls.push(n), n._autoplay && n._queue.push({
|
|
169
|
+
event: "play",
|
|
170
|
+
action: function() {
|
|
171
|
+
n.play();
|
|
172
|
+
}
|
|
173
|
+
}), n._preload && n._preload !== "none" && n.load(), n;
|
|
174
|
+
},
|
|
175
|
+
load: function() {
|
|
176
|
+
var e = this, n = null;
|
|
177
|
+
if (r.noAudio) {
|
|
178
|
+
e._emit("loaderror", null, "No audio support.");
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
typeof e._src == "string" && (e._src = [e._src]);
|
|
182
|
+
for (var i = 0; i < e._src.length; i++) {
|
|
183
|
+
var o, c;
|
|
184
|
+
if (e._format && e._format[i]) o = e._format[i];
|
|
185
|
+
else {
|
|
186
|
+
if (c = e._src[i], typeof c != "string") {
|
|
187
|
+
e._emit("loaderror", null, "Non-string found in selected audio sources - ignoring.");
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
o = /^data:audio\/([^;,]+);/i.exec(c), o ||= /\.([^.]+)$/.exec(c.split("?", 1)[0]), o &&= o[1].toLowerCase();
|
|
191
|
+
}
|
|
192
|
+
if (o || console.warn("No file extension was found. Consider using the \"format\" property or specify an extension."), o && r.codecs(o)) {
|
|
193
|
+
n = e._src[i];
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (!n) {
|
|
198
|
+
e._emit("loaderror", null, "No codec support for selected audio sources.");
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
return e._src = n, e._state = "loading", window.location.protocol === "https:" && n.slice(0, 5) === "http:" && (e._html5 = !0, e._webAudio = !1), new a(e), e._webAudio && s(e), e;
|
|
202
|
+
},
|
|
203
|
+
play: function(e, n) {
|
|
204
|
+
var i = this, a = null;
|
|
205
|
+
if (typeof e == "number") a = e, e = null;
|
|
206
|
+
else if (typeof e == "string" && i._state === "loaded" && !i._sprite[e]) return null;
|
|
207
|
+
else if (e === void 0 && (e = "__default", !i._playLock)) {
|
|
208
|
+
for (var o = 0, s = 0; s < i._sounds.length; s++) i._sounds[s]._paused && !i._sounds[s]._ended && (o++, a = i._sounds[s]._id);
|
|
209
|
+
o === 1 ? e = null : a = null;
|
|
210
|
+
}
|
|
211
|
+
var c = a ? i._soundById(a) : i._inactiveSound();
|
|
212
|
+
if (!c) return null;
|
|
213
|
+
if (a && !e && (e = c._sprite || "__default"), i._state !== "loaded") {
|
|
214
|
+
c._sprite = e, c._ended = !1;
|
|
215
|
+
var l = c._id;
|
|
216
|
+
return i._queue.push({
|
|
217
|
+
event: "play",
|
|
218
|
+
action: function() {
|
|
219
|
+
i.play(l);
|
|
220
|
+
}
|
|
221
|
+
}), l;
|
|
222
|
+
}
|
|
223
|
+
if (a && !c._paused) return n || i._loadQueue("play"), c._id;
|
|
224
|
+
i._webAudio && r._autoResume();
|
|
225
|
+
var u = Math.max(0, c._seek > 0 ? c._seek : i._sprite[e][0] / 1e3), d = Math.max(0, (i._sprite[e][0] + i._sprite[e][1]) / 1e3 - u), f = d * 1e3 / Math.abs(c._rate), p = i._sprite[e][0] / 1e3, m = (i._sprite[e][0] + i._sprite[e][1]) / 1e3;
|
|
226
|
+
c._sprite = e, c._ended = !1;
|
|
227
|
+
var h = function() {
|
|
228
|
+
c._paused = !1, c._seek = u, c._start = p, c._stop = m, c._loop = !!(c._loop || i._sprite[e][2]);
|
|
229
|
+
};
|
|
230
|
+
if (u >= m) {
|
|
231
|
+
i._ended(c);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
var g = c._node;
|
|
235
|
+
if (i._webAudio) {
|
|
236
|
+
var _ = function() {
|
|
237
|
+
i._playLock = !1, h(), i._refreshBuffer(c);
|
|
238
|
+
var e = c._muted || i._muted ? 0 : c._volume;
|
|
239
|
+
g.gain.setValueAtTime(e, r.ctx.currentTime), c._playStart = r.ctx.currentTime, g.bufferSource.start === void 0 ? c._loop ? g.bufferSource.noteGrainOn(0, u, 86400) : g.bufferSource.noteGrainOn(0, u, d) : c._loop ? g.bufferSource.start(0, u, 86400) : g.bufferSource.start(0, u, d), f !== Infinity && (i._endTimers[c._id] = setTimeout(i._ended.bind(i, c), f)), n || setTimeout(function() {
|
|
240
|
+
i._emit("play", c._id), i._loadQueue();
|
|
241
|
+
}, 0);
|
|
242
|
+
};
|
|
243
|
+
r.state === "running" && r.ctx.state !== "interrupted" ? _() : (i._playLock = !0, i.once("resume", _), i._clearTimer(c._id));
|
|
244
|
+
} else {
|
|
245
|
+
var v = function() {
|
|
246
|
+
g.currentTime = u, g.muted = c._muted || i._muted || r._muted || g.muted, g.volume = c._volume * r.volume(), g.playbackRate = c._rate;
|
|
247
|
+
try {
|
|
248
|
+
var a = g.play();
|
|
249
|
+
if (a && typeof Promise < "u" && (a instanceof Promise || typeof a.then == "function") ? (i._playLock = !0, h(), a.then(function() {
|
|
250
|
+
i._playLock = !1, g._unlocked = !0, n ? i._loadQueue() : i._emit("play", c._id);
|
|
251
|
+
}).catch(function() {
|
|
252
|
+
i._playLock = !1, i._emit("playerror", c._id, "Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."), c._ended = !0, c._paused = !0;
|
|
253
|
+
})) : n || (i._playLock = !1, h(), i._emit("play", c._id)), g.playbackRate = c._rate, g.paused) {
|
|
254
|
+
i._emit("playerror", c._id, "Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
e !== "__default" || c._loop ? i._endTimers[c._id] = setTimeout(i._ended.bind(i, c), f) : (i._endTimers[c._id] = function() {
|
|
258
|
+
i._ended(c), g.removeEventListener("ended", i._endTimers[c._id], !1);
|
|
259
|
+
}, g.addEventListener("ended", i._endTimers[c._id], !1));
|
|
260
|
+
} catch (e) {
|
|
261
|
+
i._emit("playerror", c._id, e);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
g.src === "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA" && (g.src = i._src, g.load());
|
|
265
|
+
var y = window && window.ejecta || !g.readyState && r._navigator.isCocoonJS;
|
|
266
|
+
if (g.readyState >= 3 || y) v();
|
|
267
|
+
else {
|
|
268
|
+
i._playLock = !0, i._state = "loading";
|
|
269
|
+
var b = function() {
|
|
270
|
+
i._state = "loaded", v(), g.removeEventListener(r._canPlayEvent, b, !1);
|
|
271
|
+
};
|
|
272
|
+
g.addEventListener(r._canPlayEvent, b, !1), i._clearTimer(c._id);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return c._id;
|
|
276
|
+
},
|
|
277
|
+
pause: function(e) {
|
|
278
|
+
var n = this;
|
|
279
|
+
if (n._state !== "loaded" || n._playLock) return n._queue.push({
|
|
280
|
+
event: "pause",
|
|
281
|
+
action: function() {
|
|
282
|
+
n.pause(e);
|
|
283
|
+
}
|
|
284
|
+
}), n;
|
|
285
|
+
for (var r = n._getSoundIds(e), i = 0; i < r.length; i++) {
|
|
286
|
+
n._clearTimer(r[i]);
|
|
287
|
+
var a = n._soundById(r[i]);
|
|
288
|
+
if (a && !a._paused && (a._seek = n.seek(r[i]), a._rateSeek = 0, a._paused = !0, n._stopFade(r[i]), a._node)) if (n._webAudio) {
|
|
289
|
+
if (!a._node.bufferSource) continue;
|
|
290
|
+
a._node.bufferSource.stop === void 0 ? a._node.bufferSource.noteOff(0) : a._node.bufferSource.stop(0), n._cleanBuffer(a._node);
|
|
291
|
+
} else (!isNaN(a._node.duration) || a._node.duration === Infinity) && a._node.pause();
|
|
292
|
+
arguments[1] || n._emit("pause", a ? a._id : null);
|
|
293
|
+
}
|
|
294
|
+
return n;
|
|
295
|
+
},
|
|
296
|
+
stop: function(e, n) {
|
|
297
|
+
var r = this;
|
|
298
|
+
if (r._state !== "loaded" || r._playLock) return r._queue.push({
|
|
299
|
+
event: "stop",
|
|
300
|
+
action: function() {
|
|
301
|
+
r.stop(e);
|
|
302
|
+
}
|
|
303
|
+
}), r;
|
|
304
|
+
for (var i = r._getSoundIds(e), a = 0; a < i.length; a++) {
|
|
305
|
+
r._clearTimer(i[a]);
|
|
306
|
+
var o = r._soundById(i[a]);
|
|
307
|
+
o && (o._seek = o._start || 0, o._rateSeek = 0, o._paused = !0, o._ended = !0, r._stopFade(i[a]), o._node && (r._webAudio ? o._node.bufferSource && (o._node.bufferSource.stop === void 0 ? o._node.bufferSource.noteOff(0) : o._node.bufferSource.stop(0), r._cleanBuffer(o._node)) : (!isNaN(o._node.duration) || o._node.duration === Infinity) && (o._node.currentTime = o._start || 0, o._node.pause(), o._node.duration === Infinity && r._clearSound(o._node))), n || r._emit("stop", o._id));
|
|
308
|
+
}
|
|
309
|
+
return r;
|
|
310
|
+
},
|
|
311
|
+
mute: function(e, n) {
|
|
312
|
+
var i = this;
|
|
313
|
+
if (i._state !== "loaded" || i._playLock) return i._queue.push({
|
|
314
|
+
event: "mute",
|
|
315
|
+
action: function() {
|
|
316
|
+
i.mute(e, n);
|
|
317
|
+
}
|
|
318
|
+
}), i;
|
|
319
|
+
if (n === void 0) if (typeof e == "boolean") i._muted = e;
|
|
320
|
+
else return i._muted;
|
|
321
|
+
for (var a = i._getSoundIds(n), o = 0; o < a.length; o++) {
|
|
322
|
+
var s = i._soundById(a[o]);
|
|
323
|
+
s && (s._muted = e, s._interval && i._stopFade(s._id), i._webAudio && s._node ? s._node.gain.setValueAtTime(e ? 0 : s._volume, r.ctx.currentTime) : s._node && (s._node.muted = r._muted ? !0 : e), i._emit("mute", s._id));
|
|
324
|
+
}
|
|
325
|
+
return i;
|
|
326
|
+
},
|
|
327
|
+
volume: function() {
|
|
328
|
+
var e = this, n = arguments, i, a;
|
|
329
|
+
if (n.length === 0) return e._volume;
|
|
330
|
+
n.length === 1 || n.length === 2 && n[1] === void 0 ? e._getSoundIds().indexOf(n[0]) >= 0 ? a = parseInt(n[0], 10) : i = parseFloat(n[0]) : n.length >= 2 && (i = parseFloat(n[0]), a = parseInt(n[1], 10));
|
|
331
|
+
var o;
|
|
332
|
+
if (i !== void 0 && i >= 0 && i <= 1) {
|
|
333
|
+
if (e._state !== "loaded" || e._playLock) return e._queue.push({
|
|
334
|
+
event: "volume",
|
|
335
|
+
action: function() {
|
|
336
|
+
e.volume.apply(e, n);
|
|
337
|
+
}
|
|
338
|
+
}), e;
|
|
339
|
+
a === void 0 && (e._volume = i), a = e._getSoundIds(a);
|
|
340
|
+
for (var s = 0; s < a.length; s++) o = e._soundById(a[s]), o && (o._volume = i, n[2] || e._stopFade(a[s]), e._webAudio && o._node && !o._muted ? o._node.gain.setValueAtTime(i, r.ctx.currentTime) : o._node && !o._muted && (o._node.volume = i * r.volume()), e._emit("volume", o._id));
|
|
341
|
+
} else return o = a ? e._soundById(a) : e._sounds[0], o ? o._volume : 0;
|
|
342
|
+
return e;
|
|
343
|
+
},
|
|
344
|
+
fade: function(e, n, i, a) {
|
|
345
|
+
var o = this;
|
|
346
|
+
if (o._state !== "loaded" || o._playLock) return o._queue.push({
|
|
347
|
+
event: "fade",
|
|
348
|
+
action: function() {
|
|
349
|
+
o.fade(e, n, i, a);
|
|
350
|
+
}
|
|
351
|
+
}), o;
|
|
352
|
+
e = Math.min(Math.max(0, parseFloat(e)), 1), n = Math.min(Math.max(0, parseFloat(n)), 1), i = parseFloat(i), o.volume(e, a);
|
|
353
|
+
for (var s = o._getSoundIds(a), c = 0; c < s.length; c++) {
|
|
354
|
+
var l = o._soundById(s[c]);
|
|
355
|
+
if (l) {
|
|
356
|
+
if (a || o._stopFade(s[c]), o._webAudio && !l._muted) {
|
|
357
|
+
var u = r.ctx.currentTime, d = u + i / 1e3;
|
|
358
|
+
l._volume = e, l._node.gain.setValueAtTime(e, u), l._node.gain.linearRampToValueAtTime(n, d);
|
|
359
|
+
}
|
|
360
|
+
o._startFadeInterval(l, e, n, i, s[c], a === void 0);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return o;
|
|
364
|
+
},
|
|
365
|
+
_startFadeInterval: function(e, n, r, i, a, o) {
|
|
366
|
+
var s = this, c = n, l = r - n, u = Math.abs(l / .01), d = Math.max(4, u > 0 ? i / u : i), f = Date.now();
|
|
367
|
+
e._fadeTo = r, e._interval = setInterval(function() {
|
|
368
|
+
var a = (Date.now() - f) / i;
|
|
369
|
+
f = Date.now(), c += l * a, c = Math.round(c * 100) / 100, c = l < 0 ? Math.max(r, c) : Math.min(r, c), s._webAudio ? e._volume = c : s.volume(c, e._id, !0), o && (s._volume = c), (r < n && c <= r || r > n && c >= r) && (clearInterval(e._interval), e._interval = null, e._fadeTo = null, s.volume(r, e._id), s._emit("fade", e._id));
|
|
370
|
+
}, d);
|
|
371
|
+
},
|
|
372
|
+
_stopFade: function(e) {
|
|
373
|
+
var n = this, i = n._soundById(e);
|
|
374
|
+
return i && i._interval && (n._webAudio && i._node.gain.cancelScheduledValues(r.ctx.currentTime), clearInterval(i._interval), i._interval = null, n.volume(i._fadeTo, e), i._fadeTo = null, n._emit("fade", e)), n;
|
|
375
|
+
},
|
|
376
|
+
loop: function() {
|
|
377
|
+
var e = this, n = arguments, r, i, a;
|
|
378
|
+
if (n.length === 0) return e._loop;
|
|
379
|
+
if (n.length === 1) if (typeof n[0] == "boolean") r = n[0], e._loop = r;
|
|
380
|
+
else return a = e._soundById(parseInt(n[0], 10)), a ? a._loop : !1;
|
|
381
|
+
else n.length === 2 && (r = n[0], i = parseInt(n[1], 10));
|
|
382
|
+
for (var o = e._getSoundIds(i), s = 0; s < o.length; s++) a = e._soundById(o[s]), a && (a._loop = r, e._webAudio && a._node && a._node.bufferSource && (a._node.bufferSource.loop = r, r && (a._node.bufferSource.loopStart = a._start || 0, a._node.bufferSource.loopEnd = a._stop, e.playing(o[s]) && (e.pause(o[s], !0), e.play(o[s], !0)))));
|
|
383
|
+
return e;
|
|
384
|
+
},
|
|
385
|
+
rate: function() {
|
|
386
|
+
var e = this, n = arguments, i, a;
|
|
387
|
+
n.length === 0 ? a = e._sounds[0]._id : n.length === 1 ? e._getSoundIds().indexOf(n[0]) >= 0 ? a = parseInt(n[0], 10) : i = parseFloat(n[0]) : n.length === 2 && (i = parseFloat(n[0]), a = parseInt(n[1], 10));
|
|
388
|
+
var o;
|
|
389
|
+
if (typeof i == "number") {
|
|
390
|
+
if (e._state !== "loaded" || e._playLock) return e._queue.push({
|
|
391
|
+
event: "rate",
|
|
392
|
+
action: function() {
|
|
393
|
+
e.rate.apply(e, n);
|
|
394
|
+
}
|
|
395
|
+
}), e;
|
|
396
|
+
a === void 0 && (e._rate = i), a = e._getSoundIds(a);
|
|
397
|
+
for (var s = 0; s < a.length; s++) if (o = e._soundById(a[s]), o) {
|
|
398
|
+
e.playing(a[s]) && (o._rateSeek = e.seek(a[s]), o._playStart = e._webAudio ? r.ctx.currentTime : o._playStart), o._rate = i, e._webAudio && o._node && o._node.bufferSource ? o._node.bufferSource.playbackRate.setValueAtTime(i, r.ctx.currentTime) : o._node && (o._node.playbackRate = i);
|
|
399
|
+
var c = e.seek(a[s]), l = ((e._sprite[o._sprite][0] + e._sprite[o._sprite][1]) / 1e3 - c) * 1e3 / Math.abs(o._rate);
|
|
400
|
+
(e._endTimers[a[s]] || !o._paused) && (e._clearTimer(a[s]), e._endTimers[a[s]] = setTimeout(e._ended.bind(e, o), l)), e._emit("rate", o._id);
|
|
401
|
+
}
|
|
402
|
+
} else return o = e._soundById(a), o ? o._rate : e._rate;
|
|
403
|
+
return e;
|
|
404
|
+
},
|
|
405
|
+
seek: function() {
|
|
406
|
+
var e = this, n = arguments, i, a;
|
|
407
|
+
if (n.length === 0 ? e._sounds.length && (a = e._sounds[0]._id) : n.length === 1 ? e._getSoundIds().indexOf(n[0]) >= 0 ? a = parseInt(n[0], 10) : e._sounds.length && (a = e._sounds[0]._id, i = parseFloat(n[0])) : n.length === 2 && (i = parseFloat(n[0]), a = parseInt(n[1], 10)), a === void 0) return 0;
|
|
408
|
+
if (typeof i == "number" && (e._state !== "loaded" || e._playLock)) return e._queue.push({
|
|
409
|
+
event: "seek",
|
|
410
|
+
action: function() {
|
|
411
|
+
e.seek.apply(e, n);
|
|
412
|
+
}
|
|
413
|
+
}), e;
|
|
414
|
+
var o = e._soundById(a);
|
|
415
|
+
if (o) if (typeof i == "number" && i >= 0) {
|
|
416
|
+
var s = e.playing(a);
|
|
417
|
+
s && e.pause(a, !0), o._seek = i, o._ended = !1, e._clearTimer(a), !e._webAudio && o._node && !isNaN(o._node.duration) && (o._node.currentTime = i);
|
|
418
|
+
var c = function() {
|
|
419
|
+
s && e.play(a, !0), e._emit("seek", a);
|
|
420
|
+
};
|
|
421
|
+
if (s && !e._webAudio) {
|
|
422
|
+
var l = function() {
|
|
423
|
+
e._playLock ? setTimeout(l, 0) : c();
|
|
424
|
+
};
|
|
425
|
+
setTimeout(l, 0);
|
|
426
|
+
} else c();
|
|
427
|
+
} else if (e._webAudio) {
|
|
428
|
+
var u = e.playing(a) ? r.ctx.currentTime - o._playStart : 0, d = o._rateSeek ? o._rateSeek - o._seek : 0;
|
|
429
|
+
return o._seek + (d + u * Math.abs(o._rate));
|
|
430
|
+
} else return o._node.currentTime;
|
|
431
|
+
return e;
|
|
432
|
+
},
|
|
433
|
+
playing: function(e) {
|
|
434
|
+
var n = this;
|
|
435
|
+
if (typeof e == "number") {
|
|
436
|
+
var r = n._soundById(e);
|
|
437
|
+
return r ? !r._paused : !1;
|
|
438
|
+
}
|
|
439
|
+
for (var i = 0; i < n._sounds.length; i++) if (!n._sounds[i]._paused) return !0;
|
|
440
|
+
return !1;
|
|
441
|
+
},
|
|
442
|
+
duration: function(e) {
|
|
443
|
+
var n = this, r = n._duration, i = n._soundById(e);
|
|
444
|
+
return i && (r = n._sprite[i._sprite][1] / 1e3), r;
|
|
445
|
+
},
|
|
446
|
+
state: function() {
|
|
447
|
+
return this._state;
|
|
448
|
+
},
|
|
449
|
+
unload: function() {
|
|
450
|
+
for (var e = this, n = e._sounds, i = 0; i < n.length; i++) n[i]._paused || e.stop(n[i]._id), e._webAudio || (e._clearSound(n[i]._node), n[i]._node.removeEventListener("error", n[i]._errorFn, !1), n[i]._node.removeEventListener(r._canPlayEvent, n[i]._loadFn, !1), n[i]._node.removeEventListener("ended", n[i]._endFn, !1), r._releaseHtml5Audio(n[i]._node)), delete n[i]._node, e._clearTimer(n[i]._id);
|
|
451
|
+
var a = r._howls.indexOf(e);
|
|
452
|
+
a >= 0 && r._howls.splice(a, 1);
|
|
453
|
+
var s = !0;
|
|
454
|
+
for (i = 0; i < r._howls.length; i++) if (r._howls[i]._src === e._src || e._src.indexOf(r._howls[i]._src) >= 0) {
|
|
455
|
+
s = !1;
|
|
456
|
+
break;
|
|
457
|
+
}
|
|
458
|
+
return o && s && delete o[e._src], r.noAudio = !1, e._state = "unloaded", e._sounds = [], e = null, null;
|
|
459
|
+
},
|
|
460
|
+
on: function(e, n, r, i) {
|
|
461
|
+
var a = this, o = a["_on" + e];
|
|
462
|
+
return typeof n == "function" && o.push(i ? {
|
|
463
|
+
id: r,
|
|
464
|
+
fn: n,
|
|
465
|
+
once: i
|
|
466
|
+
} : {
|
|
467
|
+
id: r,
|
|
468
|
+
fn: n
|
|
469
|
+
}), a;
|
|
470
|
+
},
|
|
471
|
+
off: function(e, n, r) {
|
|
472
|
+
var i = this, a = i["_on" + e], o = 0;
|
|
473
|
+
if (typeof n == "number" && (r = n, n = null), n || r) for (o = 0; o < a.length; o++) {
|
|
474
|
+
var s = r === a[o].id;
|
|
475
|
+
if (n === a[o].fn && s || !n && s) {
|
|
476
|
+
a.splice(o, 1);
|
|
477
|
+
break;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
else if (e) i["_on" + e] = [];
|
|
481
|
+
else {
|
|
482
|
+
var c = Object.keys(i);
|
|
483
|
+
for (o = 0; o < c.length; o++) c[o].indexOf("_on") === 0 && Array.isArray(i[c[o]]) && (i[c[o]] = []);
|
|
484
|
+
}
|
|
485
|
+
return i;
|
|
486
|
+
},
|
|
487
|
+
once: function(e, n, r) {
|
|
488
|
+
var i = this;
|
|
489
|
+
return i.on(e, n, r, 1), i;
|
|
490
|
+
},
|
|
491
|
+
_emit: function(e, n, r) {
|
|
492
|
+
for (var i = this, a = i["_on" + e], o = a.length - 1; o >= 0; o--) (!a[o].id || a[o].id === n || e === "load") && (setTimeout(function(e) {
|
|
493
|
+
e.call(this, n, r);
|
|
494
|
+
}.bind(i, a[o].fn), 0), a[o].once && i.off(e, a[o].fn, a[o].id));
|
|
495
|
+
return i._loadQueue(e), i;
|
|
496
|
+
},
|
|
497
|
+
_loadQueue: function(e) {
|
|
498
|
+
var n = this;
|
|
499
|
+
if (n._queue.length > 0) {
|
|
500
|
+
var r = n._queue[0];
|
|
501
|
+
r.event === e && (n._queue.shift(), n._loadQueue()), e || r.action();
|
|
502
|
+
}
|
|
503
|
+
return n;
|
|
504
|
+
},
|
|
505
|
+
_ended: function(e) {
|
|
506
|
+
var n = this, i = e._sprite;
|
|
507
|
+
if (!n._webAudio && e._node && !e._node.paused && !e._node.ended && e._node.currentTime < e._stop) return setTimeout(n._ended.bind(n, e), 100), n;
|
|
508
|
+
var a = !!(e._loop || n._sprite[i][2]);
|
|
509
|
+
if (n._emit("end", e._id), !n._webAudio && a && n.stop(e._id, !0).play(e._id), n._webAudio && a) {
|
|
510
|
+
n._emit("play", e._id), e._seek = e._start || 0, e._rateSeek = 0, e._playStart = r.ctx.currentTime;
|
|
511
|
+
var o = (e._stop - e._start) * 1e3 / Math.abs(e._rate);
|
|
512
|
+
n._endTimers[e._id] = setTimeout(n._ended.bind(n, e), o);
|
|
513
|
+
}
|
|
514
|
+
return n._webAudio && !a && (e._paused = !0, e._ended = !0, e._seek = e._start || 0, e._rateSeek = 0, n._clearTimer(e._id), n._cleanBuffer(e._node), r._autoSuspend()), !n._webAudio && !a && n.stop(e._id, !0), n;
|
|
515
|
+
},
|
|
516
|
+
_clearTimer: function(e) {
|
|
517
|
+
var n = this;
|
|
518
|
+
if (n._endTimers[e]) {
|
|
519
|
+
if (typeof n._endTimers[e] != "function") clearTimeout(n._endTimers[e]);
|
|
520
|
+
else {
|
|
521
|
+
var r = n._soundById(e);
|
|
522
|
+
r && r._node && r._node.removeEventListener("ended", n._endTimers[e], !1);
|
|
523
|
+
}
|
|
524
|
+
delete n._endTimers[e];
|
|
525
|
+
}
|
|
526
|
+
return n;
|
|
527
|
+
},
|
|
528
|
+
_soundById: function(e) {
|
|
529
|
+
for (var n = this, r = 0; r < n._sounds.length; r++) if (e === n._sounds[r]._id) return n._sounds[r];
|
|
530
|
+
return null;
|
|
531
|
+
},
|
|
532
|
+
_inactiveSound: function() {
|
|
533
|
+
var e = this;
|
|
534
|
+
e._drain();
|
|
535
|
+
for (var n = 0; n < e._sounds.length; n++) if (e._sounds[n]._ended) return e._sounds[n].reset();
|
|
536
|
+
return new a(e);
|
|
537
|
+
},
|
|
538
|
+
_drain: function() {
|
|
539
|
+
var e = this, n = e._pool, r = 0, i = 0;
|
|
540
|
+
if (!(e._sounds.length < n)) {
|
|
541
|
+
for (i = 0; i < e._sounds.length; i++) e._sounds[i]._ended && r++;
|
|
542
|
+
for (i = e._sounds.length - 1; i >= 0; i--) {
|
|
543
|
+
if (r <= n) return;
|
|
544
|
+
e._sounds[i]._ended && (e._webAudio && e._sounds[i]._node && e._sounds[i]._node.disconnect(0), e._sounds.splice(i, 1), r--);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
},
|
|
548
|
+
_getSoundIds: function(e) {
|
|
549
|
+
var n = this;
|
|
550
|
+
if (e === void 0) {
|
|
551
|
+
for (var r = [], i = 0; i < n._sounds.length; i++) r.push(n._sounds[i]._id);
|
|
552
|
+
return r;
|
|
553
|
+
} else return [e];
|
|
554
|
+
},
|
|
555
|
+
_refreshBuffer: function(e) {
|
|
556
|
+
var n = this;
|
|
557
|
+
return e._node.bufferSource = r.ctx.createBufferSource(), e._node.bufferSource.buffer = o[n._src], e._panner ? e._node.bufferSource.connect(e._panner) : e._node.bufferSource.connect(e._node), e._node.bufferSource.loop = e._loop, e._loop && (e._node.bufferSource.loopStart = e._start || 0, e._node.bufferSource.loopEnd = e._stop || 0), e._node.bufferSource.playbackRate.setValueAtTime(e._rate, r.ctx.currentTime), n;
|
|
558
|
+
},
|
|
559
|
+
_cleanBuffer: function(e) {
|
|
560
|
+
var n = this, i = r._navigator && r._navigator.vendor.indexOf("Apple") >= 0;
|
|
561
|
+
if (!e.bufferSource) return n;
|
|
562
|
+
if (r._scratchBuffer && e.bufferSource && (e.bufferSource.onended = null, e.bufferSource.disconnect(0), i)) try {
|
|
563
|
+
e.bufferSource.buffer = r._scratchBuffer;
|
|
564
|
+
} catch {}
|
|
565
|
+
return e.bufferSource = null, n;
|
|
566
|
+
},
|
|
567
|
+
_clearSound: function(e) {
|
|
568
|
+
/MSIE |Trident\//.test(r._navigator && r._navigator.userAgent) || (e.src = "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA");
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
var a = function(e) {
|
|
572
|
+
this._parent = e, this.init();
|
|
573
|
+
};
|
|
574
|
+
a.prototype = {
|
|
575
|
+
init: function() {
|
|
576
|
+
var e = this, n = e._parent;
|
|
577
|
+
return e._muted = n._muted, e._loop = n._loop, e._volume = n._volume, e._rate = n._rate, e._seek = 0, e._paused = !0, e._ended = !0, e._sprite = "__default", e._id = ++r._counter, n._sounds.push(e), e.create(), e;
|
|
578
|
+
},
|
|
579
|
+
create: function() {
|
|
580
|
+
var e = this, n = e._parent, i = r._muted || e._muted || e._parent._muted ? 0 : e._volume;
|
|
581
|
+
return n._webAudio ? (e._node = r.ctx.createGain === void 0 ? r.ctx.createGainNode() : r.ctx.createGain(), e._node.gain.setValueAtTime(i, r.ctx.currentTime), e._node.paused = !0, e._node.connect(r.masterGain)) : r.noAudio || (e._node = r._obtainHtml5Audio(), e._errorFn = e._errorListener.bind(e), e._node.addEventListener("error", e._errorFn, !1), e._loadFn = e._loadListener.bind(e), e._node.addEventListener(r._canPlayEvent, e._loadFn, !1), e._endFn = e._endListener.bind(e), e._node.addEventListener("ended", e._endFn, !1), e._node.src = n._src, e._node.preload = n._preload === !0 ? "auto" : n._preload, e._node.volume = i * r.volume(), e._node.load()), e;
|
|
582
|
+
},
|
|
583
|
+
reset: function() {
|
|
584
|
+
var e = this, n = e._parent;
|
|
585
|
+
return e._muted = n._muted, e._loop = n._loop, e._volume = n._volume, e._rate = n._rate, e._seek = 0, e._rateSeek = 0, e._paused = !0, e._ended = !0, e._sprite = "__default", e._id = ++r._counter, e;
|
|
586
|
+
},
|
|
587
|
+
_errorListener: function() {
|
|
588
|
+
var e = this;
|
|
589
|
+
e._parent._emit("loaderror", e._id, e._node.error ? e._node.error.code : 0), e._node.removeEventListener("error", e._errorFn, !1);
|
|
590
|
+
},
|
|
591
|
+
_loadListener: function() {
|
|
592
|
+
var e = this, n = e._parent;
|
|
593
|
+
n._duration = Math.ceil(e._node.duration * 10) / 10, Object.keys(n._sprite).length === 0 && (n._sprite = { __default: [0, n._duration * 1e3] }), n._state !== "loaded" && (n._state = "loaded", n._emit("load"), n._loadQueue()), e._node.removeEventListener(r._canPlayEvent, e._loadFn, !1);
|
|
594
|
+
},
|
|
595
|
+
_endListener: function() {
|
|
596
|
+
var e = this, n = e._parent;
|
|
597
|
+
n._duration === Infinity && (n._duration = Math.ceil(e._node.duration * 10) / 10, n._sprite.__default[1] === Infinity && (n._sprite.__default[1] = n._duration * 1e3), n._ended(e)), e._node.removeEventListener("ended", e._endFn, !1);
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
var o = {}, s = function(e) {
|
|
601
|
+
var n = e._src;
|
|
602
|
+
if (o[n]) {
|
|
603
|
+
e._duration = o[n].duration, u(e);
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
if (/^data:[^;]+;base64,/.test(n)) {
|
|
607
|
+
for (var r = atob(n.split(",")[1]), i = new Uint8Array(r.length), a = 0; a < r.length; ++a) i[a] = r.charCodeAt(a);
|
|
608
|
+
l(i.buffer, e);
|
|
609
|
+
} else {
|
|
610
|
+
var s = new XMLHttpRequest();
|
|
611
|
+
s.open(e._xhr.method, n, !0), s.withCredentials = e._xhr.withCredentials, s.responseType = "arraybuffer", e._xhr.headers && Object.keys(e._xhr.headers).forEach(function(n) {
|
|
612
|
+
s.setRequestHeader(n, e._xhr.headers[n]);
|
|
613
|
+
}), s.onload = function() {
|
|
614
|
+
var n = (s.status + "")[0];
|
|
615
|
+
if (n !== "0" && n !== "2" && n !== "3") {
|
|
616
|
+
e._emit("loaderror", null, "Failed loading audio file with status: " + s.status + ".");
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
l(s.response, e);
|
|
620
|
+
}, s.onerror = function() {
|
|
621
|
+
e._webAudio && (e._html5 = !0, e._webAudio = !1, e._sounds = [], delete o[n], e.load());
|
|
622
|
+
}, c(s);
|
|
623
|
+
}
|
|
624
|
+
}, c = function(e) {
|
|
625
|
+
try {
|
|
626
|
+
e.send();
|
|
627
|
+
} catch {
|
|
628
|
+
e.onerror();
|
|
629
|
+
}
|
|
630
|
+
}, l = function(e, n) {
|
|
631
|
+
var i = function() {
|
|
632
|
+
n._emit("loaderror", null, "Decoding audio data failed.");
|
|
633
|
+
}, a = function(e) {
|
|
634
|
+
e && n._sounds.length > 0 ? (o[n._src] = e, u(n, e)) : i();
|
|
635
|
+
};
|
|
636
|
+
typeof Promise < "u" && r.ctx.decodeAudioData.length === 1 ? r.ctx.decodeAudioData(e).then(a).catch(i) : r.ctx.decodeAudioData(e, a, i);
|
|
637
|
+
}, u = function(e, n) {
|
|
638
|
+
n && !e._duration && (e._duration = n.duration), Object.keys(e._sprite).length === 0 && (e._sprite = { __default: [0, e._duration * 1e3] }), e._state !== "loaded" && (e._state = "loaded", e._emit("load"), e._loadQueue());
|
|
639
|
+
}, d = function() {
|
|
640
|
+
if (r.usingWebAudio) {
|
|
641
|
+
try {
|
|
642
|
+
typeof AudioContext < "u" ? r.ctx = new AudioContext() : typeof webkitAudioContext < "u" ? r.ctx = new webkitAudioContext() : r.usingWebAudio = !1;
|
|
643
|
+
} catch {
|
|
644
|
+
r.usingWebAudio = !1;
|
|
645
|
+
}
|
|
646
|
+
r.ctx || (r.usingWebAudio = !1);
|
|
647
|
+
var e = /iP(hone|od|ad)/.test(r._navigator && r._navigator.platform), n = r._navigator && r._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/), i = n ? parseInt(n[1], 10) : null;
|
|
648
|
+
if (e && i && i < 9) {
|
|
649
|
+
var a = /safari/.test(r._navigator && r._navigator.userAgent.toLowerCase());
|
|
650
|
+
r._navigator && !a && (r.usingWebAudio = !1);
|
|
651
|
+
}
|
|
652
|
+
r.usingWebAudio && (r.masterGain = r.ctx.createGain === void 0 ? r.ctx.createGainNode() : r.ctx.createGain(), r.masterGain.gain.setValueAtTime(r._muted ? 0 : r._volume, r.ctx.currentTime), r.masterGain.connect(r.ctx.destination)), r._setup();
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
typeof define == "function" && define.amd && define([], function() {
|
|
656
|
+
return {
|
|
657
|
+
Howler: r,
|
|
658
|
+
Howl: i
|
|
659
|
+
};
|
|
660
|
+
}), e !== void 0 && (e.Howler = r, e.Howl = i), typeof global < "u" ? (global.HowlerGlobal = n, global.Howler = r, global.Howl = i, global.Sound = a) : typeof window < "u" && (window.HowlerGlobal = n, window.Howler = r, window.Howl = i, window.Sound = a);
|
|
661
|
+
})(), (function() {
|
|
662
|
+
HowlerGlobal.prototype._pos = [
|
|
663
|
+
0,
|
|
664
|
+
0,
|
|
665
|
+
0
|
|
666
|
+
], HowlerGlobal.prototype._orientation = [
|
|
667
|
+
0,
|
|
668
|
+
0,
|
|
669
|
+
-1,
|
|
670
|
+
0,
|
|
671
|
+
1,
|
|
672
|
+
0
|
|
673
|
+
], HowlerGlobal.prototype.stereo = function(e) {
|
|
674
|
+
var n = this;
|
|
675
|
+
if (!n.ctx || !n.ctx.listener) return n;
|
|
676
|
+
for (var r = n._howls.length - 1; r >= 0; r--) n._howls[r].stereo(e);
|
|
677
|
+
return n;
|
|
678
|
+
}, HowlerGlobal.prototype.pos = function(e, n, r) {
|
|
679
|
+
var i = this;
|
|
680
|
+
if (!i.ctx || !i.ctx.listener) return i;
|
|
681
|
+
if (n = typeof n == "number" ? n : i._pos[1], r = typeof r == "number" ? r : i._pos[2], typeof e == "number") i._pos = [
|
|
682
|
+
e,
|
|
683
|
+
n,
|
|
684
|
+
r
|
|
685
|
+
], i.ctx.listener.positionX === void 0 ? i.ctx.listener.setPosition(i._pos[0], i._pos[1], i._pos[2]) : (i.ctx.listener.positionX.setTargetAtTime(i._pos[0], Howler.ctx.currentTime, .1), i.ctx.listener.positionY.setTargetAtTime(i._pos[1], Howler.ctx.currentTime, .1), i.ctx.listener.positionZ.setTargetAtTime(i._pos[2], Howler.ctx.currentTime, .1));
|
|
686
|
+
else return i._pos;
|
|
687
|
+
return i;
|
|
688
|
+
}, HowlerGlobal.prototype.orientation = function(e, n, r, i, a, o) {
|
|
689
|
+
var s = this;
|
|
690
|
+
if (!s.ctx || !s.ctx.listener) return s;
|
|
691
|
+
var c = s._orientation;
|
|
692
|
+
if (n = typeof n == "number" ? n : c[1], r = typeof r == "number" ? r : c[2], i = typeof i == "number" ? i : c[3], a = typeof a == "number" ? a : c[4], o = typeof o == "number" ? o : c[5], typeof e == "number") s._orientation = [
|
|
693
|
+
e,
|
|
694
|
+
n,
|
|
695
|
+
r,
|
|
696
|
+
i,
|
|
697
|
+
a,
|
|
698
|
+
o
|
|
699
|
+
], s.ctx.listener.forwardX === void 0 ? s.ctx.listener.setOrientation(e, n, r, i, a, o) : (s.ctx.listener.forwardX.setTargetAtTime(e, Howler.ctx.currentTime, .1), s.ctx.listener.forwardY.setTargetAtTime(n, Howler.ctx.currentTime, .1), s.ctx.listener.forwardZ.setTargetAtTime(r, Howler.ctx.currentTime, .1), s.ctx.listener.upX.setTargetAtTime(i, Howler.ctx.currentTime, .1), s.ctx.listener.upY.setTargetAtTime(a, Howler.ctx.currentTime, .1), s.ctx.listener.upZ.setTargetAtTime(o, Howler.ctx.currentTime, .1));
|
|
700
|
+
else return c;
|
|
701
|
+
return s;
|
|
702
|
+
}, Howl.prototype.init = (function(e) {
|
|
703
|
+
return function(n) {
|
|
704
|
+
var r = this;
|
|
705
|
+
return r._orientation = n.orientation || [
|
|
706
|
+
1,
|
|
707
|
+
0,
|
|
708
|
+
0
|
|
709
|
+
], r._stereo = n.stereo || null, r._pos = n.pos || null, r._pannerAttr = {
|
|
710
|
+
coneInnerAngle: n.coneInnerAngle === void 0 ? 360 : n.coneInnerAngle,
|
|
711
|
+
coneOuterAngle: n.coneOuterAngle === void 0 ? 360 : n.coneOuterAngle,
|
|
712
|
+
coneOuterGain: n.coneOuterGain === void 0 ? 0 : n.coneOuterGain,
|
|
713
|
+
distanceModel: n.distanceModel === void 0 ? "inverse" : n.distanceModel,
|
|
714
|
+
maxDistance: n.maxDistance === void 0 ? 1e4 : n.maxDistance,
|
|
715
|
+
panningModel: n.panningModel === void 0 ? "HRTF" : n.panningModel,
|
|
716
|
+
refDistance: n.refDistance === void 0 ? 1 : n.refDistance,
|
|
717
|
+
rolloffFactor: n.rolloffFactor === void 0 ? 1 : n.rolloffFactor
|
|
718
|
+
}, r._onstereo = n.onstereo ? [{ fn: n.onstereo }] : [], r._onpos = n.onpos ? [{ fn: n.onpos }] : [], r._onorientation = n.onorientation ? [{ fn: n.onorientation }] : [], e.call(this, n);
|
|
719
|
+
};
|
|
720
|
+
})(Howl.prototype.init), Howl.prototype.stereo = function(n, r) {
|
|
721
|
+
var i = this;
|
|
722
|
+
if (!i._webAudio) return i;
|
|
723
|
+
if (i._state !== "loaded") return i._queue.push({
|
|
724
|
+
event: "stereo",
|
|
725
|
+
action: function() {
|
|
726
|
+
i.stereo(n, r);
|
|
727
|
+
}
|
|
728
|
+
}), i;
|
|
729
|
+
var a = Howler.ctx.createStereoPanner === void 0 ? "spatial" : "stereo";
|
|
730
|
+
if (r === void 0) if (typeof n == "number") i._stereo = n, i._pos = [
|
|
731
|
+
n,
|
|
732
|
+
0,
|
|
733
|
+
0
|
|
734
|
+
];
|
|
735
|
+
else return i._stereo;
|
|
736
|
+
for (var o = i._getSoundIds(r), s = 0; s < o.length; s++) {
|
|
737
|
+
var c = i._soundById(o[s]);
|
|
738
|
+
if (c) if (typeof n == "number") c._stereo = n, c._pos = [
|
|
739
|
+
n,
|
|
740
|
+
0,
|
|
741
|
+
0
|
|
742
|
+
], c._node && (c._pannerAttr.panningModel = "equalpower", (!c._panner || !c._panner.pan) && e(c, a), a === "spatial" ? c._panner.positionX === void 0 ? c._panner.setPosition(n, 0, 0) : (c._panner.positionX.setValueAtTime(n, Howler.ctx.currentTime), c._panner.positionY.setValueAtTime(0, Howler.ctx.currentTime), c._panner.positionZ.setValueAtTime(0, Howler.ctx.currentTime)) : c._panner.pan.setValueAtTime(n, Howler.ctx.currentTime)), i._emit("stereo", c._id);
|
|
743
|
+
else return c._stereo;
|
|
744
|
+
}
|
|
745
|
+
return i;
|
|
746
|
+
}, Howl.prototype.pos = function(n, r, i, a) {
|
|
747
|
+
var o = this;
|
|
748
|
+
if (!o._webAudio) return o;
|
|
749
|
+
if (o._state !== "loaded") return o._queue.push({
|
|
750
|
+
event: "pos",
|
|
751
|
+
action: function() {
|
|
752
|
+
o.pos(n, r, i, a);
|
|
753
|
+
}
|
|
754
|
+
}), o;
|
|
755
|
+
if (r = typeof r == "number" ? r : 0, i = typeof i == "number" ? i : -.5, a === void 0) if (typeof n == "number") o._pos = [
|
|
756
|
+
n,
|
|
757
|
+
r,
|
|
758
|
+
i
|
|
759
|
+
];
|
|
760
|
+
else return o._pos;
|
|
761
|
+
for (var s = o._getSoundIds(a), c = 0; c < s.length; c++) {
|
|
762
|
+
var l = o._soundById(s[c]);
|
|
763
|
+
if (l) if (typeof n == "number") l._pos = [
|
|
764
|
+
n,
|
|
765
|
+
r,
|
|
766
|
+
i
|
|
767
|
+
], l._node && ((!l._panner || l._panner.pan) && e(l, "spatial"), l._panner.positionX === void 0 ? l._panner.setPosition(n, r, i) : (l._panner.positionX.setValueAtTime(n, Howler.ctx.currentTime), l._panner.positionY.setValueAtTime(r, Howler.ctx.currentTime), l._panner.positionZ.setValueAtTime(i, Howler.ctx.currentTime))), o._emit("pos", l._id);
|
|
768
|
+
else return l._pos;
|
|
769
|
+
}
|
|
770
|
+
return o;
|
|
771
|
+
}, Howl.prototype.orientation = function(n, r, i, a) {
|
|
772
|
+
var o = this;
|
|
773
|
+
if (!o._webAudio) return o;
|
|
774
|
+
if (o._state !== "loaded") return o._queue.push({
|
|
775
|
+
event: "orientation",
|
|
776
|
+
action: function() {
|
|
777
|
+
o.orientation(n, r, i, a);
|
|
778
|
+
}
|
|
779
|
+
}), o;
|
|
780
|
+
if (r = typeof r == "number" ? r : o._orientation[1], i = typeof i == "number" ? i : o._orientation[2], a === void 0) if (typeof n == "number") o._orientation = [
|
|
781
|
+
n,
|
|
782
|
+
r,
|
|
783
|
+
i
|
|
784
|
+
];
|
|
785
|
+
else return o._orientation;
|
|
786
|
+
for (var s = o._getSoundIds(a), c = 0; c < s.length; c++) {
|
|
787
|
+
var l = o._soundById(s[c]);
|
|
788
|
+
if (l) if (typeof n == "number") l._orientation = [
|
|
789
|
+
n,
|
|
790
|
+
r,
|
|
791
|
+
i
|
|
792
|
+
], l._node && (l._panner || (l._pos ||= o._pos || [
|
|
793
|
+
0,
|
|
794
|
+
0,
|
|
795
|
+
-.5
|
|
796
|
+
], e(l, "spatial")), l._panner.orientationX === void 0 ? l._panner.setOrientation(n, r, i) : (l._panner.orientationX.setValueAtTime(n, Howler.ctx.currentTime), l._panner.orientationY.setValueAtTime(r, Howler.ctx.currentTime), l._panner.orientationZ.setValueAtTime(i, Howler.ctx.currentTime))), o._emit("orientation", l._id);
|
|
797
|
+
else return l._orientation;
|
|
798
|
+
}
|
|
799
|
+
return o;
|
|
800
|
+
}, Howl.prototype.pannerAttr = function() {
|
|
801
|
+
var n = this, r = arguments, i, a, o;
|
|
802
|
+
if (!n._webAudio) return n;
|
|
803
|
+
if (r.length === 0) return n._pannerAttr;
|
|
804
|
+
if (r.length === 1) if (typeof r[0] == "object") i = r[0], a === void 0 && (i.pannerAttr ||= {
|
|
805
|
+
coneInnerAngle: i.coneInnerAngle,
|
|
806
|
+
coneOuterAngle: i.coneOuterAngle,
|
|
807
|
+
coneOuterGain: i.coneOuterGain,
|
|
808
|
+
distanceModel: i.distanceModel,
|
|
809
|
+
maxDistance: i.maxDistance,
|
|
810
|
+
refDistance: i.refDistance,
|
|
811
|
+
rolloffFactor: i.rolloffFactor,
|
|
812
|
+
panningModel: i.panningModel
|
|
813
|
+
}, n._pannerAttr = {
|
|
814
|
+
coneInnerAngle: i.pannerAttr.coneInnerAngle === void 0 ? n._coneInnerAngle : i.pannerAttr.coneInnerAngle,
|
|
815
|
+
coneOuterAngle: i.pannerAttr.coneOuterAngle === void 0 ? n._coneOuterAngle : i.pannerAttr.coneOuterAngle,
|
|
816
|
+
coneOuterGain: i.pannerAttr.coneOuterGain === void 0 ? n._coneOuterGain : i.pannerAttr.coneOuterGain,
|
|
817
|
+
distanceModel: i.pannerAttr.distanceModel === void 0 ? n._distanceModel : i.pannerAttr.distanceModel,
|
|
818
|
+
maxDistance: i.pannerAttr.maxDistance === void 0 ? n._maxDistance : i.pannerAttr.maxDistance,
|
|
819
|
+
refDistance: i.pannerAttr.refDistance === void 0 ? n._refDistance : i.pannerAttr.refDistance,
|
|
820
|
+
rolloffFactor: i.pannerAttr.rolloffFactor === void 0 ? n._rolloffFactor : i.pannerAttr.rolloffFactor,
|
|
821
|
+
panningModel: i.pannerAttr.panningModel === void 0 ? n._panningModel : i.pannerAttr.panningModel
|
|
822
|
+
});
|
|
823
|
+
else return o = n._soundById(parseInt(r[0], 10)), o ? o._pannerAttr : n._pannerAttr;
|
|
824
|
+
else r.length === 2 && (i = r[0], a = parseInt(r[1], 10));
|
|
825
|
+
for (var s = n._getSoundIds(a), c = 0; c < s.length; c++) if (o = n._soundById(s[c]), o) {
|
|
826
|
+
var l = o._pannerAttr;
|
|
827
|
+
l = {
|
|
828
|
+
coneInnerAngle: i.coneInnerAngle === void 0 ? l.coneInnerAngle : i.coneInnerAngle,
|
|
829
|
+
coneOuterAngle: i.coneOuterAngle === void 0 ? l.coneOuterAngle : i.coneOuterAngle,
|
|
830
|
+
coneOuterGain: i.coneOuterGain === void 0 ? l.coneOuterGain : i.coneOuterGain,
|
|
831
|
+
distanceModel: i.distanceModel === void 0 ? l.distanceModel : i.distanceModel,
|
|
832
|
+
maxDistance: i.maxDistance === void 0 ? l.maxDistance : i.maxDistance,
|
|
833
|
+
refDistance: i.refDistance === void 0 ? l.refDistance : i.refDistance,
|
|
834
|
+
rolloffFactor: i.rolloffFactor === void 0 ? l.rolloffFactor : i.rolloffFactor,
|
|
835
|
+
panningModel: i.panningModel === void 0 ? l.panningModel : i.panningModel
|
|
836
|
+
};
|
|
837
|
+
var u = o._panner;
|
|
838
|
+
u ||= (o._pos ||= n._pos || [
|
|
839
|
+
0,
|
|
840
|
+
0,
|
|
841
|
+
-.5
|
|
842
|
+
], e(o, "spatial"), o._panner), u.coneInnerAngle = l.coneInnerAngle, u.coneOuterAngle = l.coneOuterAngle, u.coneOuterGain = l.coneOuterGain, u.distanceModel = l.distanceModel, u.maxDistance = l.maxDistance, u.refDistance = l.refDistance, u.rolloffFactor = l.rolloffFactor, u.panningModel = l.panningModel;
|
|
843
|
+
}
|
|
844
|
+
return n;
|
|
845
|
+
}, Sound.prototype.init = (function(e) {
|
|
846
|
+
return function() {
|
|
847
|
+
var n = this, r = n._parent;
|
|
848
|
+
n._orientation = r._orientation, n._stereo = r._stereo, n._pos = r._pos, n._pannerAttr = r._pannerAttr, e.call(this), n._stereo ? r.stereo(n._stereo) : n._pos && r.pos(n._pos[0], n._pos[1], n._pos[2], n._id);
|
|
849
|
+
};
|
|
850
|
+
})(Sound.prototype.init), Sound.prototype.reset = (function(e) {
|
|
851
|
+
return function() {
|
|
852
|
+
var n = this, r = n._parent;
|
|
853
|
+
return n._orientation = r._orientation, n._stereo = r._stereo, n._pos = r._pos, n._pannerAttr = r._pannerAttr, n._stereo ? r.stereo(n._stereo) : n._pos ? r.pos(n._pos[0], n._pos[1], n._pos[2], n._id) : n._panner && (n._panner.disconnect(0), n._panner = void 0, r._refreshBuffer(n)), e.call(this);
|
|
854
|
+
};
|
|
855
|
+
})(Sound.prototype.reset);
|
|
856
|
+
var e = function(e, n) {
|
|
857
|
+
n ||= "spatial", n === "spatial" ? (e._panner = Howler.ctx.createPanner(), e._panner.coneInnerAngle = e._pannerAttr.coneInnerAngle, e._panner.coneOuterAngle = e._pannerAttr.coneOuterAngle, e._panner.coneOuterGain = e._pannerAttr.coneOuterGain, e._panner.distanceModel = e._pannerAttr.distanceModel, e._panner.maxDistance = e._pannerAttr.maxDistance, e._panner.refDistance = e._pannerAttr.refDistance, e._panner.rolloffFactor = e._pannerAttr.rolloffFactor, e._panner.panningModel = e._pannerAttr.panningModel, e._panner.positionX === void 0 ? e._panner.setPosition(e._pos[0], e._pos[1], e._pos[2]) : (e._panner.positionX.setValueAtTime(e._pos[0], Howler.ctx.currentTime), e._panner.positionY.setValueAtTime(e._pos[1], Howler.ctx.currentTime), e._panner.positionZ.setValueAtTime(e._pos[2], Howler.ctx.currentTime)), e._panner.orientationX === void 0 ? e._panner.setOrientation(e._orientation[0], e._orientation[1], e._orientation[2]) : (e._panner.orientationX.setValueAtTime(e._orientation[0], Howler.ctx.currentTime), e._panner.orientationY.setValueAtTime(e._orientation[1], Howler.ctx.currentTime), e._panner.orientationZ.setValueAtTime(e._orientation[2], Howler.ctx.currentTime))) : (e._panner = Howler.ctx.createStereoPanner(), e._panner.pan.setValueAtTime(e._stereo, Howler.ctx.currentTime)), e._panner.connect(e._node), e._paused || e._parent.pause(e._id, !0).play(e._id, !0);
|
|
858
|
+
};
|
|
859
|
+
})();
|
|
860
|
+
})), import_howler = require_howler();
|
|
861
|
+
const BUF_BGM = "BGM", BUF_SE = "SE";
|
|
862
|
+
var BUF_VOICE = "VOICE", MAX_END_MS = 999e3, val, errScript, getSndBuf, evtMng, hLP = {}, vol_mul_talking = 1;
|
|
863
|
+
function delLoopPlay(e) {
|
|
864
|
+
delete hLP[e];
|
|
865
|
+
let n = "const.sn.sound." + e + ".";
|
|
866
|
+
val.setVal_Nochk("save", n + "fn", ""), val.setVal_Nochk("save", "const.sn.loopPlaying", JSON.stringify(hLP)), val.flush();
|
|
6
867
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} || function(t, s) {
|
|
11
|
-
for (var o in s) Object.prototype.hasOwnProperty.call(s, o) && (t[o] = s[o]);
|
|
12
|
-
})(n, e);
|
|
13
|
-
};
|
|
14
|
-
function b(n, e) {
|
|
15
|
-
if (typeof e != "function" && e !== null) throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
|
|
16
|
-
function t() {
|
|
17
|
-
this.constructor = n;
|
|
18
|
-
}
|
|
19
|
-
se(n, e), n.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
|
|
20
|
-
}
|
|
21
|
-
var V = function() {
|
|
22
|
-
return (V = Object.assign || function(n) {
|
|
23
|
-
for (var e, t = 1, s = arguments.length; t < s; t++) for (var o in e = arguments[t]) Object.prototype.hasOwnProperty.call(e, o) && (n[o] = e[o]);
|
|
24
|
-
return n;
|
|
25
|
-
}).apply(this, arguments);
|
|
26
|
-
}, ne = ["mp3", "ogg", "oga", "opus", "mpeg", "wav", "m4a", "aiff", "wma", "mid", "caf"], K = {};
|
|
27
|
-
function de(n) {
|
|
28
|
-
var e = V({ m4a: "audio/mp4", oga: "audio/ogg", opus: 'audio/ogg; codecs="opus"', caf: 'audio/x-caf; codecs="opus"' }, n || {}), t = document.createElement("audio"), s = {}, o = /^no$/;
|
|
29
|
-
ne.forEach(function(i) {
|
|
30
|
-
var r = t.canPlayType("audio/".concat(i)).replace(o, ""), u = e[i] ? t.canPlayType(e[i]).replace(o, "") : "";
|
|
31
|
-
s[i] = !!r || !!u;
|
|
32
|
-
}), Object.assign(K, s);
|
|
33
|
-
}
|
|
34
|
-
de();
|
|
35
|
-
var _e = /\.(\{([^\}]+)\})(\?.*)?$/;
|
|
36
|
-
function oe(n) {
|
|
37
|
-
var e = _e, t = typeof n == "string" ? n : n.url;
|
|
38
|
-
if (!e.test(t)) return t;
|
|
39
|
-
for (var s = e.exec(t), o = s[2].split(","), i = o[o.length - 1], r = 0, u = o.length; r < u; r++) {
|
|
40
|
-
var a = o[r];
|
|
41
|
-
if (K[a]) {
|
|
42
|
-
i = a;
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
var l = t.replace(s[1], i);
|
|
47
|
-
if (typeof n != "string") {
|
|
48
|
-
var h = n;
|
|
49
|
-
h.extension = i, h.url = l;
|
|
50
|
-
}
|
|
51
|
-
return l;
|
|
52
|
-
}
|
|
53
|
-
var q = ne.filter(function(n) {
|
|
54
|
-
return K[n];
|
|
55
|
-
}), ie = function() {
|
|
56
|
-
function n() {
|
|
57
|
-
}
|
|
58
|
-
return n.add = function() {
|
|
59
|
-
n.setLegacy(_().useLegacy);
|
|
60
|
-
}, n.setLegacy = function(e) {
|
|
61
|
-
e ? q.forEach(function(t) {
|
|
62
|
-
S.setExtensionXhrType(t, S.XHR_RESPONSE_TYPE.DEFAULT), S.setExtensionLoadType(t, S.LOAD_TYPE.AUDIO);
|
|
63
|
-
}) : q.forEach(function(t) {
|
|
64
|
-
S.setExtensionXhrType(t, S.XHR_RESPONSE_TYPE.BUFFER), S.setExtensionLoadType(t, S.LOAD_TYPE.XHR);
|
|
65
|
-
});
|
|
66
|
-
}, n.pre = function(e, t) {
|
|
67
|
-
oe(e), t();
|
|
68
|
-
}, n.use = function(e, t) {
|
|
69
|
-
e.data && q.indexOf(e.extension) > -1 ? e.sound = _().add(e.name, { loaded: t, preload: !0, url: e.url, source: e.data }) : t();
|
|
70
|
-
}, n.extension = "loader", n;
|
|
71
|
-
}(), ye = 0, me = function(n) {
|
|
72
|
-
function e(t) {
|
|
73
|
-
var s = n.call(this) || this;
|
|
74
|
-
return s.id = ye++, s.init(t), s;
|
|
75
|
-
}
|
|
76
|
-
return b(e, n), e.prototype.set = function(t, s) {
|
|
77
|
-
if (this[t] === void 0) throw new Error("Property with name ".concat(t, " does not exist."));
|
|
78
|
-
switch (t) {
|
|
79
|
-
case "speed":
|
|
80
|
-
this.speed = s;
|
|
81
|
-
break;
|
|
82
|
-
case "volume":
|
|
83
|
-
this.volume = s;
|
|
84
|
-
break;
|
|
85
|
-
case "paused":
|
|
86
|
-
this.paused = s;
|
|
87
|
-
break;
|
|
88
|
-
case "loop":
|
|
89
|
-
this.loop = s;
|
|
90
|
-
break;
|
|
91
|
-
case "muted":
|
|
92
|
-
this.muted = s;
|
|
93
|
-
}
|
|
94
|
-
return this;
|
|
95
|
-
}, Object.defineProperty(e.prototype, "progress", { get: function() {
|
|
96
|
-
return this._source.currentTime / this._duration;
|
|
97
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "paused", { get: function() {
|
|
98
|
-
return this._paused;
|
|
99
|
-
}, set: function(t) {
|
|
100
|
-
this._paused = t, this.refreshPaused();
|
|
101
|
-
}, enumerable: !1, configurable: !0 }), e.prototype._onPlay = function() {
|
|
102
|
-
this._playing = !0;
|
|
103
|
-
}, e.prototype._onPause = function() {
|
|
104
|
-
this._playing = !1;
|
|
105
|
-
}, e.prototype.init = function(t) {
|
|
106
|
-
this._playing = !1, this._duration = t.source.duration;
|
|
107
|
-
var s = this._source = t.source.cloneNode(!1);
|
|
108
|
-
s.src = t.parent.url, s.onplay = this._onPlay.bind(this), s.onpause = this._onPause.bind(this), t.context.on("refresh", this.refresh, this), t.context.on("refreshPaused", this.refreshPaused, this), this._media = t;
|
|
109
|
-
}, e.prototype._internalStop = function() {
|
|
110
|
-
this._source && this._playing && (this._source.onended = null, this._source.pause());
|
|
111
|
-
}, e.prototype.stop = function() {
|
|
112
|
-
this._internalStop(), this._source && this.emit("stop");
|
|
113
|
-
}, Object.defineProperty(e.prototype, "speed", { get: function() {
|
|
114
|
-
return this._speed;
|
|
115
|
-
}, set: function(t) {
|
|
116
|
-
this._speed = t, this.refresh();
|
|
117
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "volume", { get: function() {
|
|
118
|
-
return this._volume;
|
|
119
|
-
}, set: function(t) {
|
|
120
|
-
this._volume = t, this.refresh();
|
|
121
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "loop", { get: function() {
|
|
122
|
-
return this._loop;
|
|
123
|
-
}, set: function(t) {
|
|
124
|
-
this._loop = t, this.refresh();
|
|
125
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "muted", { get: function() {
|
|
126
|
-
return this._muted;
|
|
127
|
-
}, set: function(t) {
|
|
128
|
-
this._muted = t, this.refresh();
|
|
129
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "filters", { get: function() {
|
|
130
|
-
return null;
|
|
131
|
-
}, set: function(t) {
|
|
132
|
-
}, enumerable: !1, configurable: !0 }), e.prototype.refresh = function() {
|
|
133
|
-
var t = this._media.context, s = this._media.parent;
|
|
134
|
-
this._source.loop = this._loop || s.loop;
|
|
135
|
-
var o = t.volume * (t.muted ? 0 : 1), i = s.volume * (s.muted ? 0 : 1), r = this._volume * (this._muted ? 0 : 1);
|
|
136
|
-
this._source.volume = r * o * i, this._source.playbackRate = this._speed * t.speed * s.speed;
|
|
137
|
-
}, e.prototype.refreshPaused = function() {
|
|
138
|
-
var t = this._media.context, s = this._media.parent, o = this._paused || s.paused || t.paused;
|
|
139
|
-
o !== this._pausedReal && (this._pausedReal = o, o ? (this._internalStop(), this.emit("paused")) : (this.emit("resumed"), this.play({ start: this._source.currentTime, end: this._end, volume: this._volume, speed: this._speed, loop: this._loop })), this.emit("pause", o));
|
|
140
|
-
}, e.prototype.play = function(t) {
|
|
141
|
-
var s = this, o = t.start, i = t.end, r = t.speed, u = t.loop, a = t.volume, l = t.muted;
|
|
142
|
-
this._speed = r, this._volume = a, this._loop = !!u, this._muted = l, this.refresh(), this.loop && i !== null && (this.loop = !1), this._start = o, this._end = i || this._duration, this._start = Math.max(0, this._start - e.PADDING), this._end = Math.min(this._end + e.PADDING, this._duration), this._source.onloadedmetadata = function() {
|
|
143
|
-
s._source && (s._source.currentTime = o, s._source.onloadedmetadata = null, s.emit("progress", o, s._duration), T.shared.add(s._onUpdate, s));
|
|
144
|
-
}, this._source.onended = this._onComplete.bind(this), this._source.play(), this.emit("start");
|
|
145
|
-
}, e.prototype._onUpdate = function() {
|
|
146
|
-
this.emit("progress", this.progress, this._duration), this._source.currentTime >= this._end && !this._source.loop && this._onComplete();
|
|
147
|
-
}, e.prototype._onComplete = function() {
|
|
148
|
-
T.shared.remove(this._onUpdate, this), this._internalStop(), this.emit("progress", 1, this._duration), this.emit("end", this);
|
|
149
|
-
}, e.prototype.destroy = function() {
|
|
150
|
-
T.shared.remove(this._onUpdate, this), this.removeAllListeners();
|
|
151
|
-
var t = this._source;
|
|
152
|
-
t && (t.onended = null, t.onplay = null, t.onpause = null, this._internalStop()), this._source = null, this._speed = 1, this._volume = 1, this._loop = !1, this._end = null, this._start = 0, this._duration = 0, this._playing = !1, this._pausedReal = !1, this._paused = !1, this._muted = !1, this._media && (this._media.context.off("refresh", this.refresh, this), this._media.context.off("refreshPaused", this.refreshPaused, this), this._media = null);
|
|
153
|
-
}, e.prototype.toString = function() {
|
|
154
|
-
return "[HTMLAudioInstance id=".concat(this.id, "]");
|
|
155
|
-
}, e.PADDING = 0.1, e;
|
|
156
|
-
}(R), ge = function(n) {
|
|
157
|
-
function e() {
|
|
158
|
-
return n !== null && n.apply(this, arguments) || this;
|
|
159
|
-
}
|
|
160
|
-
return b(e, n), e.prototype.init = function(t) {
|
|
161
|
-
this.parent = t, this._source = t.options.source || new Audio(), t.url && (this._source.src = t.url);
|
|
162
|
-
}, e.prototype.create = function() {
|
|
163
|
-
return new me(this);
|
|
164
|
-
}, Object.defineProperty(e.prototype, "isPlayable", { get: function() {
|
|
165
|
-
return !!this._source && this._source.readyState === 4;
|
|
166
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "duration", { get: function() {
|
|
167
|
-
return this._source.duration;
|
|
168
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "context", { get: function() {
|
|
169
|
-
return this.parent.context;
|
|
170
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "filters", { get: function() {
|
|
171
|
-
return null;
|
|
172
|
-
}, set: function(t) {
|
|
173
|
-
}, enumerable: !1, configurable: !0 }), e.prototype.destroy = function() {
|
|
174
|
-
this.removeAllListeners(), this.parent = null, this._source && (this._source.src = "", this._source.load(), this._source = null);
|
|
175
|
-
}, Object.defineProperty(e.prototype, "source", { get: function() {
|
|
176
|
-
return this._source;
|
|
177
|
-
}, enumerable: !1, configurable: !0 }), e.prototype.load = function(t) {
|
|
178
|
-
var s = this._source, o = this.parent;
|
|
179
|
-
if (s.readyState !== 4) if (o.url) {
|
|
180
|
-
s.src = o.url;
|
|
181
|
-
var i = function() {
|
|
182
|
-
a(), o.isLoaded = !0;
|
|
183
|
-
var h = o.autoPlayStart();
|
|
184
|
-
t && t(null, o, h);
|
|
185
|
-
}, r = function() {
|
|
186
|
-
a(), t && t(new Error("Sound loading has been aborted"));
|
|
187
|
-
}, u = function() {
|
|
188
|
-
a();
|
|
189
|
-
var h = "Failed to load audio element (code: ".concat(s.error.code, ")");
|
|
190
|
-
t && t(new Error(h));
|
|
191
|
-
}, a = function() {
|
|
192
|
-
s.removeEventListener("canplaythrough", i), s.removeEventListener("load", i), s.removeEventListener("abort", r), s.removeEventListener("error", u);
|
|
193
|
-
};
|
|
194
|
-
s.addEventListener("canplaythrough", i, !1), s.addEventListener("load", i, !1), s.addEventListener("abort", r, !1), s.addEventListener("error", u, !1), s.load();
|
|
195
|
-
} else t(new Error("sound.url or sound.source must be set"));
|
|
196
|
-
else {
|
|
197
|
-
o.isLoaded = !0;
|
|
198
|
-
var l = o.autoPlayStart();
|
|
199
|
-
t && setTimeout(function() {
|
|
200
|
-
t(null, o, l);
|
|
201
|
-
}, 0);
|
|
202
|
-
}
|
|
203
|
-
}, e;
|
|
204
|
-
}(R), be = function() {
|
|
205
|
-
function n(e, t) {
|
|
206
|
-
this.parent = e, Object.assign(this, t), this.duration = this.end - this.start;
|
|
207
|
-
}
|
|
208
|
-
return n.prototype.play = function(e) {
|
|
209
|
-
return this.parent.play({ complete: e, speed: this.speed || this.parent.speed, end: this.end, start: this.start, loop: this.loop });
|
|
210
|
-
}, n.prototype.destroy = function() {
|
|
211
|
-
this.parent = null;
|
|
212
|
-
}, n;
|
|
213
|
-
}(), v = function() {
|
|
214
|
-
function n() {
|
|
215
|
-
}
|
|
216
|
-
return n.setParamValue = function(e, t) {
|
|
217
|
-
if (e.setValueAtTime) {
|
|
218
|
-
var s = _().context;
|
|
219
|
-
e.setValueAtTime(t, s.audioContext.currentTime);
|
|
220
|
-
} else e.value = t;
|
|
221
|
-
return t;
|
|
222
|
-
}, n;
|
|
223
|
-
}(), ve = 0, Pe = function(n) {
|
|
224
|
-
function e(t) {
|
|
225
|
-
var s = n.call(this) || this;
|
|
226
|
-
return s.id = ve++, s._media = null, s._paused = !1, s._muted = !1, s._elapsed = 0, s.init(t), s;
|
|
227
|
-
}
|
|
228
|
-
return b(e, n), e.prototype.set = function(t, s) {
|
|
229
|
-
if (this[t] === void 0) throw new Error("Property with name ".concat(t, " does not exist."));
|
|
230
|
-
switch (t) {
|
|
231
|
-
case "speed":
|
|
232
|
-
this.speed = s;
|
|
233
|
-
break;
|
|
234
|
-
case "volume":
|
|
235
|
-
this.volume = s;
|
|
236
|
-
break;
|
|
237
|
-
case "muted":
|
|
238
|
-
this.muted = s;
|
|
239
|
-
break;
|
|
240
|
-
case "loop":
|
|
241
|
-
this.loop = s;
|
|
242
|
-
break;
|
|
243
|
-
case "paused":
|
|
244
|
-
this.paused = s;
|
|
245
|
-
}
|
|
246
|
-
return this;
|
|
247
|
-
}, e.prototype.stop = function() {
|
|
248
|
-
this._source && (this._internalStop(), this.emit("stop"));
|
|
249
|
-
}, Object.defineProperty(e.prototype, "speed", { get: function() {
|
|
250
|
-
return this._speed;
|
|
251
|
-
}, set: function(t) {
|
|
252
|
-
this._speed = t, this.refresh(), this._update(!0);
|
|
253
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "volume", { get: function() {
|
|
254
|
-
return this._volume;
|
|
255
|
-
}, set: function(t) {
|
|
256
|
-
this._volume = t, this.refresh();
|
|
257
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "muted", { get: function() {
|
|
258
|
-
return this._muted;
|
|
259
|
-
}, set: function(t) {
|
|
260
|
-
this._muted = t, this.refresh();
|
|
261
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "loop", { get: function() {
|
|
262
|
-
return this._loop;
|
|
263
|
-
}, set: function(t) {
|
|
264
|
-
this._loop = t, this.refresh();
|
|
265
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "filters", { get: function() {
|
|
266
|
-
return this._filters;
|
|
267
|
-
}, set: function(t) {
|
|
268
|
-
var s;
|
|
269
|
-
this._filters && ((s = this._filters) === null || s === void 0 || s.filter(function(o) {
|
|
270
|
-
return o;
|
|
271
|
-
}).forEach(function(o) {
|
|
272
|
-
return o.disconnect();
|
|
273
|
-
}), this._filters = null, this._source.connect(this._gain)), this._filters = t?.length ? t.slice(0) : null, this.refresh();
|
|
274
|
-
}, enumerable: !1, configurable: !0 }), e.prototype.refresh = function() {
|
|
275
|
-
if (this._source) {
|
|
276
|
-
var t = this._media.context, s = this._media.parent;
|
|
277
|
-
this._source.loop = this._loop || s.loop;
|
|
278
|
-
var o = t.volume * (t.muted ? 0 : 1), i = s.volume * (s.muted ? 0 : 1), r = this._volume * (this._muted ? 0 : 1);
|
|
279
|
-
v.setParamValue(this._gain.gain, r * i * o), v.setParamValue(this._source.playbackRate, this._speed * s.speed * t.speed), this.applyFilters();
|
|
280
|
-
}
|
|
281
|
-
}, e.prototype.applyFilters = function() {
|
|
282
|
-
var t;
|
|
283
|
-
if (!((t = this._filters) === null || t === void 0) && t.length) {
|
|
284
|
-
this._source.disconnect();
|
|
285
|
-
var s = this._source;
|
|
286
|
-
this._filters.forEach(function(o) {
|
|
287
|
-
s.connect(o.destination), s = o;
|
|
288
|
-
}), s.connect(this._gain);
|
|
289
|
-
}
|
|
290
|
-
}, e.prototype.refreshPaused = function() {
|
|
291
|
-
var t = this._media.context, s = this._media.parent, o = this._paused || s.paused || t.paused;
|
|
292
|
-
o !== this._pausedReal && (this._pausedReal = o, o ? (this._internalStop(), this.emit("paused")) : (this.emit("resumed"), this.play({ start: this._elapsed % this._duration, end: this._end, speed: this._speed, loop: this._loop, volume: this._volume })), this.emit("pause", o));
|
|
293
|
-
}, e.prototype.play = function(t) {
|
|
294
|
-
var s = t.start, o = t.end, i = t.speed, r = t.loop, u = t.volume, a = t.muted, l = t.filters;
|
|
295
|
-
this._paused = !1;
|
|
296
|
-
var h = this._media.nodes.cloneBufferSource(), m = h.source, y = h.gain;
|
|
297
|
-
this._source = m, this._gain = y, this._speed = i, this._volume = u, this._loop = !!r, this._muted = a, this._filters = l, this.refresh();
|
|
298
|
-
var g = this._source.buffer.duration;
|
|
299
|
-
this._duration = g, this._end = o, this._lastUpdate = this._now(), this._elapsed = s, this._source.onended = this._onComplete.bind(this), this._loop ? (this._source.loopEnd = o, this._source.loopStart = s, this._source.start(0, s)) : o ? this._source.start(0, s, o - s) : this._source.start(0, s), this.emit("start"), this._update(!0), this.enableTicker(!0);
|
|
300
|
-
}, e.prototype.enableTicker = function(t) {
|
|
301
|
-
T.shared.remove(this._updateListener, this), t && T.shared.add(this._updateListener, this);
|
|
302
|
-
}, Object.defineProperty(e.prototype, "progress", { get: function() {
|
|
303
|
-
return this._progress;
|
|
304
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "paused", { get: function() {
|
|
305
|
-
return this._paused;
|
|
306
|
-
}, set: function(t) {
|
|
307
|
-
this._paused = t, this.refreshPaused();
|
|
308
|
-
}, enumerable: !1, configurable: !0 }), e.prototype.destroy = function() {
|
|
309
|
-
var t;
|
|
310
|
-
this.removeAllListeners(), this._internalStop(), this._gain && (this._gain.disconnect(), this._gain = null), this._media && (this._media.context.events.off("refresh", this.refresh, this), this._media.context.events.off("refreshPaused", this.refreshPaused, this), this._media = null), (t = this._filters) === null || t === void 0 || t.forEach(function(s) {
|
|
311
|
-
return s.disconnect();
|
|
312
|
-
}), this._filters = null, this._end = null, this._speed = 1, this._volume = 1, this._loop = !1, this._elapsed = 0, this._duration = 0, this._paused = !1, this._muted = !1, this._pausedReal = !1;
|
|
313
|
-
}, e.prototype.toString = function() {
|
|
314
|
-
return "[WebAudioInstance id=".concat(this.id, "]");
|
|
315
|
-
}, e.prototype._now = function() {
|
|
316
|
-
return this._media.context.audioContext.currentTime;
|
|
317
|
-
}, e.prototype._updateListener = function() {
|
|
318
|
-
this._update();
|
|
319
|
-
}, e.prototype._update = function(t) {
|
|
320
|
-
if (t === void 0 && (t = !1), this._source) {
|
|
321
|
-
var s = this._now(), o = s - this._lastUpdate;
|
|
322
|
-
if (o > 0 || t) {
|
|
323
|
-
var i = this._source.playbackRate.value;
|
|
324
|
-
this._elapsed += o * i, this._lastUpdate = s;
|
|
325
|
-
var r = this._duration, u = void 0;
|
|
326
|
-
if (this._source.loopStart) {
|
|
327
|
-
var a = this._source.loopEnd - this._source.loopStart;
|
|
328
|
-
u = (this._source.loopStart + this._elapsed % a) / r;
|
|
329
|
-
} else u = this._elapsed % r / r;
|
|
330
|
-
this._progress = u, this.emit("progress", this._progress, r);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}, e.prototype.init = function(t) {
|
|
334
|
-
this._media = t, t.context.events.on("refresh", this.refresh, this), t.context.events.on("refreshPaused", this.refreshPaused, this);
|
|
335
|
-
}, e.prototype._internalStop = function() {
|
|
336
|
-
if (this._source) {
|
|
337
|
-
this.enableTicker(!1), this._source.onended = null, this._source.stop(0), this._source.disconnect();
|
|
338
|
-
try {
|
|
339
|
-
this._source.buffer = null;
|
|
340
|
-
} catch {
|
|
341
|
-
}
|
|
342
|
-
this._source = null;
|
|
343
|
-
}
|
|
344
|
-
}, e.prototype._onComplete = function() {
|
|
345
|
-
if (this._source) {
|
|
346
|
-
this.enableTicker(!1), this._source.onended = null, this._source.disconnect();
|
|
347
|
-
try {
|
|
348
|
-
this._source.buffer = null;
|
|
349
|
-
} catch {
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
this._source = null, this._progress = 1, this.emit("progress", 1, this._duration), this.emit("end", this);
|
|
353
|
-
}, e;
|
|
354
|
-
}(R), re = function() {
|
|
355
|
-
function n(e, t) {
|
|
356
|
-
this._output = t, this._input = e;
|
|
357
|
-
}
|
|
358
|
-
return Object.defineProperty(n.prototype, "destination", { get: function() {
|
|
359
|
-
return this._input;
|
|
360
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "filters", { get: function() {
|
|
361
|
-
return this._filters;
|
|
362
|
-
}, set: function(e) {
|
|
363
|
-
var t = this;
|
|
364
|
-
if (this._filters && (this._filters.forEach(function(o) {
|
|
365
|
-
o && o.disconnect();
|
|
366
|
-
}), this._filters = null, this._input.connect(this._output)), e && e.length) {
|
|
367
|
-
this._filters = e.slice(0), this._input.disconnect();
|
|
368
|
-
var s = null;
|
|
369
|
-
e.forEach(function(o) {
|
|
370
|
-
s === null ? t._input.connect(o.destination) : s.connect(o.destination), s = o;
|
|
371
|
-
}), s.connect(this._output);
|
|
372
|
-
}
|
|
373
|
-
}, enumerable: !1, configurable: !0 }), n.prototype.destroy = function() {
|
|
374
|
-
this.filters = null, this._input = null, this._output = null;
|
|
375
|
-
}, n;
|
|
376
|
-
}(), xe = function(n) {
|
|
377
|
-
function e(t) {
|
|
378
|
-
var s = this, o = t.audioContext, i = o.createBufferSource(), r = o.createGain(), u = o.createAnalyser();
|
|
379
|
-
return i.connect(u), u.connect(r), r.connect(t.destination), (s = n.call(this, u, r) || this).context = t, s.bufferSource = i, s.gain = r, s.analyser = u, s;
|
|
380
|
-
}
|
|
381
|
-
return b(e, n), Object.defineProperty(e.prototype, "script", { get: function() {
|
|
382
|
-
return this._script || (this._script = this.context.audioContext.createScriptProcessor(e.BUFFER_SIZE), this._script.connect(this.context.destination)), this._script;
|
|
383
|
-
}, enumerable: !1, configurable: !0 }), e.prototype.destroy = function() {
|
|
384
|
-
n.prototype.destroy.call(this), this.bufferSource.disconnect(), this._script && this._script.disconnect(), this.gain.disconnect(), this.analyser.disconnect(), this.bufferSource = null, this._script = null, this.gain = null, this.analyser = null, this.context = null;
|
|
385
|
-
}, e.prototype.cloneBufferSource = function() {
|
|
386
|
-
var t = this.bufferSource, s = this.context.audioContext.createBufferSource();
|
|
387
|
-
s.buffer = t.buffer, v.setParamValue(s.playbackRate, t.playbackRate.value), s.loop = t.loop;
|
|
388
|
-
var o = this.context.audioContext.createGain();
|
|
389
|
-
return s.connect(o), o.connect(this.destination), { source: s, gain: o };
|
|
390
|
-
}, Object.defineProperty(e.prototype, "bufferSize", { get: function() {
|
|
391
|
-
return this.script.bufferSize;
|
|
392
|
-
}, enumerable: !1, configurable: !0 }), e.BUFFER_SIZE = 0, e;
|
|
393
|
-
}(re), we = function() {
|
|
394
|
-
function n() {
|
|
395
|
-
}
|
|
396
|
-
return n.prototype.init = function(e) {
|
|
397
|
-
this.parent = e, this._nodes = new xe(this.context), this._source = this._nodes.bufferSource, this.source = e.options.source;
|
|
398
|
-
}, n.prototype.destroy = function() {
|
|
399
|
-
this.parent = null, this._nodes.destroy(), this._nodes = null;
|
|
400
|
-
try {
|
|
401
|
-
this._source.buffer = null;
|
|
402
|
-
} catch {
|
|
403
|
-
}
|
|
404
|
-
this._source = null, this.source = null;
|
|
405
|
-
}, n.prototype.create = function() {
|
|
406
|
-
return new Pe(this);
|
|
407
|
-
}, Object.defineProperty(n.prototype, "context", { get: function() {
|
|
408
|
-
return this.parent.context;
|
|
409
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "isPlayable", { get: function() {
|
|
410
|
-
return !!this._source && !!this._source.buffer;
|
|
411
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "filters", { get: function() {
|
|
412
|
-
return this._nodes.filters;
|
|
413
|
-
}, set: function(e) {
|
|
414
|
-
this._nodes.filters = e;
|
|
415
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "duration", { get: function() {
|
|
416
|
-
return this._source.buffer.duration;
|
|
417
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "buffer", { get: function() {
|
|
418
|
-
return this._source.buffer;
|
|
419
|
-
}, set: function(e) {
|
|
420
|
-
this._source.buffer = e;
|
|
421
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "nodes", { get: function() {
|
|
422
|
-
return this._nodes;
|
|
423
|
-
}, enumerable: !1, configurable: !0 }), n.prototype.load = function(e) {
|
|
424
|
-
this.source ? this._decode(this.source, e) : this.parent.url ? this._loadUrl(e) : e && e(new Error("sound.url or sound.source must be set"));
|
|
425
|
-
}, n.prototype._loadUrl = function(e) {
|
|
426
|
-
var t = this, s = new XMLHttpRequest(), o = this.parent.url;
|
|
427
|
-
s.open("GET", o, !0), s.responseType = "arraybuffer", s.onload = function() {
|
|
428
|
-
t.source = s.response, t._decode(s.response, e);
|
|
429
|
-
}, s.send();
|
|
430
|
-
}, n.prototype._decode = function(e, t) {
|
|
431
|
-
var s = this, o = function(i, r) {
|
|
432
|
-
if (i) t && t(i);
|
|
433
|
-
else {
|
|
434
|
-
s.parent.isLoaded = !0, s.buffer = r;
|
|
435
|
-
var u = s.parent.autoPlayStart();
|
|
436
|
-
t && t(null, s.parent, u);
|
|
437
|
-
}
|
|
438
|
-
};
|
|
439
|
-
e instanceof AudioBuffer ? o(null, e) : this.parent.context.decode(e, o);
|
|
440
|
-
}, n;
|
|
441
|
-
}(), N = function() {
|
|
442
|
-
function n(e, t) {
|
|
443
|
-
this.media = e, this.options = t, this._instances = [], this._sprites = {}, this.media.init(this);
|
|
444
|
-
var s = t.complete;
|
|
445
|
-
this._autoPlayOptions = s ? { complete: s } : null, this.isLoaded = !1, this.isPlaying = !1, this.autoPlay = t.autoPlay, this.singleInstance = t.singleInstance, this.preload = t.preload || this.autoPlay, this.url = t.url, this.speed = t.speed, this.volume = t.volume, this.loop = t.loop, t.sprites && this.addSprites(t.sprites), this.preload && this._preload(t.loaded);
|
|
446
|
-
}
|
|
447
|
-
return n.from = function(e) {
|
|
448
|
-
var t = {};
|
|
449
|
-
return typeof e == "string" ? t.url = e : e instanceof ArrayBuffer || e instanceof AudioBuffer || e instanceof HTMLAudioElement ? t.source = e : t = e, (t = V({ autoPlay: !1, singleInstance: !1, url: null, source: null, preload: !1, volume: 1, speed: 1, complete: null, loaded: null, loop: !1 }, t)).url && (t.url = oe(t.url)), Object.freeze(t), new n(_().useLegacy ? new ge() : new we(), t);
|
|
450
|
-
}, Object.defineProperty(n.prototype, "context", { get: function() {
|
|
451
|
-
return _().context;
|
|
452
|
-
}, enumerable: !1, configurable: !0 }), n.prototype.pause = function() {
|
|
453
|
-
return this.isPlaying = !1, this.paused = !0, this;
|
|
454
|
-
}, n.prototype.resume = function() {
|
|
455
|
-
return this.isPlaying = this._instances.length > 0, this.paused = !1, this;
|
|
456
|
-
}, Object.defineProperty(n.prototype, "paused", { get: function() {
|
|
457
|
-
return this._paused;
|
|
458
|
-
}, set: function(e) {
|
|
459
|
-
this._paused = e, this.refreshPaused();
|
|
460
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "speed", { get: function() {
|
|
461
|
-
return this._speed;
|
|
462
|
-
}, set: function(e) {
|
|
463
|
-
this._speed = e, this.refresh();
|
|
464
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "filters", { get: function() {
|
|
465
|
-
return this.media.filters;
|
|
466
|
-
}, set: function(e) {
|
|
467
|
-
this.media.filters = e;
|
|
468
|
-
}, enumerable: !1, configurable: !0 }), n.prototype.addSprites = function(e, t) {
|
|
469
|
-
if (typeof e == "object") {
|
|
470
|
-
var s = {};
|
|
471
|
-
for (var o in e) s[o] = this.addSprites(o, e[o]);
|
|
472
|
-
return s;
|
|
473
|
-
}
|
|
474
|
-
var i = new be(this, t);
|
|
475
|
-
return this._sprites[e] = i, i;
|
|
476
|
-
}, n.prototype.destroy = function() {
|
|
477
|
-
this._removeInstances(), this.removeSprites(), this.media.destroy(), this.media = null, this._sprites = null, this._instances = null;
|
|
478
|
-
}, n.prototype.removeSprites = function(e) {
|
|
479
|
-
if (e) {
|
|
480
|
-
var t = this._sprites[e];
|
|
481
|
-
t !== void 0 && (t.destroy(), delete this._sprites[e]);
|
|
482
|
-
} else for (var s in this._sprites) this.removeSprites(s);
|
|
483
|
-
return this;
|
|
484
|
-
}, Object.defineProperty(n.prototype, "isPlayable", { get: function() {
|
|
485
|
-
return this.isLoaded && this.media && this.media.isPlayable;
|
|
486
|
-
}, enumerable: !1, configurable: !0 }), n.prototype.stop = function() {
|
|
487
|
-
if (!this.isPlayable) return this.autoPlay = !1, this._autoPlayOptions = null, this;
|
|
488
|
-
this.isPlaying = !1;
|
|
489
|
-
for (var e = this._instances.length - 1; e >= 0; e--) this._instances[e].stop();
|
|
490
|
-
return this;
|
|
491
|
-
}, n.prototype.play = function(e, t) {
|
|
492
|
-
var s, o = this;
|
|
493
|
-
if (typeof e == "string" ? s = { sprite: r = e, loop: this.loop, complete: t } : typeof e == "function" ? (s = {}).complete = e : s = e, (s = V({ complete: null, loaded: null, sprite: null, end: null, start: 0, volume: 1, speed: 1, muted: !1, loop: !1 }, s || {})).sprite) {
|
|
494
|
-
var i = s.sprite, r = this._sprites[i];
|
|
495
|
-
s.start = r.start + (s.start || 0), s.end = r.end, s.speed = r.speed || 1, s.loop = r.loop || s.loop, delete s.sprite;
|
|
496
|
-
}
|
|
497
|
-
if (s.offset && (s.start = s.offset), !this.isLoaded) return new Promise(function(a, l) {
|
|
498
|
-
o.autoPlay = !0, o._autoPlayOptions = s, o._preload(function(h, m, y) {
|
|
499
|
-
h ? l(h) : (s.loaded && s.loaded(h, m, y), a(y));
|
|
500
|
-
});
|
|
501
|
-
});
|
|
502
|
-
(this.singleInstance || s.singleInstance) && this._removeInstances();
|
|
503
|
-
var u = this._createInstance();
|
|
504
|
-
return this._instances.push(u), this.isPlaying = !0, u.once("end", function() {
|
|
505
|
-
s.complete && s.complete(o), o._onComplete(u);
|
|
506
|
-
}), u.once("stop", function() {
|
|
507
|
-
o._onComplete(u);
|
|
508
|
-
}), u.play(s), u;
|
|
509
|
-
}, n.prototype.refresh = function() {
|
|
510
|
-
for (var e = this._instances.length, t = 0; t < e; t++) this._instances[t].refresh();
|
|
511
|
-
}, n.prototype.refreshPaused = function() {
|
|
512
|
-
for (var e = this._instances.length, t = 0; t < e; t++) this._instances[t].refreshPaused();
|
|
513
|
-
}, Object.defineProperty(n.prototype, "volume", { get: function() {
|
|
514
|
-
return this._volume;
|
|
515
|
-
}, set: function(e) {
|
|
516
|
-
this._volume = e, this.refresh();
|
|
517
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "muted", { get: function() {
|
|
518
|
-
return this._muted;
|
|
519
|
-
}, set: function(e) {
|
|
520
|
-
this._muted = e, this.refresh();
|
|
521
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "loop", { get: function() {
|
|
522
|
-
return this._loop;
|
|
523
|
-
}, set: function(e) {
|
|
524
|
-
this._loop = e, this.refresh();
|
|
525
|
-
}, enumerable: !1, configurable: !0 }), n.prototype._preload = function(e) {
|
|
526
|
-
this.media.load(e);
|
|
527
|
-
}, Object.defineProperty(n.prototype, "instances", { get: function() {
|
|
528
|
-
return this._instances;
|
|
529
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "sprites", { get: function() {
|
|
530
|
-
return this._sprites;
|
|
531
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "duration", { get: function() {
|
|
532
|
-
return this.media.duration;
|
|
533
|
-
}, enumerable: !1, configurable: !0 }), n.prototype.autoPlayStart = function() {
|
|
534
|
-
var e;
|
|
535
|
-
return this.autoPlay && (e = this.play(this._autoPlayOptions)), e;
|
|
536
|
-
}, n.prototype._removeInstances = function() {
|
|
537
|
-
for (var e = this._instances.length - 1; e >= 0; e--) this._poolInstance(this._instances[e]);
|
|
538
|
-
this._instances.length = 0;
|
|
539
|
-
}, n.prototype._onComplete = function(e) {
|
|
540
|
-
if (this._instances) {
|
|
541
|
-
var t = this._instances.indexOf(e);
|
|
542
|
-
t > -1 && this._instances.splice(t, 1), this.isPlaying = this._instances.length > 0;
|
|
543
|
-
}
|
|
544
|
-
this._poolInstance(e);
|
|
545
|
-
}, n.prototype._createInstance = function() {
|
|
546
|
-
if (n._pool.length > 0) {
|
|
547
|
-
var e = n._pool.pop();
|
|
548
|
-
return e.init(this.media), e;
|
|
549
|
-
}
|
|
550
|
-
return this.media.create();
|
|
551
|
-
}, n.prototype._poolInstance = function(e) {
|
|
552
|
-
e.destroy(), n._pool.indexOf(e) < 0 && n._pool.push(e);
|
|
553
|
-
}, n._pool = [], n;
|
|
554
|
-
}(), Oe = function(n) {
|
|
555
|
-
function e() {
|
|
556
|
-
var t = n !== null && n.apply(this, arguments) || this;
|
|
557
|
-
return t.speed = 1, t.muted = !1, t.volume = 1, t.paused = !1, t;
|
|
558
|
-
}
|
|
559
|
-
return b(e, n), e.prototype.refresh = function() {
|
|
560
|
-
this.emit("refresh");
|
|
561
|
-
}, e.prototype.refreshPaused = function() {
|
|
562
|
-
this.emit("refreshPaused");
|
|
563
|
-
}, Object.defineProperty(e.prototype, "filters", { get: function() {
|
|
564
|
-
return null;
|
|
565
|
-
}, set: function(t) {
|
|
566
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "audioContext", { get: function() {
|
|
567
|
-
return null;
|
|
568
|
-
}, enumerable: !1, configurable: !0 }), e.prototype.toggleMute = function() {
|
|
569
|
-
return this.muted = !this.muted, this.refresh(), this.muted;
|
|
570
|
-
}, e.prototype.togglePause = function() {
|
|
571
|
-
return this.paused = !this.paused, this.refreshPaused(), this.paused;
|
|
572
|
-
}, e.prototype.destroy = function() {
|
|
573
|
-
this.removeAllListeners();
|
|
574
|
-
}, e;
|
|
575
|
-
}(R), Y = function(n) {
|
|
576
|
-
function e() {
|
|
577
|
-
var t = n.call(this, null, null) || this;
|
|
578
|
-
t.autoPause = !0;
|
|
579
|
-
var s = window, o = new e.AudioContext(), i = o.createDynamicsCompressor(), r = o.createAnalyser();
|
|
580
|
-
return r.connect(i), i.connect(o.destination), t._input = r, t._output = o.destination, t._ctx = o, t._offlineCtx = new e.OfflineAudioContext(1, 2, s.OfflineAudioContext ? Math.max(8e3, Math.min(96e3, o.sampleRate)) : 44100), t.compressor = i, t.analyser = r, t.events = new R(), t.volume = 1, t.speed = 1, t.muted = !1, t.paused = !1, t._locked = o.state === "suspended" && ("ontouchstart" in globalThis || "onclick" in globalThis), t._locked && (t._unlock(), t._unlock = t._unlock.bind(t), document.addEventListener("mousedown", t._unlock, !0), document.addEventListener("touchstart", t._unlock, !0), document.addEventListener("touchend", t._unlock, !0)), t.onFocus = t.onFocus.bind(t), t.onBlur = t.onBlur.bind(t), globalThis.addEventListener("focus", t.onFocus), globalThis.addEventListener("blur", t.onBlur), t;
|
|
581
|
-
}
|
|
582
|
-
return b(e, n), e.prototype.onFocus = function() {
|
|
583
|
-
if (this.autoPause) {
|
|
584
|
-
var t = this._ctx.state;
|
|
585
|
-
t !== "suspended" && t !== "interrupted" && this._locked || (this.paused = this._pausedOnBlur, this.refreshPaused());
|
|
586
|
-
}
|
|
587
|
-
}, e.prototype.onBlur = function() {
|
|
588
|
-
this.autoPause && (this._locked || (this._pausedOnBlur = this._paused, this.paused = !0, this.refreshPaused()));
|
|
589
|
-
}, e.prototype._unlock = function() {
|
|
590
|
-
this._locked && (this.playEmptySound(), this._ctx.state === "running" && (document.removeEventListener("mousedown", this._unlock, !0), document.removeEventListener("touchend", this._unlock, !0), document.removeEventListener("touchstart", this._unlock, !0), this._locked = !1));
|
|
591
|
-
}, e.prototype.playEmptySound = function() {
|
|
592
|
-
var t = this._ctx.createBufferSource();
|
|
593
|
-
t.buffer = this._ctx.createBuffer(1, 1, 22050), t.connect(this._ctx.destination), t.start(0, 0, 0), t.context.state === "suspended" && t.context.resume();
|
|
594
|
-
}, Object.defineProperty(e, "AudioContext", { get: function() {
|
|
595
|
-
var t = window;
|
|
596
|
-
return t.AudioContext || t.webkitAudioContext || null;
|
|
597
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e, "OfflineAudioContext", { get: function() {
|
|
598
|
-
var t = window;
|
|
599
|
-
return t.OfflineAudioContext || t.webkitOfflineAudioContext || null;
|
|
600
|
-
}, enumerable: !1, configurable: !0 }), e.prototype.destroy = function() {
|
|
601
|
-
n.prototype.destroy.call(this);
|
|
602
|
-
var t = this._ctx;
|
|
603
|
-
t.close !== void 0 && t.close(), globalThis.removeEventListener("focus", this.onFocus), globalThis.removeEventListener("blur", this.onBlur), this.events.removeAllListeners(), this.analyser.disconnect(), this.compressor.disconnect(), this.analyser = null, this.compressor = null, this.events = null, this._offlineCtx = null, this._ctx = null;
|
|
604
|
-
}, Object.defineProperty(e.prototype, "audioContext", { get: function() {
|
|
605
|
-
return this._ctx;
|
|
606
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "offlineContext", { get: function() {
|
|
607
|
-
return this._offlineCtx;
|
|
608
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "paused", { get: function() {
|
|
609
|
-
return this._paused;
|
|
610
|
-
}, set: function(t) {
|
|
611
|
-
t && this._ctx.state === "running" ? this._ctx.suspend() : t || this._ctx.state !== "suspended" || this._ctx.resume(), this._paused = t;
|
|
612
|
-
}, enumerable: !1, configurable: !0 }), e.prototype.refresh = function() {
|
|
613
|
-
this.events.emit("refresh");
|
|
614
|
-
}, e.prototype.refreshPaused = function() {
|
|
615
|
-
this.events.emit("refreshPaused");
|
|
616
|
-
}, e.prototype.toggleMute = function() {
|
|
617
|
-
return this.muted = !this.muted, this.refresh(), this.muted;
|
|
618
|
-
}, e.prototype.togglePause = function() {
|
|
619
|
-
return this.paused = !this.paused, this.refreshPaused(), this._paused;
|
|
620
|
-
}, e.prototype.decode = function(t, s) {
|
|
621
|
-
var o = function(r) {
|
|
622
|
-
s(new Error(r?.message || "Unable to decode file"));
|
|
623
|
-
}, i = this._offlineCtx.decodeAudioData(t, function(r) {
|
|
624
|
-
s(null, r);
|
|
625
|
-
}, o);
|
|
626
|
-
i && i.catch(o);
|
|
627
|
-
}, e;
|
|
628
|
-
}(re), Se = function() {
|
|
629
|
-
function n() {
|
|
630
|
-
this.init();
|
|
631
|
-
}
|
|
632
|
-
return n.prototype.init = function() {
|
|
633
|
-
return this.supported && (this._webAudioContext = new Y()), this._htmlAudioContext = new Oe(), this._sounds = {}, this.useLegacy = !this.supported, this;
|
|
634
|
-
}, Object.defineProperty(n.prototype, "context", { get: function() {
|
|
635
|
-
return this._context;
|
|
636
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "filtersAll", { get: function() {
|
|
637
|
-
return this.useLegacy ? [] : this._context.filters;
|
|
638
|
-
}, set: function(e) {
|
|
639
|
-
this.useLegacy || (this._context.filters = e);
|
|
640
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "supported", { get: function() {
|
|
641
|
-
return Y.AudioContext !== null;
|
|
642
|
-
}, enumerable: !1, configurable: !0 }), n.prototype.add = function(e, t) {
|
|
643
|
-
if (typeof e == "object") {
|
|
644
|
-
var s = {};
|
|
645
|
-
for (var o in e) {
|
|
646
|
-
var i = this._getOptions(e[o], t);
|
|
647
|
-
s[o] = this.add(o, i);
|
|
648
|
-
}
|
|
649
|
-
return s;
|
|
650
|
-
}
|
|
651
|
-
if (t instanceof N) return this._sounds[e] = t, t;
|
|
652
|
-
var r = this._getOptions(t), u = N.from(r);
|
|
653
|
-
return this._sounds[e] = u, u;
|
|
654
|
-
}, n.prototype._getOptions = function(e, t) {
|
|
655
|
-
var s;
|
|
656
|
-
return s = typeof e == "string" ? { url: e } : e instanceof ArrayBuffer || e instanceof AudioBuffer || e instanceof HTMLAudioElement ? { source: e } : e, s = V(V({}, s), t || {});
|
|
657
|
-
}, Object.defineProperty(n.prototype, "useLegacy", { get: function() {
|
|
658
|
-
return this._useLegacy;
|
|
659
|
-
}, set: function(e) {
|
|
660
|
-
ie.setLegacy(e), this._useLegacy = e, this._context = !e && this.supported ? this._webAudioContext : this._htmlAudioContext;
|
|
661
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "disableAutoPause", { get: function() {
|
|
662
|
-
return !this._webAudioContext.autoPause;
|
|
663
|
-
}, set: function(e) {
|
|
664
|
-
this._webAudioContext.autoPause = !e;
|
|
665
|
-
}, enumerable: !1, configurable: !0 }), n.prototype.remove = function(e) {
|
|
666
|
-
return this.exists(e, !0), this._sounds[e].destroy(), delete this._sounds[e], this;
|
|
667
|
-
}, Object.defineProperty(n.prototype, "volumeAll", { get: function() {
|
|
668
|
-
return this._context.volume;
|
|
669
|
-
}, set: function(e) {
|
|
670
|
-
this._context.volume = e, this._context.refresh();
|
|
671
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(n.prototype, "speedAll", { get: function() {
|
|
672
|
-
return this._context.speed;
|
|
673
|
-
}, set: function(e) {
|
|
674
|
-
this._context.speed = e, this._context.refresh();
|
|
675
|
-
}, enumerable: !1, configurable: !0 }), n.prototype.togglePauseAll = function() {
|
|
676
|
-
return this._context.togglePause();
|
|
677
|
-
}, n.prototype.pauseAll = function() {
|
|
678
|
-
return this._context.paused = !0, this._context.refreshPaused(), this;
|
|
679
|
-
}, n.prototype.resumeAll = function() {
|
|
680
|
-
return this._context.paused = !1, this._context.refreshPaused(), this;
|
|
681
|
-
}, n.prototype.toggleMuteAll = function() {
|
|
682
|
-
return this._context.toggleMute();
|
|
683
|
-
}, n.prototype.muteAll = function() {
|
|
684
|
-
return this._context.muted = !0, this._context.refresh(), this;
|
|
685
|
-
}, n.prototype.unmuteAll = function() {
|
|
686
|
-
return this._context.muted = !1, this._context.refresh(), this;
|
|
687
|
-
}, n.prototype.removeAll = function() {
|
|
688
|
-
for (var e in this._sounds) this._sounds[e].destroy(), delete this._sounds[e];
|
|
689
|
-
return this;
|
|
690
|
-
}, n.prototype.stopAll = function() {
|
|
691
|
-
for (var e in this._sounds) this._sounds[e].stop();
|
|
692
|
-
return this;
|
|
693
|
-
}, n.prototype.exists = function(e, t) {
|
|
694
|
-
return !!this._sounds[e];
|
|
695
|
-
}, n.prototype.find = function(e) {
|
|
696
|
-
return this.exists(e, !0), this._sounds[e];
|
|
697
|
-
}, n.prototype.play = function(e, t) {
|
|
698
|
-
return this.find(e).play(t);
|
|
699
|
-
}, n.prototype.stop = function(e) {
|
|
700
|
-
return this.find(e).stop();
|
|
701
|
-
}, n.prototype.pause = function(e) {
|
|
702
|
-
return this.find(e).pause();
|
|
703
|
-
}, n.prototype.resume = function(e) {
|
|
704
|
-
return this.find(e).resume();
|
|
705
|
-
}, n.prototype.volume = function(e, t) {
|
|
706
|
-
var s = this.find(e);
|
|
707
|
-
return t !== void 0 && (s.volume = t), s.volume;
|
|
708
|
-
}, n.prototype.speed = function(e, t) {
|
|
709
|
-
var s = this.find(e);
|
|
710
|
-
return t !== void 0 && (s.speed = t), s.speed;
|
|
711
|
-
}, n.prototype.duration = function(e) {
|
|
712
|
-
return this.find(e).duration;
|
|
713
|
-
}, n.prototype.close = function() {
|
|
714
|
-
return this.removeAll(), this._sounds = null, this._webAudioContext && (this._webAudioContext.destroy(), this._webAudioContext = null), this._htmlAudioContext && (this._htmlAudioContext.destroy(), this._htmlAudioContext = null), this._context = null, this;
|
|
715
|
-
}, n;
|
|
716
|
-
}(), k = function() {
|
|
717
|
-
function n(e, t) {
|
|
718
|
-
this.init(e, t);
|
|
719
|
-
}
|
|
720
|
-
return n.prototype.init = function(e, t) {
|
|
721
|
-
this.destination = e, this.source = t || e;
|
|
722
|
-
}, n.prototype.connect = function(e) {
|
|
723
|
-
this.source.connect(e);
|
|
724
|
-
}, n.prototype.disconnect = function() {
|
|
725
|
-
this.source.disconnect();
|
|
726
|
-
}, n.prototype.destroy = function() {
|
|
727
|
-
this.disconnect(), this.destination = null, this.source = null;
|
|
728
|
-
}, n;
|
|
729
|
-
}(), B = { __proto__: null, EqualizerFilter: function(n) {
|
|
730
|
-
function e(t, s, o, i, r, u, a, l, h, m) {
|
|
731
|
-
t === void 0 && (t = 0), s === void 0 && (s = 0), o === void 0 && (o = 0), i === void 0 && (i = 0), r === void 0 && (r = 0), u === void 0 && (u = 0), a === void 0 && (a = 0), l === void 0 && (l = 0), h === void 0 && (h = 0), m === void 0 && (m = 0);
|
|
732
|
-
var y = this;
|
|
733
|
-
if (!_().useLegacy) {
|
|
734
|
-
var g = [{ f: e.F32, type: "lowshelf", gain: t }, { f: e.F64, type: "peaking", gain: s }, { f: e.F125, type: "peaking", gain: o }, { f: e.F250, type: "peaking", gain: i }, { f: e.F500, type: "peaking", gain: r }, { f: e.F1K, type: "peaking", gain: u }, { f: e.F2K, type: "peaking", gain: a }, { f: e.F4K, type: "peaking", gain: l }, { f: e.F8K, type: "peaking", gain: h }, { f: e.F16K, type: "highshelf", gain: m }].map(function($) {
|
|
735
|
-
var p = _().context.audioContext.createBiquadFilter();
|
|
736
|
-
return p.type = $.type, v.setParamValue(p.Q, 1), p.frequency.value = $.f, v.setParamValue(p.gain, $.gain), p;
|
|
737
|
-
});
|
|
738
|
-
(y = n.call(this, g[0], g[g.length - 1]) || this).bands = g, y.bandsMap = {};
|
|
739
|
-
for (var d = 0; d < y.bands.length; d++) {
|
|
740
|
-
var O = y.bands[d];
|
|
741
|
-
d > 0 && y.bands[d - 1].connect(O), y.bandsMap[O.frequency.value] = O;
|
|
742
|
-
}
|
|
743
|
-
return y;
|
|
744
|
-
}
|
|
745
|
-
y = n.call(this, null) || this;
|
|
746
|
-
}
|
|
747
|
-
return b(e, n), e.prototype.setGain = function(t, s) {
|
|
748
|
-
if (s === void 0 && (s = 0), !this.bandsMap[t]) throw new Error("No band found for frequency ".concat(t));
|
|
749
|
-
v.setParamValue(this.bandsMap[t].gain, s);
|
|
750
|
-
}, e.prototype.getGain = function(t) {
|
|
751
|
-
if (!this.bandsMap[t]) throw new Error("No band found for frequency ".concat(t));
|
|
752
|
-
return this.bandsMap[t].gain.value;
|
|
753
|
-
}, Object.defineProperty(e.prototype, "f32", { get: function() {
|
|
754
|
-
return this.getGain(e.F32);
|
|
755
|
-
}, set: function(t) {
|
|
756
|
-
this.setGain(e.F32, t);
|
|
757
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "f64", { get: function() {
|
|
758
|
-
return this.getGain(e.F64);
|
|
759
|
-
}, set: function(t) {
|
|
760
|
-
this.setGain(e.F64, t);
|
|
761
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "f125", { get: function() {
|
|
762
|
-
return this.getGain(e.F125);
|
|
763
|
-
}, set: function(t) {
|
|
764
|
-
this.setGain(e.F125, t);
|
|
765
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "f250", { get: function() {
|
|
766
|
-
return this.getGain(e.F250);
|
|
767
|
-
}, set: function(t) {
|
|
768
|
-
this.setGain(e.F250, t);
|
|
769
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "f500", { get: function() {
|
|
770
|
-
return this.getGain(e.F500);
|
|
771
|
-
}, set: function(t) {
|
|
772
|
-
this.setGain(e.F500, t);
|
|
773
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "f1k", { get: function() {
|
|
774
|
-
return this.getGain(e.F1K);
|
|
775
|
-
}, set: function(t) {
|
|
776
|
-
this.setGain(e.F1K, t);
|
|
777
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "f2k", { get: function() {
|
|
778
|
-
return this.getGain(e.F2K);
|
|
779
|
-
}, set: function(t) {
|
|
780
|
-
this.setGain(e.F2K, t);
|
|
781
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "f4k", { get: function() {
|
|
782
|
-
return this.getGain(e.F4K);
|
|
783
|
-
}, set: function(t) {
|
|
784
|
-
this.setGain(e.F4K, t);
|
|
785
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "f8k", { get: function() {
|
|
786
|
-
return this.getGain(e.F8K);
|
|
787
|
-
}, set: function(t) {
|
|
788
|
-
this.setGain(e.F8K, t);
|
|
789
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "f16k", { get: function() {
|
|
790
|
-
return this.getGain(e.F16K);
|
|
791
|
-
}, set: function(t) {
|
|
792
|
-
this.setGain(e.F16K, t);
|
|
793
|
-
}, enumerable: !1, configurable: !0 }), e.prototype.reset = function() {
|
|
794
|
-
this.bands.forEach(function(t) {
|
|
795
|
-
v.setParamValue(t.gain, 0);
|
|
796
|
-
});
|
|
797
|
-
}, e.prototype.destroy = function() {
|
|
798
|
-
this.bands.forEach(function(t) {
|
|
799
|
-
t.disconnect();
|
|
800
|
-
}), this.bands = null, this.bandsMap = null;
|
|
801
|
-
}, e.F32 = 32, e.F64 = 64, e.F125 = 125, e.F250 = 250, e.F500 = 500, e.F1K = 1e3, e.F2K = 2e3, e.F4K = 4e3, e.F8K = 8e3, e.F16K = 16e3, e;
|
|
802
|
-
}(k), DistortionFilter: function(n) {
|
|
803
|
-
function e(t) {
|
|
804
|
-
t === void 0 && (t = 0);
|
|
805
|
-
var s = this;
|
|
806
|
-
if (!_().useLegacy) {
|
|
807
|
-
var o = _().context.audioContext.createWaveShaper();
|
|
808
|
-
return (s = n.call(this, o) || this)._distortion = o, s.amount = t, s;
|
|
809
|
-
}
|
|
810
|
-
s = n.call(this, null) || this;
|
|
811
|
-
}
|
|
812
|
-
return b(e, n), Object.defineProperty(e.prototype, "amount", { get: function() {
|
|
813
|
-
return this._amount;
|
|
814
|
-
}, set: function(t) {
|
|
815
|
-
this._amount = t;
|
|
816
|
-
for (var s, o = 1e3 * t, i = 44100, r = new Float32Array(i), u = Math.PI / 180, a = 0; a < i; ++a) s = 2 * a / i - 1, r[a] = (3 + o) * s * 20 * u / (Math.PI + o * Math.abs(s));
|
|
817
|
-
this._distortion.curve = r, this._distortion.oversample = "4x";
|
|
818
|
-
}, enumerable: !1, configurable: !0 }), e.prototype.destroy = function() {
|
|
819
|
-
this._distortion = null, n.prototype.destroy.call(this);
|
|
820
|
-
}, e;
|
|
821
|
-
}(k), StereoFilter: function(n) {
|
|
822
|
-
function e(t) {
|
|
823
|
-
t === void 0 && (t = 0);
|
|
824
|
-
var s = this;
|
|
825
|
-
if (!_().useLegacy) {
|
|
826
|
-
var o, i, r, u = _().context.audioContext;
|
|
827
|
-
return u.createStereoPanner ? r = o = u.createStereoPanner() : ((i = u.createPanner()).panningModel = "equalpower", r = i), (s = n.call(this, r) || this)._stereo = o, s._panner = i, s.pan = t, s;
|
|
828
|
-
}
|
|
829
|
-
s = n.call(this, null) || this;
|
|
830
|
-
}
|
|
831
|
-
return b(e, n), Object.defineProperty(e.prototype, "pan", { get: function() {
|
|
832
|
-
return this._pan;
|
|
833
|
-
}, set: function(t) {
|
|
834
|
-
this._pan = t, this._stereo ? v.setParamValue(this._stereo.pan, t) : this._panner.setPosition(t, 0, 1 - Math.abs(t));
|
|
835
|
-
}, enumerable: !1, configurable: !0 }), e.prototype.destroy = function() {
|
|
836
|
-
n.prototype.destroy.call(this), this._stereo = null, this._panner = null;
|
|
837
|
-
}, e;
|
|
838
|
-
}(k), ReverbFilter: function(n) {
|
|
839
|
-
function e(t, s, o) {
|
|
840
|
-
t === void 0 && (t = 3), s === void 0 && (s = 2), o === void 0 && (o = !1);
|
|
841
|
-
var i = this;
|
|
842
|
-
if (!_().useLegacy) return (i = n.call(this, null) || this)._seconds = i._clamp(t, 1, 50), i._decay = i._clamp(s, 0, 100), i._reverse = o, i._rebuild(), i;
|
|
843
|
-
i = n.call(this, null) || this;
|
|
844
|
-
}
|
|
845
|
-
return b(e, n), e.prototype._clamp = function(t, s, o) {
|
|
846
|
-
return Math.min(o, Math.max(s, t));
|
|
847
|
-
}, Object.defineProperty(e.prototype, "seconds", { get: function() {
|
|
848
|
-
return this._seconds;
|
|
849
|
-
}, set: function(t) {
|
|
850
|
-
this._seconds = this._clamp(t, 1, 50), this._rebuild();
|
|
851
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "decay", { get: function() {
|
|
852
|
-
return this._decay;
|
|
853
|
-
}, set: function(t) {
|
|
854
|
-
this._decay = this._clamp(t, 0, 100), this._rebuild();
|
|
855
|
-
}, enumerable: !1, configurable: !0 }), Object.defineProperty(e.prototype, "reverse", { get: function() {
|
|
856
|
-
return this._reverse;
|
|
857
|
-
}, set: function(t) {
|
|
858
|
-
this._reverse = t, this._rebuild();
|
|
859
|
-
}, enumerable: !1, configurable: !0 }), e.prototype._rebuild = function() {
|
|
860
|
-
for (var t, s = _().context.audioContext, o = s.sampleRate, i = o * this._seconds, r = s.createBuffer(2, i, o), u = r.getChannelData(0), a = r.getChannelData(1), l = 0; l < i; l++) t = this._reverse ? i - l : l, u[l] = (2 * Math.random() - 1) * Math.pow(1 - t / i, this._decay), a[l] = (2 * Math.random() - 1) * Math.pow(1 - t / i, this._decay);
|
|
861
|
-
var h = _().context.audioContext.createConvolver();
|
|
862
|
-
h.buffer = r, this.init(h);
|
|
863
|
-
}, e;
|
|
864
|
-
}(k), MonoFilter: function(n) {
|
|
865
|
-
function e() {
|
|
866
|
-
var t = this;
|
|
867
|
-
if (!_().useLegacy) {
|
|
868
|
-
var s = _().context.audioContext, o = s.createChannelSplitter(), i = s.createChannelMerger();
|
|
869
|
-
return i.connect(o), (t = n.call(this, i, o) || this)._merger = i, t;
|
|
870
|
-
}
|
|
871
|
-
t = n.call(this, null) || this;
|
|
872
|
-
}
|
|
873
|
-
return b(e, n), e.prototype.destroy = function() {
|
|
874
|
-
this._merger.disconnect(), this._merger = null, n.prototype.destroy.call(this);
|
|
875
|
-
}, e;
|
|
876
|
-
}(k), StreamFilter: function(n) {
|
|
877
|
-
function e() {
|
|
878
|
-
var t = this;
|
|
879
|
-
if (!_().useLegacy) {
|
|
880
|
-
var s = _().context.audioContext, o = s.createMediaStreamDestination(), i = s.createMediaStreamSource(o.stream);
|
|
881
|
-
return (t = n.call(this, o, i) || this)._stream = o.stream, t;
|
|
882
|
-
}
|
|
883
|
-
t = n.call(this, null) || this;
|
|
884
|
-
}
|
|
885
|
-
return b(e, n), Object.defineProperty(e.prototype, "stream", { get: function() {
|
|
886
|
-
return this._stream;
|
|
887
|
-
}, enumerable: !1, configurable: !0 }), e.prototype.destroy = function() {
|
|
888
|
-
this._stream = null, n.prototype.destroy.call(this);
|
|
889
|
-
}, e;
|
|
890
|
-
}(k), TelephoneFilter: function(n) {
|
|
891
|
-
function e() {
|
|
892
|
-
if (!_().useLegacy) {
|
|
893
|
-
var t = _().context.audioContext, s = t.createBiquadFilter(), o = t.createBiquadFilter(), i = t.createBiquadFilter(), r = t.createBiquadFilter();
|
|
894
|
-
return s.type = "lowpass", v.setParamValue(s.frequency, 2e3), o.type = "lowpass", v.setParamValue(o.frequency, 2e3), i.type = "highpass", v.setParamValue(i.frequency, 500), r.type = "highpass", v.setParamValue(r.frequency, 500), s.connect(o), o.connect(i), i.connect(r), n.call(this, s, r) || this;
|
|
895
|
-
}
|
|
896
|
-
n.call(this, null);
|
|
897
|
-
}
|
|
898
|
-
return b(e, n), e;
|
|
899
|
-
}(k) }, Ae = { __proto__: null, supported: K }, z = function(n) {
|
|
900
|
-
return te = n, n;
|
|
901
|
-
}(new Se());
|
|
902
|
-
ae.add(ie);
|
|
903
|
-
class P {
|
|
904
|
-
constructor(e, t, s, o, i, r, u, a) {
|
|
905
|
-
this.fn = e, this.buf = t, this.start_ms = s, this.end_ms = o, this.ret_ms = i, this.volume = r, this.pan = u, this.snd = a, this.stt = a ? new G(this) : new Ee(this), this.#e = L.procID, a && this.addSnd(a);
|
|
906
|
-
}
|
|
907
|
-
static grp = new he();
|
|
908
|
-
static init() {
|
|
909
|
-
ee.addGrp(P.grp);
|
|
910
|
-
}
|
|
911
|
-
static #t = 1;
|
|
912
|
-
stt;
|
|
913
|
-
loop = !1;
|
|
914
|
-
#e;
|
|
915
|
-
get procID() {
|
|
916
|
-
return this.#e;
|
|
917
|
-
}
|
|
918
|
-
addSnd(e) {
|
|
919
|
-
switch (this.snd = e, this.loop = e.loop, this.stt.onLoad(this), this.pan !== 0 && (e.filters = [new B.StereoFilter(this.pan)]), this.setVol = (t) => {
|
|
920
|
-
e.volume = t;
|
|
921
|
-
}, this.tw = () => {
|
|
922
|
-
const t = new fe(e);
|
|
923
|
-
return P.grp.add(t), t;
|
|
924
|
-
}, this.onPlayEnd = () => {
|
|
925
|
-
this.stt.onPlayEnd(this.buf), this.#s();
|
|
926
|
-
}, this.stop = () => {
|
|
927
|
-
e.stop(), this.#s();
|
|
928
|
-
}, this.destroy = () => e.destroy(), !this.loop && pe.needClick2Play() && setTimeout(() => this.onPlayEnd(), (e.duration - this.start_ms - (this.end_ms <= 0 ? this.end_ms : this.end_ms === f.MAX_END_MS ? 0 : e.duration - this.end_ms)) * 1e3), this.buf) {
|
|
929
|
-
// セリフ再生中はBGM音量を絞る
|
|
930
|
-
case Q:
|
|
931
|
-
{
|
|
932
|
-
const t = Number(c.getVal("sys:sn.sound.BGM.vol_mul_talking") ?? 1);
|
|
933
|
-
if (t === 1) break;
|
|
934
|
-
P.#t = t;
|
|
935
|
-
const s = H[X];
|
|
936
|
-
s && s.setVol(this.volume * P.#t);
|
|
937
|
-
}
|
|
938
|
-
break;
|
|
939
|
-
case X:
|
|
940
|
-
e.volume = this.volume * P.#t;
|
|
941
|
-
break;
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
#s = () => {
|
|
945
|
-
if (this.#s = () => {
|
|
946
|
-
}, P.#t === 1 || this.buf !== Q) return;
|
|
947
|
-
P.#t = 1;
|
|
948
|
-
const e = H[X];
|
|
949
|
-
e && e.setVol(this.volume * P.#t);
|
|
950
|
-
};
|
|
951
|
-
setVol(e) {
|
|
952
|
-
}
|
|
953
|
-
tw() {
|
|
954
|
-
}
|
|
955
|
-
onPlayEnd() {
|
|
956
|
-
}
|
|
957
|
-
stop() {
|
|
958
|
-
}
|
|
959
|
-
destroy() {
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
let J, c, F, Z, H, U;
|
|
963
|
-
const X = "BGM", D = "SE", Q = "VOICE";
|
|
964
|
-
class f {
|
|
965
|
-
constructor(e, t, s) {
|
|
966
|
-
this.hArg = e, this.buf = t, this.fn = s;
|
|
967
|
-
const o = j(e, "start_ms", 0), i = j(e, "end_ms", f.MAX_END_MS), r = j(e, "ret_ms", 0), u = j(e, "pan", 0), a = j(e, "speed", 1);
|
|
968
|
-
if (o < 0) throw `[playse] start_ms:${String(o)} が負の値です`;
|
|
969
|
-
if (r < 0) throw `[playse] ret_ms:${String(r)} が負の値です`;
|
|
970
|
-
if (0 < i) {
|
|
971
|
-
if (i <= o) throw `[playse] start_ms:${String(o)} >= end_ms:${String(i)} は異常値です`;
|
|
972
|
-
if (i <= r) throw `[playse] ret_ms:${String(r)} >= end_ms:${String(i)} は異常値です`;
|
|
973
|
-
}
|
|
974
|
-
const l = "const.sn.sound." + t + ".";
|
|
975
|
-
c.setVal_Nochk("save", l + "fn", s);
|
|
976
|
-
const h = f.getVol(e, 1);
|
|
977
|
-
c.setVal_Nochk("save", l + "volume", h);
|
|
978
|
-
const m = h * Number(c.getVal("sys:" + l + "volume", 1, !0)), y = A(e, "loop", !1);
|
|
979
|
-
y ? (f.#t[t] = s, c.setVal_Nochk("save", "const.sn.loopPlaying", JSON.stringify(f.#t))) : f.delLoopPlay(t), c.setVal_Nochk("save", l + "start_ms", o), c.setVal_Nochk("save", l + "end_ms", i), c.setVal_Nochk("save", l + "ret_ms", r), c.setVal_Nochk("tmp", l + "playing", !0), c.flush();
|
|
980
|
-
const g = z.find(s);
|
|
981
|
-
this.#e = new P(
|
|
982
|
-
s,
|
|
983
|
-
t,
|
|
984
|
-
o,
|
|
985
|
-
i,
|
|
986
|
-
r,
|
|
987
|
-
m,
|
|
988
|
-
u,
|
|
989
|
-
g
|
|
990
|
-
);
|
|
991
|
-
const d = {
|
|
992
|
-
loop: y,
|
|
993
|
-
speed: a,
|
|
994
|
-
volume: m,
|
|
995
|
-
loaded: (p, w) => {
|
|
996
|
-
if (!this.#e.stt.isDestroy) {
|
|
997
|
-
if (p) {
|
|
998
|
-
F.errScript(`ロード失敗です SndBuf fn:${s} ${String(p)}`, !1);
|
|
999
|
-
return;
|
|
1000
|
-
}
|
|
1001
|
-
w && (this.#e.addSnd(w), u !== 0 && (w.filters = [new B.StereoFilter(u)]), e.fnc?.());
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
};
|
|
1005
|
-
let O = "";
|
|
1006
|
-
if (0 < o || i < f.MAX_END_MS) {
|
|
1007
|
-
O = `${s};${String(o)};${String(i)};${String(r)}`;
|
|
1008
|
-
const p = (d.sprites ??= {})[O] = {
|
|
1009
|
-
start: o / 1e3,
|
|
1010
|
-
end: i / 1e3
|
|
1011
|
-
};
|
|
1012
|
-
d.preload = !0;
|
|
1013
|
-
const w = d.loaded;
|
|
1014
|
-
d.loaded = (C, E) => {
|
|
1015
|
-
if (this.#e.stt.isDestroy) return;
|
|
1016
|
-
w(C, E);
|
|
1017
|
-
const I = E, M = I.duration;
|
|
1018
|
-
p.end < 0 && (p.end += M, I.removeSprites(O), I.addSprites(O, p)), p.end <= p.start && F.errScript(`[playse] end_ms:${String(i)}(${String(p.end * 1e3)}) >= start_ms:${String(o)} は異常値です`), p.end * 1e3 <= r && F.errScript(`[playse] end_ms:${String(i)}(${String(p.end * 1e3)}) <= ret_ms:${String(r)} は異常値です`), M <= p.start && F.errScript(`[playse] 音声ファイル再生時間:${String(M * 1e3)} <= start_ms:${String(o)} は異常値です`), i !== f.MAX_END_MS && M <= p.end && F.errScript(`[playse] 音声ファイル再生時間:${String(M * 1e3)} <= end_ms:${String(i)} は異常値です`), I.play(O, (ue) => d.complete?.(ue));
|
|
1019
|
-
};
|
|
1020
|
-
} else d.autoPlay = !0;
|
|
1021
|
-
if (y ? r !== 0 && (d.loop = !1, d.complete = (p) => {
|
|
1022
|
-
const w = p.duration, C = r / 1e3, E = i / 1e3;
|
|
1023
|
-
w <= C && F.errScript(`[playse] 音声ファイル再生時間:${String(w * 1e3)} <= ret_ms:${String(r)} は異常値です`), p.play({
|
|
1024
|
-
// 一周目はループなし、なのでキャッシュされてる
|
|
1025
|
-
...d,
|
|
1026
|
-
start: C,
|
|
1027
|
-
end: E < 0 ? E + w : E,
|
|
1028
|
-
// 負の値は末尾から
|
|
1029
|
-
// speed, // 重複
|
|
1030
|
-
loop: !0,
|
|
1031
|
-
// volume, // 重複
|
|
1032
|
-
//- muted?: boolean;
|
|
1033
|
-
filters: u !== 0 ? [new B.StereoFilter(u)] : []
|
|
1034
|
-
//- complete?: CompleteCallback;
|
|
1035
|
-
//- loaded?: LoadedCallback;
|
|
1036
|
-
//- singleInstance?: boolean;
|
|
1037
|
-
});
|
|
1038
|
-
}) : d.complete = () => {
|
|
1039
|
-
W(this.#e, t), this.#e.onPlayEnd();
|
|
1040
|
-
}, this.#s(), g) {
|
|
1041
|
-
if (g.volume = m, O) this.#n(s, d);
|
|
1042
|
-
else if (g.isPlayable) {
|
|
1043
|
-
const p = g.options.source;
|
|
1044
|
-
!(p instanceof ArrayBuffer) || p.byteLength === 0 ? g.play(d) : this.#e.addSnd(N.from({
|
|
1045
|
-
...d,
|
|
1046
|
-
url: g.options.url,
|
|
1047
|
-
source: p
|
|
1048
|
-
}));
|
|
1049
|
-
}
|
|
1050
|
-
u !== 0 && (g.filters = [new B.StereoFilter(u)]), this.needLoad = !1;
|
|
1051
|
-
return;
|
|
1052
|
-
}
|
|
1053
|
-
if (this.needLoad = A(e, "join", !0)) {
|
|
1054
|
-
const p = this.#e.procID + `loaded buf:${t} fn:${s}`;
|
|
1055
|
-
L.beginProc(p);
|
|
1056
|
-
const w = d.loaded;
|
|
1057
|
-
d.loaded = (C, E) => {
|
|
1058
|
-
w(C, E), L.endProc(p);
|
|
1059
|
-
};
|
|
1060
|
-
}
|
|
1061
|
-
this.#n(s, d);
|
|
1062
|
-
}
|
|
1063
|
-
static #t = {};
|
|
1064
|
-
static init(e, t, s, o, i) {
|
|
1065
|
-
f.#t = {}, J = e, c = t, F = s, Z = o, H = i, P.init();
|
|
1066
|
-
}
|
|
1067
|
-
static setEvtMng(e) {
|
|
1068
|
-
U = e;
|
|
1069
|
-
}
|
|
1070
|
-
static delLoopPlay(e) {
|
|
1071
|
-
delete f.#t[e];
|
|
1072
|
-
const t = "const.sn.sound." + e + ".";
|
|
1073
|
-
c.setVal_Nochk("save", t + "fn", ""), c.setVal_Nochk("save", "const.sn.loopPlaying", JSON.stringify(f.#t)), c.flush();
|
|
1074
|
-
}
|
|
1075
|
-
static getVol(e, t) {
|
|
1076
|
-
const s = j(e, "volume", t);
|
|
1077
|
-
return s < 0 ? 0 : s > 1 ? 1 : s;
|
|
1078
|
-
}
|
|
1079
|
-
static xchgbuf({ buf: e = D, buf2: t = D }) {
|
|
1080
|
-
if (e === t) throw `[xchgbuf] buf:${e} が同じ値です`;
|
|
1081
|
-
const s = "const.sn.sound." + e + ".", o = Number(c.getVal("save:" + s + "volume")), i = String(c.getVal("save:" + s + "fn")), r = "const.sn.sound." + t + ".", u = Number(c.getVal("save:" + r + "volume")), a = String(c.getVal("save:" + r + "fn"));
|
|
1082
|
-
c.setVal_Nochk("save", s + "volume", u), c.setVal_Nochk("save", r + "volume", o), c.setVal_Nochk("save", s + "fn", a), c.setVal_Nochk("save", r + "fn", i), e in f.#t != t in f.#t && (e in f.#t ? (delete f.#t[e], f.#t[t] = i) : (delete f.#t[t], f.#t[e] = a), c.setVal_Nochk("save", "const.sn.loopPlaying", JSON.stringify(f.#t))), c.flush();
|
|
1083
|
-
}
|
|
1084
|
-
static MAX_END_MS = 999e3;
|
|
1085
|
-
#e;
|
|
1086
|
-
needLoad;
|
|
1087
|
-
#s = () => {
|
|
1088
|
-
z.volumeAll = Number(c.getVal("sys:sn.sound.global_volume", 1)), this.#s = () => {
|
|
1089
|
-
};
|
|
1090
|
-
};
|
|
1091
|
-
#n(e, t) {
|
|
1092
|
-
const s = J.searchPath(e, le.SOUND);
|
|
1093
|
-
if (!s.endsWith(".bin")) {
|
|
1094
|
-
t.url = s, N.from(t);
|
|
1095
|
-
return;
|
|
1096
|
-
}
|
|
1097
|
-
new ce().add({ name: e, url: s, xhrType: S.XHR_RESPONSE_TYPE.BUFFER }).use((o, i) => {
|
|
1098
|
-
Z.decAB(o.data).then((r) => {
|
|
1099
|
-
o.data = r;
|
|
1100
|
-
}).catch((r) => F.errScript(`Sound ロード失敗ですc fn:${o.name} ${String(r)}`, !1)).finally(() => i());
|
|
1101
|
-
}).load((o, i) => {
|
|
1102
|
-
t.source = i[e]?.data, N.from(t);
|
|
1103
|
-
});
|
|
1104
|
-
}
|
|
1105
|
-
setVol(e) {
|
|
1106
|
-
this.#e.setVol(e);
|
|
1107
|
-
}
|
|
1108
|
-
ws = (e) => this.#e.stt.ws(this.#e, e);
|
|
1109
|
-
stopse({ buf: e = D }) {
|
|
1110
|
-
W(this.#e, e), this.#e.stt.stopse(this.#e);
|
|
1111
|
-
}
|
|
1112
|
-
fade = (e) => this.#e.stt.fade(this.#e, e);
|
|
1113
|
-
wf = (e) => this.#e.stt.wf(this.#e, e);
|
|
1114
|
-
stopfadese = (e) => this.#e.stt.stopfadese(this.#e, e);
|
|
1115
|
-
}
|
|
1116
|
-
function W({ loop: n }, e) {
|
|
1117
|
-
if (n) {
|
|
1118
|
-
f.delLoopPlay(e);
|
|
1119
|
-
return;
|
|
1120
|
-
}
|
|
1121
|
-
const t = "const.sn.sound." + e + ".";
|
|
1122
|
-
c.setVal_Nochk("tmp", t + "playing", !1), c.flush();
|
|
1123
|
-
}
|
|
1124
|
-
class Ee {
|
|
1125
|
-
constructor(e) {
|
|
1126
|
-
this.si = e;
|
|
1127
|
-
}
|
|
1128
|
-
onLoad(e) {
|
|
1129
|
-
e.stt = new G(e);
|
|
1130
|
-
}
|
|
1131
|
-
stopse(e) {
|
|
1132
|
-
e.stt = new x(e, !1);
|
|
1133
|
-
}
|
|
1134
|
-
ws = () => !1;
|
|
1135
|
-
onPlayEnd() {
|
|
1136
|
-
this.si.stt = new x(this.si, !1);
|
|
1137
|
-
}
|
|
1138
|
-
// ok
|
|
1139
|
-
fade() {
|
|
1140
|
-
}
|
|
1141
|
-
// ok
|
|
1142
|
-
wf = () => !1;
|
|
1143
|
-
// ok
|
|
1144
|
-
compFade() {
|
|
1145
|
-
}
|
|
1146
|
-
// ok
|
|
1147
|
-
stopfadese() {
|
|
1148
|
-
}
|
|
1149
|
-
// ok
|
|
1150
|
-
isDestroy = !1;
|
|
1151
|
-
}
|
|
1152
|
-
class G {
|
|
1153
|
-
constructor(e) {
|
|
1154
|
-
this.si = e;
|
|
1155
|
-
}
|
|
1156
|
-
onLoad() {
|
|
1157
|
-
}
|
|
1158
|
-
// ok
|
|
1159
|
-
stopse(e) {
|
|
1160
|
-
e.stt = new x(e);
|
|
1161
|
-
}
|
|
1162
|
-
ws(e, t) {
|
|
1163
|
-
if (e.loop) return !1;
|
|
1164
|
-
e.stt = new Fe(e);
|
|
1165
|
-
const s = A(t, "canskip", !1), o = A(t, "stop", !0);
|
|
1166
|
-
if (s && U.isSkipping)
|
|
1167
|
-
return o ? e.stt.stopse(e) : e.stt.onPlayEnd = () => {
|
|
1168
|
-
}, !1;
|
|
1169
|
-
const { buf: i = D } = t, r = () => {
|
|
1170
|
-
W(e, i), e.onPlayEnd(), o ? e.stt.stopse(e) : e.stt.onPlayEnd = () => {
|
|
1171
|
-
};
|
|
1172
|
-
};
|
|
1173
|
-
return L.beginProc(e.procID + "ws", r, !0, s ? r : void 0), !0;
|
|
1174
|
-
}
|
|
1175
|
-
onPlayEnd() {
|
|
1176
|
-
this.si.stt = new x(this.si, !1);
|
|
1177
|
-
}
|
|
1178
|
-
// ok
|
|
1179
|
-
fade(e, t) {
|
|
1180
|
-
const { buf: s = D } = t, i = "const.sn.sound." + s + "." + "volume", r = f.getVol(t, NaN);
|
|
1181
|
-
c.setVal_Nochk("save", i, r);
|
|
1182
|
-
const u = r * Number(c.getVal("sys:" + i, 1)), a = A(t, "stop", r === 0);
|
|
1183
|
-
a && f.delLoopPlay(s), c.flush();
|
|
1184
|
-
const l = j(t, "time", NaN), h = j(t, "delay", 0);
|
|
1185
|
-
if (l === 0 && h === 0 || U.isSkipping) {
|
|
1186
|
-
e.setVol(u), e.stt = a ? new x(e) : new G(e);
|
|
1187
|
-
return;
|
|
1188
|
-
}
|
|
1189
|
-
if (!e.snd) return;
|
|
1190
|
-
const m = e.tw();
|
|
1191
|
-
m && (ee.setTwProp(m, t).to({ volume: u }, l).onUpdate((y) => {
|
|
1192
|
-
if (e.snd?.isPlaying) {
|
|
1193
|
-
e.snd.volume = y.volume;
|
|
1194
|
-
return;
|
|
1195
|
-
}
|
|
1196
|
-
m.stop(), m.onComplete();
|
|
1197
|
-
}).onComplete(() => {
|
|
1198
|
-
P.grp.remove(m), e.stt.compFade(s), e.stt = a ? new x(e) : new G(e);
|
|
1199
|
-
}).start(), e.stt = new je(m, e));
|
|
1200
|
-
}
|
|
1201
|
-
wf = () => !1;
|
|
1202
|
-
// ok
|
|
1203
|
-
compFade() {
|
|
1204
|
-
}
|
|
1205
|
-
// ok
|
|
1206
|
-
stopfadese() {
|
|
1207
|
-
}
|
|
1208
|
-
// ok
|
|
1209
|
-
isDestroy = !1;
|
|
1210
|
-
}
|
|
1211
|
-
class Fe {
|
|
1212
|
-
constructor(e) {
|
|
1213
|
-
this.si = e;
|
|
1214
|
-
}
|
|
1215
|
-
onLoad() {
|
|
1216
|
-
}
|
|
1217
|
-
// ok
|
|
1218
|
-
stopse(e) {
|
|
1219
|
-
e.stt = new x(e);
|
|
1220
|
-
}
|
|
1221
|
-
ws = () => !1;
|
|
1222
|
-
// ok
|
|
1223
|
-
onPlayEnd() {
|
|
1224
|
-
this.si.stt = new x(this.si, !1), L.notifyEndProc(this.si.procID + "ws");
|
|
1225
|
-
}
|
|
1226
|
-
fade() {
|
|
1227
|
-
}
|
|
1228
|
-
// ok
|
|
1229
|
-
wf = () => !1;
|
|
1230
|
-
// ok
|
|
1231
|
-
compFade() {
|
|
1232
|
-
}
|
|
1233
|
-
// ok
|
|
1234
|
-
stopfadese() {
|
|
1235
|
-
}
|
|
1236
|
-
// ok
|
|
1237
|
-
isDestroy = !1;
|
|
1238
|
-
}
|
|
1239
|
-
class je {
|
|
1240
|
-
constructor(e, t) {
|
|
1241
|
-
this.tw = e, this.si = t;
|
|
1242
|
-
}
|
|
1243
|
-
onLoad() {
|
|
1244
|
-
}
|
|
1245
|
-
// ok
|
|
1246
|
-
stopse(e) {
|
|
1247
|
-
this.stopfadese(), e.stt = new x(e);
|
|
1248
|
-
}
|
|
1249
|
-
// 順番厳守
|
|
1250
|
-
ws = () => !1;
|
|
1251
|
-
// ok ?
|
|
1252
|
-
onPlayEnd() {
|
|
1253
|
-
this.stopfadese(), this.si.stt = new x(this.si, !1);
|
|
1254
|
-
}
|
|
1255
|
-
// ok
|
|
1256
|
-
fade() {
|
|
1257
|
-
}
|
|
1258
|
-
// ok
|
|
1259
|
-
wf(e, t) {
|
|
1260
|
-
e.stt = new ke(e);
|
|
1261
|
-
const s = A(t, "canskip", !1);
|
|
1262
|
-
if (s && U.isSkipping)
|
|
1263
|
-
return this.stopfadese(), !1;
|
|
1264
|
-
const o = () => this.stopfadese();
|
|
1265
|
-
return L.beginProc(e.procID + "wf", o, !0, s ? o : void 0), !0;
|
|
1266
|
-
}
|
|
1267
|
-
compFade() {
|
|
1268
|
-
}
|
|
1269
|
-
// ok
|
|
1270
|
-
stopfadese = () => this.si.stop();
|
|
1271
|
-
isDestroy = !1;
|
|
1272
|
-
}
|
|
1273
|
-
class ke {
|
|
1274
|
-
constructor(e) {
|
|
1275
|
-
this.si = e;
|
|
1276
|
-
}
|
|
1277
|
-
onLoad() {
|
|
1278
|
-
}
|
|
1279
|
-
// ok
|
|
1280
|
-
stopse(e) {
|
|
1281
|
-
this.stopfadese(), e.stt = new x(e);
|
|
1282
|
-
}
|
|
1283
|
-
ws = () => !1;
|
|
1284
|
-
// ok
|
|
1285
|
-
onPlayEnd() {
|
|
1286
|
-
this.stopfadese(), this.si.stt = new x(this.si, !1);
|
|
1287
|
-
}
|
|
1288
|
-
// ok
|
|
1289
|
-
fade() {
|
|
1290
|
-
}
|
|
1291
|
-
// ok
|
|
1292
|
-
wf = () => !1;
|
|
1293
|
-
// ok
|
|
1294
|
-
compFade() {
|
|
1295
|
-
L.notifyEndProc(this.si.procID + "wf");
|
|
1296
|
-
}
|
|
1297
|
-
stopfadese = () => this.si.stop();
|
|
1298
|
-
isDestroy = !1;
|
|
868
|
+
function getVol(e, r) {
|
|
869
|
+
let i = argChk_Num(e, "volume", r);
|
|
870
|
+
return i < 0 ? 0 : i > 1 ? 1 : i;
|
|
1299
871
|
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
}
|
|
1305
|
-
onLoad() {
|
|
1306
|
-
}
|
|
1307
|
-
// ok
|
|
1308
|
-
stopse() {
|
|
1309
|
-
}
|
|
1310
|
-
// ok
|
|
1311
|
-
ws = () => !1;
|
|
1312
|
-
// ok
|
|
1313
|
-
onPlayEnd() {
|
|
1314
|
-
}
|
|
1315
|
-
// ok
|
|
1316
|
-
fade() {
|
|
1317
|
-
}
|
|
1318
|
-
// ok
|
|
1319
|
-
wf = () => !1;
|
|
1320
|
-
// ok
|
|
1321
|
-
compFade() {
|
|
1322
|
-
}
|
|
1323
|
-
// ok
|
|
1324
|
-
stopfadese() {
|
|
1325
|
-
}
|
|
1326
|
-
// ok
|
|
1327
|
-
isDestroy = !0;
|
|
872
|
+
function xchgbuf({ buf: e = "SE", buf2: n = "SE" }) {
|
|
873
|
+
if (e === n) throw `[xchgbuf] buf:${e} が同じ値です`;
|
|
874
|
+
let r = "const.sn.sound." + e + ".", i = Number(val.getVal("save:" + r + "volume")), a = String(val.getVal("save:" + r + "fn")), o = "const.sn.sound." + n + ".", s = Number(val.getVal("save:" + o + "volume")), c = String(val.getVal("save:" + o + "fn"));
|
|
875
|
+
val.setVal_Nochk("save", r + "volume", s), val.setVal_Nochk("save", o + "volume", i), val.setVal_Nochk("save", r + "fn", c), val.setVal_Nochk("save", o + "fn", a), e in hLP != n in hLP && (e in hLP ? (delete hLP[e], hLP[n] = a) : (delete hLP[n], hLP[e] = c), val.setVal_Nochk("save", "const.sn.loopPlaying", JSON.stringify(hLP))), val.flush();
|
|
1328
876
|
}
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
877
|
+
var SndBuf = class e {
|
|
878
|
+
static #e;
|
|
879
|
+
static #t;
|
|
880
|
+
static init(n, r, i, a, o) {
|
|
881
|
+
hLP = {}, e.#e = n, val = r, errScript = (e, n) => i.errScript(e, n), e.#t = a, getSndBuf = o;
|
|
882
|
+
}
|
|
883
|
+
static setEvtMng(e) {
|
|
884
|
+
evtMng = e;
|
|
885
|
+
}
|
|
886
|
+
static generate = (i, a, s) => new e(i, a, i.fn ?? "", Reading.procID, s, argChk_Num(i, "start_ms", 0), argChk_Num(i, "end_ms", MAX_END_MS), argChk_Num(i, "ret_ms", 0), argChk_Boolean(i, "loop", !1), argChk_Num(i, "pan", 0));
|
|
887
|
+
stt = new StLoading(this);
|
|
888
|
+
constructor(r, i, s, c, l, u, g, x, S, C) {
|
|
889
|
+
if (this.hArg = r, this.buf = i, this.fn = s, this.procID = c, this.join = l, this.start_ms = u, this.end_ms = g, this.ret_ms = x, this.loop = S, this.pan = C, !s) throw `fnは必須です buf:${i}`;
|
|
890
|
+
if (u < 0) throw `[${r[":タグ名"] ?? ""}] start_ms:${String(u)} が負の値です`;
|
|
891
|
+
if (x < 0) throw `[${r[":タグ名"] ?? ""}] ret_ms:${String(x)} が負の値です`;
|
|
892
|
+
if (0 < g) {
|
|
893
|
+
if (g <= u) throw `[${r[":タグ名"] ?? ""}] start_ms:${String(u)} >= end_ms:${String(g)} は異常値です`;
|
|
894
|
+
if (g <= x) throw `[${r[":タグ名"] ?? ""}] ret_ms:${String(x)} >= end_ms:${String(g)} は異常値です`;
|
|
895
|
+
}
|
|
896
|
+
let w = "const.sn.sound." + i + ".";
|
|
897
|
+
val.setVal_Nochk("save", w + "fn", s);
|
|
898
|
+
let T = getVol(r, 1);
|
|
899
|
+
val.setVal_Nochk("save", w + "volume", T);
|
|
900
|
+
let E = T * Number(val.getVal("sys:" + w + "volume", 1, !0));
|
|
901
|
+
switch (i) {
|
|
902
|
+
case BUF_VOICE:
|
|
903
|
+
{
|
|
904
|
+
if ((vol_mul_talking = Number(val.getVal("sys:sn.sound.BGM.vol_mul_talking") ?? 1)) === 1) break;
|
|
905
|
+
let e = getSndBuf("BGM"), n = "const.sn.sound.BGM.volume";
|
|
906
|
+
e && (e.volume = Number(val.getVal("save:" + n, 1)) * Number(val.getVal("sys:" + n, 1, !0)) * vol_mul_talking);
|
|
907
|
+
}
|
|
908
|
+
break;
|
|
909
|
+
case "BGM":
|
|
910
|
+
E *= vol_mul_talking;
|
|
911
|
+
break;
|
|
912
|
+
}
|
|
913
|
+
S ? (hLP[i] = s, val.setVal_Nochk("save", "const.sn.loopPlaying", JSON.stringify(hLP))) : delLoopPlay(i), val.setVal_Nochk("save", w + "start_ms", u), val.setVal_Nochk("save", w + "end_ms", g), val.setVal_Nochk("save", w + "ret_ms", x), val.setVal_Nochk("tmp", w + "playing", !0), val.flush();
|
|
914
|
+
let D = () => {};
|
|
915
|
+
if (l) {
|
|
916
|
+
let e = c + ` loaded buf:${i} fn:${s}`;
|
|
917
|
+
Reading.beginProc(e), D = () => Reading.endProc(e);
|
|
918
|
+
}
|
|
919
|
+
let O = e.#e.searchPath(s, SEARCH_PATH_ARG_EXT.SOUND), k = {
|
|
920
|
+
src: O,
|
|
921
|
+
volume: E,
|
|
922
|
+
html5: !1,
|
|
923
|
+
loop: S,
|
|
924
|
+
autoplay: !0,
|
|
925
|
+
rate: argChk_Num(r, "speed", 1),
|
|
926
|
+
onload: () => {
|
|
927
|
+
D(), r.fnc?.(), this.stt = new StPlaying(this, this.#n);
|
|
928
|
+
},
|
|
929
|
+
onloaderror: (e, n) => {
|
|
930
|
+
D(), errScript(`SndBuf ロード失敗です fn:${s} ${String(n)}`, !1);
|
|
931
|
+
}
|
|
932
|
+
};
|
|
933
|
+
if (S || (k.onend = () => this.stt.onend()), u > 0 || g !== MAX_END_MS || x > 0) {
|
|
934
|
+
k.autoplay = !1;
|
|
935
|
+
let { 一周目: e, 二周目: n } = k.sprite = {
|
|
936
|
+
一周目: [u, g - u],
|
|
937
|
+
二周目: [
|
|
938
|
+
x,
|
|
939
|
+
g - x,
|
|
940
|
+
!0
|
|
941
|
+
]
|
|
942
|
+
}, i = k.onload;
|
|
943
|
+
if (k.onload = (a) => {
|
|
944
|
+
i(a);
|
|
945
|
+
let o = this.#n.duration() * 1e3;
|
|
946
|
+
o <= u && errScript(`[${r[":タグ名"] ?? ""}] 音声ファイル再生時間:${String(o)} <= ret_ms:${String(x)} は異常値です`), g < 0 ? (e[1] = o + g - u, n[1] = o + g - x) : g === MAX_END_MS && (e[1] = o - u, n[1] = o - x);
|
|
947
|
+
let s = e[1] + u;
|
|
948
|
+
s <= u && errScript(`[${r[":タグ名"] ?? ""}] end_ms:${String(g)}(${String(s)}) >= start_ms:${String(u)} は異常値です`), s <= x && errScript(`[${r[":タグ名"] ?? ""}] end_ms:${String(g)}(${String(s)}) <= ret_ms:${String(x)} は異常値です`), o <= u && errScript(`[${r[":タグ名"] ?? ""}] 音声ファイル再生時間:${String(o)} <= start_ms:${String(u)} は異常値です`), g !== MAX_END_MS && o <= s && errScript(`[${r[":タグ名"] ?? ""}] 音声ファイル再生時間:${String(o)} <= end_ms:${String(g)} は異常値です`), this.#n.play("一周目");
|
|
949
|
+
}, S && x > 0) {
|
|
950
|
+
delete k.loop;
|
|
951
|
+
let e = () => {
|
|
952
|
+
e = () => {}, this.#n.play("二周目");
|
|
953
|
+
};
|
|
954
|
+
k.onend = () => e();
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
if (!O.endsWith(".bin")) {
|
|
958
|
+
this.#r(k);
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
e.#t.fetch(O).then(async (n) => {
|
|
962
|
+
n.ok || errScript(`SndBuf ロード失敗です d1 fn:${s} ${n.statusText}`, !0);
|
|
963
|
+
let r = await n.arrayBuffer(), i = await e.#t.decAB(r).catch((e) => errScript(`SndBuf ロード失敗です d2 fn:${s} ${String(e)}`, !1)), a = new Uint8Array(i), o = new Blob([a], { type: "music/mp3" }), c = URL.createObjectURL(o);
|
|
964
|
+
k.src = c, k.format = "mp3", k.onplay = () => URL.revokeObjectURL(c), this.#r(k);
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
#n;
|
|
968
|
+
#r(e) {
|
|
969
|
+
let n = this.#n = new import_howler.Howl(e);
|
|
970
|
+
this.pan !== 0 && n.stereo(this.pan), !this.loop && CmnLib.needClick2Play() && setTimeout(() => e.onend?.(0), (n.duration() - this.start_ms - (this.end_ms <= 0 ? this.end_ms : this.end_ms === MAX_END_MS ? 0 : n.duration() - this.end_ms)) * 1e3);
|
|
971
|
+
}
|
|
972
|
+
stopse() {
|
|
973
|
+
this.stt.stopse();
|
|
974
|
+
}
|
|
975
|
+
ws = (e) => this.stt.ws(e);
|
|
976
|
+
fade = (e) => this.stt.fade(e);
|
|
977
|
+
wf = (e) => this.stt.wf(e);
|
|
978
|
+
get volume() {
|
|
979
|
+
return this.#n.volume();
|
|
980
|
+
}
|
|
981
|
+
set volume(e) {
|
|
982
|
+
this.#n.volume(e);
|
|
983
|
+
}
|
|
984
|
+
}, StLoading = class {
|
|
985
|
+
constructor(e) {
|
|
986
|
+
this.sb = e;
|
|
987
|
+
}
|
|
988
|
+
onend() {
|
|
989
|
+
this.stopse();
|
|
990
|
+
}
|
|
991
|
+
onfade() {}
|
|
992
|
+
stopse() {
|
|
993
|
+
this.sb.stt = new StStop(this.sb);
|
|
994
|
+
}
|
|
995
|
+
ws = () => !1;
|
|
996
|
+
fade() {}
|
|
997
|
+
wf = () => !1;
|
|
998
|
+
}, StPlaying = class {
|
|
999
|
+
constructor(e, n) {
|
|
1000
|
+
this.sb = e, this.snd = n;
|
|
1001
|
+
}
|
|
1002
|
+
onend() {
|
|
1003
|
+
this.stopse();
|
|
1004
|
+
}
|
|
1005
|
+
onfade() {}
|
|
1006
|
+
stopse() {
|
|
1007
|
+
this.sb.stt = new StStop(this.sb, this.snd);
|
|
1008
|
+
}
|
|
1009
|
+
ws(e) {
|
|
1010
|
+
let { sb: n } = this;
|
|
1011
|
+
if (n.loop) return !1;
|
|
1012
|
+
n.stt = new StWaitingStop(n, this.snd);
|
|
1013
|
+
let i = argChk_Boolean(e, "canskip", !1), a = argChk_Boolean(e, "stop", !0) ? () => n.stt.stopse() : () => {};
|
|
1014
|
+
return i && evtMng.isSkipping ? (a(), !1) : (Reading.beginProc(n.procID + "ws", a, !0, i ? a : void 0), !0);
|
|
1015
|
+
}
|
|
1016
|
+
fade(e) {
|
|
1017
|
+
let { buf: i = "SE" } = e, a = "const.sn.sound." + i + ".volume", o = getVol(e, NaN);
|
|
1018
|
+
val.setVal_Nochk("save", a, o);
|
|
1019
|
+
let s = o * Number(val.getVal("sys:" + a, 1)), c = argChk_Boolean(e, "stop", o === 0);
|
|
1020
|
+
c && delLoopPlay(i), val.flush();
|
|
1021
|
+
let l = argChk_Num(e, "time", NaN), u = argChk_Num(e, "delay", 0), { sb: d, snd: f } = this;
|
|
1022
|
+
if (l === 0 && u === 0 || evtMng.isSkipping) {
|
|
1023
|
+
f.volume(s), c && (d.stt = new StStop(d, f));
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
1026
|
+
f.fade(f.volume(), s, l).once("fade", () => {
|
|
1027
|
+
d.stt.onfade(), c && (d.stt = new StStop(d, f));
|
|
1028
|
+
}), d.stt = new StFade(d, c, f);
|
|
1029
|
+
}
|
|
1030
|
+
wf = () => !1;
|
|
1031
|
+
}, StWaitingStop = class {
|
|
1032
|
+
constructor(e, n) {
|
|
1033
|
+
this.sb = e, this.snd = n;
|
|
1034
|
+
}
|
|
1035
|
+
onend() {
|
|
1036
|
+
this.stopse();
|
|
1037
|
+
}
|
|
1038
|
+
onfade() {}
|
|
1039
|
+
stopse() {
|
|
1040
|
+
this.sb.stt = new StStop(this.sb, this.snd), Reading.notifyEndProc(this.sb.procID + "ws");
|
|
1041
|
+
}
|
|
1042
|
+
ws = () => !1;
|
|
1043
|
+
fade() {}
|
|
1044
|
+
wf = () => !1;
|
|
1045
|
+
}, StFade = class {
|
|
1046
|
+
constructor(e, n, r) {
|
|
1047
|
+
this.sb = e, this.stopOnFade = n, this.snd = r;
|
|
1048
|
+
}
|
|
1049
|
+
onend() {
|
|
1050
|
+
this.stopse();
|
|
1051
|
+
}
|
|
1052
|
+
onfade() {
|
|
1053
|
+
this.stopOnFade ? this.stopse() : this.sb.stt = new StPlaying(this.sb, this.snd);
|
|
1054
|
+
}
|
|
1055
|
+
stopse() {
|
|
1056
|
+
this.sb.stt = new StStop(this.sb, this.snd);
|
|
1057
|
+
}
|
|
1058
|
+
ws = () => !1;
|
|
1059
|
+
fade() {}
|
|
1060
|
+
wf(e) {
|
|
1061
|
+
let { sb: n } = this;
|
|
1062
|
+
n.stt = new StWaitingFade(n, this.stopOnFade, this.snd);
|
|
1063
|
+
let i = argChk_Boolean(e, "canskip", !1);
|
|
1064
|
+
if (i && evtMng.isSkipping) return !1;
|
|
1065
|
+
let a = () => {};
|
|
1066
|
+
return Reading.beginProc(n.procID + "wf", a, !0, i ? a : void 0), !0;
|
|
1067
|
+
}
|
|
1068
|
+
}, StWaitingFade = class {
|
|
1069
|
+
constructor(e, n, r) {
|
|
1070
|
+
this.sb = e, this.stopOnFade = n, this.snd = r;
|
|
1071
|
+
}
|
|
1072
|
+
onend() {
|
|
1073
|
+
this.stopse();
|
|
1074
|
+
}
|
|
1075
|
+
onfade() {
|
|
1076
|
+
this.stopOnFade ? this.stopse() : this.sb.stt = new StPlaying(this.sb, this.snd), Reading.notifyEndProc(this.sb.procID + "wf");
|
|
1077
|
+
}
|
|
1078
|
+
stopse() {
|
|
1079
|
+
this.sb.stt = new StStop(this.sb, this.snd);
|
|
1080
|
+
}
|
|
1081
|
+
ws = () => !1;
|
|
1082
|
+
fade() {}
|
|
1083
|
+
wf = () => !1;
|
|
1084
|
+
}, StStop = class {
|
|
1085
|
+
constructor(e, n) {
|
|
1086
|
+
e.loop && delLoopPlay(e.buf);
|
|
1087
|
+
let r = "const.sn.sound." + e.buf + ".";
|
|
1088
|
+
if (val.setVal_Nochk("tmp", r + "playing", !1), val.flush(), n?.unload(), e.buf !== BUF_VOICE) return;
|
|
1089
|
+
let i = getSndBuf("BGM");
|
|
1090
|
+
i && (i.volume = Number(val.getVal("save:" + r + "volume", 1, !0)) * Number(val.getVal("sys:" + r + "volume", 1, !0))), vol_mul_talking = 1;
|
|
1091
|
+
}
|
|
1092
|
+
onend() {}
|
|
1093
|
+
onfade() {}
|
|
1094
|
+
stopse() {}
|
|
1095
|
+
ws = () => !1;
|
|
1096
|
+
fade() {}
|
|
1097
|
+
wf = () => !1;
|
|
1335
1098
|
};
|
|
1336
|
-
|
|
1099
|
+
export { require_howler as a, xchgbuf as i, BUF_SE as n, SndBuf as r, BUF_BGM as t };
|
|
1100
|
+
|
|
1101
|
+
//# sourceMappingURL=SndBuf.js.map
|