audio-mixer-ui 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audio-mixer-ui.js +547 -540
- package/dist/audio-mixer-ui.umd.cjs +1 -1
- package/package.json +2 -2
package/dist/audio-mixer-ui.js
CHANGED
|
@@ -3,10 +3,10 @@ import { defineStore as sl } from "pinia";
|
|
|
3
3
|
var gl = function() {
|
|
4
4
|
if (typeof Map < "u")
|
|
5
5
|
return Map;
|
|
6
|
-
function
|
|
6
|
+
function Z(l, U) {
|
|
7
7
|
var F = -1;
|
|
8
|
-
return l.some(function(
|
|
9
|
-
return
|
|
8
|
+
return l.some(function(d, Q) {
|
|
9
|
+
return d[0] === U ? (F = Q, !0) : !1;
|
|
10
10
|
}), F;
|
|
11
11
|
}
|
|
12
12
|
return (
|
|
@@ -25,22 +25,22 @@ var gl = function() {
|
|
|
25
25
|
enumerable: !0,
|
|
26
26
|
configurable: !0
|
|
27
27
|
}), l.prototype.get = function(U) {
|
|
28
|
-
var F =
|
|
29
|
-
return
|
|
28
|
+
var F = Z(this.__entries__, U), d = this.__entries__[F];
|
|
29
|
+
return d && d[1];
|
|
30
30
|
}, l.prototype.set = function(U, F) {
|
|
31
|
-
var
|
|
32
|
-
~
|
|
31
|
+
var d = Z(this.__entries__, U);
|
|
32
|
+
~d ? this.__entries__[d][1] = F : this.__entries__.push([U, F]);
|
|
33
33
|
}, l.prototype.delete = function(U) {
|
|
34
|
-
var F = this.__entries__,
|
|
35
|
-
~
|
|
34
|
+
var F = this.__entries__, d = Z(F, U);
|
|
35
|
+
~d && F.splice(d, 1);
|
|
36
36
|
}, l.prototype.has = function(U) {
|
|
37
|
-
return !!~
|
|
37
|
+
return !!~Z(this.__entries__, U);
|
|
38
38
|
}, l.prototype.clear = function() {
|
|
39
39
|
this.__entries__.splice(0);
|
|
40
40
|
}, l.prototype.forEach = function(U, F) {
|
|
41
41
|
F === void 0 && (F = null);
|
|
42
|
-
for (var
|
|
43
|
-
var V = Q[
|
|
42
|
+
for (var d = 0, Q = this.__entries__; d < Q.length; d++) {
|
|
43
|
+
var V = Q[d];
|
|
44
44
|
U.call(F, V[1], V[0]);
|
|
45
45
|
}
|
|
46
46
|
}, l;
|
|
@@ -49,16 +49,16 @@ var gl = function() {
|
|
|
49
49
|
}(), ul = typeof window < "u" && typeof document < "u" && window.document === document, ml = function() {
|
|
50
50
|
return typeof global < "u" && global.Math === Math ? global : typeof self < "u" && self.Math === Math ? self : typeof window < "u" && window.Math === Math ? window : Function("return this")();
|
|
51
51
|
}(), dU = function() {
|
|
52
|
-
return typeof requestAnimationFrame == "function" ? requestAnimationFrame.bind(ml) : function(
|
|
52
|
+
return typeof requestAnimationFrame == "function" ? requestAnimationFrame.bind(ml) : function(Z) {
|
|
53
53
|
return setTimeout(function() {
|
|
54
|
-
return
|
|
54
|
+
return Z(Date.now());
|
|
55
55
|
}, 1e3 / 60);
|
|
56
56
|
};
|
|
57
57
|
}(), ZU = 2;
|
|
58
|
-
function QU(
|
|
59
|
-
var U = !1, F = !1,
|
|
58
|
+
function QU(Z, l) {
|
|
59
|
+
var U = !1, F = !1, d = 0;
|
|
60
60
|
function Q() {
|
|
61
|
-
U && (U = !1,
|
|
61
|
+
U && (U = !1, Z()), F && t();
|
|
62
62
|
}
|
|
63
63
|
function V() {
|
|
64
64
|
dU(Q);
|
|
@@ -66,163 +66,163 @@ function QU(d, l) {
|
|
|
66
66
|
function t() {
|
|
67
67
|
var R = Date.now();
|
|
68
68
|
if (U) {
|
|
69
|
-
if (R -
|
|
69
|
+
if (R - d < ZU)
|
|
70
70
|
return;
|
|
71
71
|
F = !0;
|
|
72
72
|
} else
|
|
73
73
|
U = !0, F = !1, setTimeout(V, l);
|
|
74
|
-
|
|
74
|
+
d = R;
|
|
75
75
|
}
|
|
76
76
|
return t;
|
|
77
77
|
}
|
|
78
78
|
var VU = 20, tU = ["top", "right", "bottom", "left", "width", "height", "size", "weight"], RU = typeof MutationObserver < "u", aU = (
|
|
79
79
|
/** @class */
|
|
80
80
|
function() {
|
|
81
|
-
function
|
|
81
|
+
function Z() {
|
|
82
82
|
this.connected_ = !1, this.mutationEventsAdded_ = !1, this.mutationsObserver_ = null, this.observers_ = [], this.onTransitionEnd_ = this.onTransitionEnd_.bind(this), this.refresh = QU(this.refresh.bind(this), VU);
|
|
83
83
|
}
|
|
84
|
-
return
|
|
84
|
+
return Z.prototype.addObserver = function(l) {
|
|
85
85
|
~this.observers_.indexOf(l) || this.observers_.push(l), this.connected_ || this.connect_();
|
|
86
|
-
},
|
|
86
|
+
}, Z.prototype.removeObserver = function(l) {
|
|
87
87
|
var U = this.observers_, F = U.indexOf(l);
|
|
88
88
|
~F && U.splice(F, 1), !U.length && this.connected_ && this.disconnect_();
|
|
89
|
-
},
|
|
89
|
+
}, Z.prototype.refresh = function() {
|
|
90
90
|
var l = this.updateObservers_();
|
|
91
91
|
l && this.refresh();
|
|
92
|
-
},
|
|
92
|
+
}, Z.prototype.updateObservers_ = function() {
|
|
93
93
|
var l = this.observers_.filter(function(U) {
|
|
94
94
|
return U.gatherActive(), U.hasActive();
|
|
95
95
|
});
|
|
96
96
|
return l.forEach(function(U) {
|
|
97
97
|
return U.broadcastActive();
|
|
98
98
|
}), l.length > 0;
|
|
99
|
-
},
|
|
99
|
+
}, Z.prototype.connect_ = function() {
|
|
100
100
|
!ul || this.connected_ || (document.addEventListener("transitionend", this.onTransitionEnd_), window.addEventListener("resize", this.refresh), RU ? (this.mutationsObserver_ = new MutationObserver(this.refresh), this.mutationsObserver_.observe(document, {
|
|
101
101
|
attributes: !0,
|
|
102
102
|
childList: !0,
|
|
103
103
|
characterData: !0,
|
|
104
104
|
subtree: !0
|
|
105
105
|
})) : (document.addEventListener("DOMSubtreeModified", this.refresh), this.mutationEventsAdded_ = !0), this.connected_ = !0);
|
|
106
|
-
},
|
|
106
|
+
}, Z.prototype.disconnect_ = function() {
|
|
107
107
|
!ul || !this.connected_ || (document.removeEventListener("transitionend", this.onTransitionEnd_), window.removeEventListener("resize", this.refresh), this.mutationsObserver_ && this.mutationsObserver_.disconnect(), this.mutationEventsAdded_ && document.removeEventListener("DOMSubtreeModified", this.refresh), this.mutationsObserver_ = null, this.mutationEventsAdded_ = !1, this.connected_ = !1);
|
|
108
|
-
},
|
|
109
|
-
var U = l.propertyName, F = U === void 0 ? "" : U,
|
|
108
|
+
}, Z.prototype.onTransitionEnd_ = function(l) {
|
|
109
|
+
var U = l.propertyName, F = U === void 0 ? "" : U, d = tU.some(function(Q) {
|
|
110
110
|
return !!~F.indexOf(Q);
|
|
111
111
|
});
|
|
112
|
-
|
|
113
|
-
},
|
|
114
|
-
return this.instance_ || (this.instance_ = new
|
|
115
|
-
},
|
|
112
|
+
d && this.refresh();
|
|
113
|
+
}, Z.getInstance = function() {
|
|
114
|
+
return this.instance_ || (this.instance_ = new Z()), this.instance_;
|
|
115
|
+
}, Z.instance_ = null, Z;
|
|
116
116
|
}()
|
|
117
|
-
), Hl = function(
|
|
117
|
+
), Hl = function(Z, l) {
|
|
118
118
|
for (var U = 0, F = Object.keys(l); U < F.length; U++) {
|
|
119
|
-
var
|
|
120
|
-
Object.defineProperty(
|
|
121
|
-
value: l[
|
|
119
|
+
var d = F[U];
|
|
120
|
+
Object.defineProperty(Z, d, {
|
|
121
|
+
value: l[d],
|
|
122
122
|
enumerable: !1,
|
|
123
123
|
writable: !1,
|
|
124
124
|
configurable: !0
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
-
return
|
|
128
|
-
}, dl = function(
|
|
129
|
-
var l =
|
|
127
|
+
return Z;
|
|
128
|
+
}, dl = function(Z) {
|
|
129
|
+
var l = Z && Z.ownerDocument && Z.ownerDocument.defaultView;
|
|
130
130
|
return l || ml;
|
|
131
131
|
}, Dl = hl(0, 0, 0, 0);
|
|
132
|
-
function Wl(
|
|
133
|
-
return parseFloat(
|
|
132
|
+
function Wl(Z) {
|
|
133
|
+
return parseFloat(Z) || 0;
|
|
134
134
|
}
|
|
135
|
-
function Tl(
|
|
135
|
+
function Tl(Z) {
|
|
136
136
|
for (var l = [], U = 1; U < arguments.length; U++)
|
|
137
137
|
l[U - 1] = arguments[U];
|
|
138
|
-
return l.reduce(function(F,
|
|
139
|
-
var Q =
|
|
138
|
+
return l.reduce(function(F, d) {
|
|
139
|
+
var Q = Z["border-" + d + "-width"];
|
|
140
140
|
return F + Wl(Q);
|
|
141
141
|
}, 0);
|
|
142
142
|
}
|
|
143
|
-
function nU(
|
|
144
|
-
for (var l = ["top", "right", "bottom", "left"], U = {}, F = 0,
|
|
145
|
-
var Q =
|
|
143
|
+
function nU(Z) {
|
|
144
|
+
for (var l = ["top", "right", "bottom", "left"], U = {}, F = 0, d = l; F < d.length; F++) {
|
|
145
|
+
var Q = d[F], V = Z["padding-" + Q];
|
|
146
146
|
U[Q] = Wl(V);
|
|
147
147
|
}
|
|
148
148
|
return U;
|
|
149
149
|
}
|
|
150
|
-
function mU(
|
|
151
|
-
var l =
|
|
150
|
+
function mU(Z) {
|
|
151
|
+
var l = Z.getBBox();
|
|
152
152
|
return hl(0, 0, l.width, l.height);
|
|
153
153
|
}
|
|
154
|
-
function WU(
|
|
155
|
-
var l =
|
|
154
|
+
function WU(Z) {
|
|
155
|
+
var l = Z.clientWidth, U = Z.clientHeight;
|
|
156
156
|
if (!l && !U)
|
|
157
157
|
return Dl;
|
|
158
|
-
var F = dl(
|
|
159
|
-
if (F.boxSizing === "border-box" && (Math.round(t + Q) !== l && (t -= Tl(F, "left", "right") + Q), Math.round(R + V) !== U && (R -= Tl(F, "top", "bottom") + V)), !cU(
|
|
158
|
+
var F = dl(Z).getComputedStyle(Z), d = nU(F), Q = d.left + d.right, V = d.top + d.bottom, t = Wl(F.width), R = Wl(F.height);
|
|
159
|
+
if (F.boxSizing === "border-box" && (Math.round(t + Q) !== l && (t -= Tl(F, "left", "right") + Q), Math.round(R + V) !== U && (R -= Tl(F, "top", "bottom") + V)), !cU(Z)) {
|
|
160
160
|
var a = Math.round(t + Q) - l, n = Math.round(R + V) - U;
|
|
161
161
|
Math.abs(a) !== 1 && (t -= a), Math.abs(n) !== 1 && (R -= n);
|
|
162
162
|
}
|
|
163
|
-
return hl(
|
|
163
|
+
return hl(d.left, d.top, t, R);
|
|
164
164
|
}
|
|
165
165
|
var bU = /* @__PURE__ */ function() {
|
|
166
|
-
return typeof SVGGraphicsElement < "u" ? function(
|
|
167
|
-
return
|
|
168
|
-
} : function(
|
|
169
|
-
return
|
|
166
|
+
return typeof SVGGraphicsElement < "u" ? function(Z) {
|
|
167
|
+
return Z instanceof dl(Z).SVGGraphicsElement;
|
|
168
|
+
} : function(Z) {
|
|
169
|
+
return Z instanceof dl(Z).SVGElement && typeof Z.getBBox == "function";
|
|
170
170
|
};
|
|
171
171
|
}();
|
|
172
|
-
function cU(
|
|
173
|
-
return
|
|
172
|
+
function cU(Z) {
|
|
173
|
+
return Z === dl(Z).document.documentElement;
|
|
174
174
|
}
|
|
175
|
-
function eU(
|
|
176
|
-
return ul ? bU(
|
|
175
|
+
function eU(Z) {
|
|
176
|
+
return ul ? bU(Z) ? mU(Z) : WU(Z) : Dl;
|
|
177
177
|
}
|
|
178
|
-
function sU(
|
|
179
|
-
var l =
|
|
178
|
+
function sU(Z) {
|
|
179
|
+
var l = Z.x, U = Z.y, F = Z.width, d = Z.height, Q = typeof DOMRectReadOnly < "u" ? DOMRectReadOnly : Object, V = Object.create(Q.prototype);
|
|
180
180
|
return Hl(V, {
|
|
181
181
|
x: l,
|
|
182
182
|
y: U,
|
|
183
183
|
width: F,
|
|
184
|
-
height:
|
|
184
|
+
height: d,
|
|
185
185
|
top: U,
|
|
186
186
|
right: l + F,
|
|
187
|
-
bottom:
|
|
187
|
+
bottom: d + U,
|
|
188
188
|
left: l
|
|
189
189
|
}), V;
|
|
190
190
|
}
|
|
191
|
-
function hl(
|
|
192
|
-
return { x:
|
|
191
|
+
function hl(Z, l, U, F) {
|
|
192
|
+
return { x: Z, y: l, width: U, height: F };
|
|
193
193
|
}
|
|
194
194
|
var hU = (
|
|
195
195
|
/** @class */
|
|
196
196
|
function() {
|
|
197
|
-
function
|
|
197
|
+
function Z(l) {
|
|
198
198
|
this.broadcastWidth = 0, this.broadcastHeight = 0, this.contentRect_ = hl(0, 0, 0, 0), this.target = l;
|
|
199
199
|
}
|
|
200
|
-
return
|
|
200
|
+
return Z.prototype.isActive = function() {
|
|
201
201
|
var l = eU(this.target);
|
|
202
202
|
return this.contentRect_ = l, l.width !== this.broadcastWidth || l.height !== this.broadcastHeight;
|
|
203
|
-
},
|
|
203
|
+
}, Z.prototype.broadcastRect = function() {
|
|
204
204
|
var l = this.contentRect_;
|
|
205
205
|
return this.broadcastWidth = l.width, this.broadcastHeight = l.height, l;
|
|
206
|
-
},
|
|
206
|
+
}, Z;
|
|
207
207
|
}()
|
|
208
208
|
), BU = (
|
|
209
209
|
/** @class */
|
|
210
210
|
/* @__PURE__ */ function() {
|
|
211
|
-
function
|
|
211
|
+
function Z(l, U) {
|
|
212
212
|
var F = sU(U);
|
|
213
213
|
Hl(this, { target: l, contentRect: F });
|
|
214
214
|
}
|
|
215
|
-
return
|
|
215
|
+
return Z;
|
|
216
216
|
}()
|
|
217
217
|
), JU = (
|
|
218
218
|
/** @class */
|
|
219
219
|
function() {
|
|
220
|
-
function
|
|
220
|
+
function Z(l, U, F) {
|
|
221
221
|
if (this.activeObservations_ = [], this.observations_ = new gl(), typeof l != "function")
|
|
222
222
|
throw new TypeError("The callback provided as parameter 1 is not a function.");
|
|
223
223
|
this.callback_ = l, this.controller_ = U, this.callbackCtx_ = F;
|
|
224
224
|
}
|
|
225
|
-
return
|
|
225
|
+
return Z.prototype.observe = function(l) {
|
|
226
226
|
if (!arguments.length)
|
|
227
227
|
throw new TypeError("1 argument required, but only 0 present.");
|
|
228
228
|
if (!(typeof Element > "u" || !(Element instanceof Object))) {
|
|
@@ -231,7 +231,7 @@ var hU = (
|
|
|
231
231
|
var U = this.observations_;
|
|
232
232
|
U.has(l) || (U.set(l, new hU(l)), this.controller_.addObserver(this), this.controller_.refresh());
|
|
233
233
|
}
|
|
234
|
-
},
|
|
234
|
+
}, Z.prototype.unobserve = function(l) {
|
|
235
235
|
if (!arguments.length)
|
|
236
236
|
throw new TypeError("1 argument required, but only 0 present.");
|
|
237
237
|
if (!(typeof Element > "u" || !(Element instanceof Object))) {
|
|
@@ -240,62 +240,62 @@ var hU = (
|
|
|
240
240
|
var U = this.observations_;
|
|
241
241
|
U.has(l) && (U.delete(l), U.size || this.controller_.removeObserver(this));
|
|
242
242
|
}
|
|
243
|
-
},
|
|
243
|
+
}, Z.prototype.disconnect = function() {
|
|
244
244
|
this.clearActive(), this.observations_.clear(), this.controller_.removeObserver(this);
|
|
245
|
-
},
|
|
245
|
+
}, Z.prototype.gatherActive = function() {
|
|
246
246
|
var l = this;
|
|
247
247
|
this.clearActive(), this.observations_.forEach(function(U) {
|
|
248
248
|
U.isActive() && l.activeObservations_.push(U);
|
|
249
249
|
});
|
|
250
|
-
},
|
|
250
|
+
}, Z.prototype.broadcastActive = function() {
|
|
251
251
|
if (this.hasActive()) {
|
|
252
252
|
var l = this.callbackCtx_, U = this.activeObservations_.map(function(F) {
|
|
253
253
|
return new BU(F.target, F.broadcastRect());
|
|
254
254
|
});
|
|
255
255
|
this.callback_.call(l, U, l), this.clearActive();
|
|
256
256
|
}
|
|
257
|
-
},
|
|
257
|
+
}, Z.prototype.clearActive = function() {
|
|
258
258
|
this.activeObservations_.splice(0);
|
|
259
|
-
},
|
|
259
|
+
}, Z.prototype.hasActive = function() {
|
|
260
260
|
return this.activeObservations_.length > 0;
|
|
261
|
-
},
|
|
261
|
+
}, Z;
|
|
262
262
|
}()
|
|
263
263
|
), jl = typeof WeakMap < "u" ? /* @__PURE__ */ new WeakMap() : new gl(), Pl = (
|
|
264
264
|
/** @class */
|
|
265
265
|
/* @__PURE__ */ function() {
|
|
266
|
-
function
|
|
267
|
-
if (!(this instanceof
|
|
266
|
+
function Z(l) {
|
|
267
|
+
if (!(this instanceof Z))
|
|
268
268
|
throw new TypeError("Cannot call a class as a function.");
|
|
269
269
|
if (!arguments.length)
|
|
270
270
|
throw new TypeError("1 argument required, but only 0 present.");
|
|
271
271
|
var U = aU.getInstance(), F = new JU(l, U, this);
|
|
272
272
|
jl.set(this, F);
|
|
273
273
|
}
|
|
274
|
-
return
|
|
274
|
+
return Z;
|
|
275
275
|
}()
|
|
276
276
|
);
|
|
277
277
|
[
|
|
278
278
|
"observe",
|
|
279
279
|
"unobserve",
|
|
280
280
|
"disconnect"
|
|
281
|
-
].forEach(function(
|
|
282
|
-
Pl.prototype[
|
|
281
|
+
].forEach(function(Z) {
|
|
282
|
+
Pl.prototype[Z] = function() {
|
|
283
283
|
var l;
|
|
284
|
-
return (l = jl.get(this))[
|
|
284
|
+
return (l = jl.get(this))[Z].apply(l, arguments);
|
|
285
285
|
};
|
|
286
286
|
});
|
|
287
287
|
var uU = function() {
|
|
288
288
|
return typeof ml.ResizeObserver < "u" ? ml.ResizeObserver : Pl;
|
|
289
289
|
}();
|
|
290
|
-
function ll(
|
|
290
|
+
function ll(Z) {
|
|
291
291
|
const l = x(0), U = x(0);
|
|
292
292
|
let F = null;
|
|
293
|
-
const
|
|
293
|
+
const d = () => {
|
|
294
294
|
F && (F.disconnect(), F = null);
|
|
295
295
|
};
|
|
296
|
-
return v(() => r(
|
|
297
|
-
|
|
298
|
-
const V = r(
|
|
296
|
+
return v(() => r(Z), () => {
|
|
297
|
+
d();
|
|
298
|
+
const V = r(Z);
|
|
299
299
|
if (!V) return;
|
|
300
300
|
F = new uU((R) => {
|
|
301
301
|
const a = R[0];
|
|
@@ -303,15 +303,15 @@ function ll(d) {
|
|
|
303
303
|
}), F.observe(V);
|
|
304
304
|
const t = V.getBoundingClientRect();
|
|
305
305
|
l.value = t.width, U.value = t.height;
|
|
306
|
-
}, { immediate: !0 }), UU(
|
|
306
|
+
}, { immediate: !0 }), UU(d), {
|
|
307
307
|
width: yl(l),
|
|
308
308
|
height: yl(U)
|
|
309
309
|
};
|
|
310
310
|
}
|
|
311
|
-
const g = (
|
|
312
|
-
const U =
|
|
313
|
-
for (const [F,
|
|
314
|
-
U[F] =
|
|
311
|
+
const g = (Z, l) => {
|
|
312
|
+
const U = Z.__vccOpts || Z;
|
|
313
|
+
for (const [F, d] of l)
|
|
314
|
+
U[F] = d;
|
|
315
315
|
return U;
|
|
316
316
|
}, GU = {
|
|
317
317
|
key: 0,
|
|
@@ -332,7 +332,7 @@ const g = (d, l) => {
|
|
|
332
332
|
valueModifiers: {}
|
|
333
333
|
}),
|
|
334
334
|
emits: ["update:value"],
|
|
335
|
-
setup(
|
|
335
|
+
setup(Z) {
|
|
336
336
|
$((i) => ({
|
|
337
337
|
"083f3e45": c.value,
|
|
338
338
|
d4833630: W.value,
|
|
@@ -340,7 +340,7 @@ const g = (d, l) => {
|
|
|
340
340
|
12894835: s.value,
|
|
341
341
|
"3e9a6a44": N.value
|
|
342
342
|
}));
|
|
343
|
-
const l =
|
|
343
|
+
const l = Z, U = O("root"), { width: F, height: d } = ll(U), Q = G(() => Math.min(F.value, d.value)), V = G(() => Math.max(F.value, d.value)), t = G(() => F.value > d.value), R = G(() => t.value ? "h-slide" : "v-slide"), a = _(Z, "value"), n = G(() => Q.value * 0.8), m = G(() => Q.value * l.thumbLength * 0.8), W = G(() => (t.value ? m : n).value + "px"), c = G(() => (t.value ? n : m).value + "px"), s = G(() => Q.value * 0.1 + "px"), N = G(() => (V.value - m.value) * (a.value - l.min) / (l.max - l.min) + "px"), J = G(() => t.value ? "90deg" : "0deg"), p = x(!1), M = x(0), y = (i) => {
|
|
344
344
|
if (!U.value) return a.value;
|
|
345
345
|
const z = U.value.getBoundingClientRect(), P = i.touches ? i.touches[0].clientX : i.clientX, B = i.touches ? i.touches[0].clientY : i.clientY;
|
|
346
346
|
let S;
|
|
@@ -382,7 +382,7 @@ const g = (d, l) => {
|
|
|
382
382
|
style: { userSelect: "none", touchAction: "none" }
|
|
383
383
|
}, [
|
|
384
384
|
z[0] || (z[0] = h("div", { class: "track" }, null, -1)),
|
|
385
|
-
|
|
385
|
+
Z.showLevel ? (X(), Y("div", GU, [
|
|
386
386
|
(X(), Y(al, null, Sl(10, (P) => h("div", {
|
|
387
387
|
class: L(["led", "led" + P])
|
|
388
388
|
}, [
|
|
@@ -393,7 +393,7 @@ const g = (d, l) => {
|
|
|
393
393
|
], 2)), 64))
|
|
394
394
|
])) : f("", !0),
|
|
395
395
|
h("div", {
|
|
396
|
-
class: L(["thumb", { dragging: p.value, [
|
|
396
|
+
class: L(["thumb", { dragging: p.value, [Z.colour]: !0, [Z.style]: !0 }])
|
|
397
397
|
}, null, 2)
|
|
398
398
|
], 34));
|
|
399
399
|
}
|
|
@@ -405,18 +405,18 @@ const g = (d, l) => {
|
|
|
405
405
|
default: "left"
|
|
406
406
|
}
|
|
407
407
|
},
|
|
408
|
-
setup(
|
|
408
|
+
setup(Z) {
|
|
409
409
|
$((t) => ({
|
|
410
410
|
"5fddb56d": V.value
|
|
411
411
|
}));
|
|
412
|
-
const l = O("el"), { width: U, height: F } = ll(l),
|
|
412
|
+
const l = O("el"), { width: U, height: F } = ll(l), d = G(() => Math.min(U.value, F.value)), Q = G(() => U.value > F.value ? "h-text" : "v-text"), V = G(() => d.value * 3 / 4 + "px");
|
|
413
413
|
return (t, R) => (X(), Y("div", {
|
|
414
414
|
ref_key: "el",
|
|
415
415
|
ref: l,
|
|
416
416
|
class: "outer"
|
|
417
417
|
}, [
|
|
418
418
|
h("div", {
|
|
419
|
-
class: L({ [Q.value]: !0, [
|
|
419
|
+
class: L({ [Q.value]: !0, [Z.align]: !0 })
|
|
420
420
|
}, [
|
|
421
421
|
Vl(t.$slots, "default", {}, void 0, !0)
|
|
422
422
|
], 2)
|
|
@@ -431,8 +431,8 @@ const g = (d, l) => {
|
|
|
431
431
|
soloModifiers: {}
|
|
432
432
|
},
|
|
433
433
|
emits: ["update:mute", "update:solo"],
|
|
434
|
-
setup(
|
|
435
|
-
const l = _(
|
|
434
|
+
setup(Z) {
|
|
435
|
+
const l = _(Z, "mute"), U = _(Z, "solo"), F = O("outer"), { width: d, height: Q } = ll(F), V = G(() => d.value > Q.value * 1.9);
|
|
436
436
|
function t() {
|
|
437
437
|
l.value = !l.value, U.value = !1;
|
|
438
438
|
}
|
|
@@ -474,7 +474,7 @@ const g = (d, l) => {
|
|
|
474
474
|
// Enable other debug/dev features as needed
|
|
475
475
|
debugMode: !1
|
|
476
476
|
}
|
|
477
|
-
}, kF = () => Gl.enabled, Ol = (
|
|
477
|
+
}, kF = () => Gl.enabled, Ol = (Z) => Gl.enabled && Gl.features[Z], Ul = sl("audioState", {
|
|
478
478
|
state: () => ({
|
|
479
479
|
// Playback state
|
|
480
480
|
isPlaying: !1,
|
|
@@ -502,78 +502,78 @@ const g = (d, l) => {
|
|
|
502
502
|
}),
|
|
503
503
|
getters: {
|
|
504
504
|
// Format current time as MM:SS
|
|
505
|
-
formattedTime: (
|
|
506
|
-
const l = Math.floor(
|
|
505
|
+
formattedTime: (Z) => {
|
|
506
|
+
const l = Math.floor(Z.currentTime / 60), U = Math.floor(Z.currentTime % 60);
|
|
507
507
|
return `${l}:${U.toString().padStart(2, "0")}`;
|
|
508
508
|
},
|
|
509
509
|
// Get volume for a specific part
|
|
510
|
-
getPartVolume: (
|
|
510
|
+
getPartVolume: (Z) => (l) => Z.partVolumes[l] ?? 0.75,
|
|
511
511
|
// Check if part is muted
|
|
512
|
-
isPartMuted: (
|
|
512
|
+
isPartMuted: (Z) => (l) => Z.partMuted[l] ?? !1,
|
|
513
513
|
// Check if part is solo
|
|
514
|
-
isPartSolo: (
|
|
514
|
+
isPartSolo: (Z) => (l) => Z.partSolo[l] ?? !1,
|
|
515
515
|
// Check if any part has solo enabled (global solo state)
|
|
516
|
-
isAnySolo: (
|
|
516
|
+
isAnySolo: (Z) => Object.values(Z.partSolo).some((l) => l === !0),
|
|
517
517
|
// Current musical position as string
|
|
518
|
-
currentPosition: (
|
|
519
|
-
let l = `${
|
|
520
|
-
return
|
|
518
|
+
currentPosition: (Z) => {
|
|
519
|
+
let l = `${Z.currentBar}.${Z.currentBeat}`;
|
|
520
|
+
return Z.currentRepeat > 0 && (l += ` (R${Z.currentRepeat})`), l;
|
|
521
521
|
}
|
|
522
522
|
},
|
|
523
523
|
actions: {
|
|
524
524
|
// Playback state updates
|
|
525
|
-
setPlaybackState(
|
|
526
|
-
this.isPlaying =
|
|
525
|
+
setPlaybackState(Z) {
|
|
526
|
+
this.isPlaying = Z;
|
|
527
527
|
},
|
|
528
|
-
setCurrentTime(
|
|
529
|
-
this.currentTime =
|
|
528
|
+
setCurrentTime(Z) {
|
|
529
|
+
this.currentTime = Z;
|
|
530
530
|
},
|
|
531
|
-
setPlaybackSpeed(
|
|
532
|
-
this.playbackSpeed =
|
|
531
|
+
setPlaybackSpeed(Z) {
|
|
532
|
+
this.playbackSpeed = Z;
|
|
533
533
|
},
|
|
534
534
|
// Musical position updates
|
|
535
|
-
setCurrentBar(
|
|
536
|
-
typeof
|
|
535
|
+
setCurrentBar(Z, l = 1, U = 0) {
|
|
536
|
+
typeof Z == "number" && (this.currentBar = Z), typeof l == "number" && (this.currentBeat = l), typeof U == "number" && (this.currentRepeat = U);
|
|
537
537
|
},
|
|
538
538
|
// Volume controls
|
|
539
|
-
setMasterVolume(
|
|
540
|
-
this.masterVolume = Math.max(0, Math.min(1,
|
|
539
|
+
setMasterVolume(Z) {
|
|
540
|
+
this.masterVolume = Math.max(0, Math.min(1, Z));
|
|
541
541
|
},
|
|
542
|
-
setMetronomeVolume(
|
|
543
|
-
this.metronomeVolume = Math.max(0, Math.min(1,
|
|
542
|
+
setMetronomeVolume(Z) {
|
|
543
|
+
this.metronomeVolume = Math.max(0, Math.min(1, Z));
|
|
544
544
|
},
|
|
545
|
-
setPartVolume(
|
|
546
|
-
this.partVolumes[
|
|
545
|
+
setPartVolume(Z, l) {
|
|
546
|
+
this.partVolumes[Z] = Math.max(0, Math.min(1, l));
|
|
547
547
|
},
|
|
548
|
-
setPartMuted(
|
|
549
|
-
this.partMuted[
|
|
548
|
+
setPartMuted(Z, l) {
|
|
549
|
+
this.partMuted[Z] = l;
|
|
550
550
|
},
|
|
551
|
-
setPartSolo(
|
|
552
|
-
this.partSolo[
|
|
551
|
+
setPartSolo(Z, l) {
|
|
552
|
+
this.partSolo[Z] = l;
|
|
553
553
|
},
|
|
554
554
|
// Transport features
|
|
555
|
-
setLeadInActive(
|
|
556
|
-
this.isLeadInActive =
|
|
555
|
+
setLeadInActive(Z, l = 1) {
|
|
556
|
+
this.isLeadInActive = Z, this.leadInBars = l;
|
|
557
557
|
},
|
|
558
|
-
setStartingNotesActive(
|
|
559
|
-
this.isStartingNotesActive =
|
|
558
|
+
setStartingNotesActive(Z) {
|
|
559
|
+
this.isStartingNotesActive = Z;
|
|
560
560
|
},
|
|
561
561
|
// Feature toggles
|
|
562
|
-
setMetronomeEnabled(
|
|
563
|
-
this.metronomeEnabled =
|
|
562
|
+
setMetronomeEnabled(Z) {
|
|
563
|
+
this.metronomeEnabled = Z;
|
|
564
564
|
},
|
|
565
|
-
setLeadInEnabled(
|
|
566
|
-
this.leadInEnabled =
|
|
565
|
+
setLeadInEnabled(Z) {
|
|
566
|
+
this.leadInEnabled = Z;
|
|
567
567
|
},
|
|
568
568
|
// Initialize part states
|
|
569
|
-
initializeParts(
|
|
570
|
-
this.partVolumes = {}, this.partMuted = {}, this.partSolo = {},
|
|
569
|
+
initializeParts(Z) {
|
|
570
|
+
this.partVolumes = {}, this.partMuted = {}, this.partSolo = {}, Z.forEach((l) => {
|
|
571
571
|
this.partVolumes[l.name] = l.volume || 0.75, this.partMuted[l.name] = !1, this.partSolo[l.name] = !1;
|
|
572
572
|
});
|
|
573
573
|
},
|
|
574
574
|
// Initialization state (for blur overlay)
|
|
575
|
-
setLoaded(
|
|
576
|
-
this.isLoaded =
|
|
575
|
+
setLoaded(Z) {
|
|
576
|
+
this.isLoaded = Z;
|
|
577
577
|
}
|
|
578
578
|
}
|
|
579
579
|
}), tl = sl("musicData", {
|
|
@@ -592,30 +592,30 @@ const g = (d, l) => {
|
|
|
592
592
|
}),
|
|
593
593
|
getters: {
|
|
594
594
|
// Get practice mark letters as array
|
|
595
|
-
practiceMarkLetters: (
|
|
595
|
+
practiceMarkLetters: (Z) => Object.keys(Z.practiceMarks).sort(),
|
|
596
596
|
// Get bar number for practice mark
|
|
597
|
-
getBarForMark: (
|
|
597
|
+
getBarForMark: (Z) => (l) => Z.practiceMarks[l],
|
|
598
598
|
// Get all unique bar numbers
|
|
599
|
-
allBars: (
|
|
599
|
+
allBars: (Z) => {
|
|
600
600
|
const l = /* @__PURE__ */ new Set();
|
|
601
|
-
return
|
|
601
|
+
return Z.beats.forEach((U) => {
|
|
602
602
|
U.beat === 1 && l.add(U.bar);
|
|
603
603
|
}), Array.from(l).sort((U, F) => U - F);
|
|
604
604
|
},
|
|
605
605
|
// Check if a bar has repeats
|
|
606
|
-
hasRepeats: (
|
|
606
|
+
hasRepeats: (Z) => (l) => Z.beats.some((U) => U.bar === l && U.repeat > 0),
|
|
607
607
|
// Get the number of repeats for a specific bar
|
|
608
|
-
getRepeatCountForBar: (
|
|
608
|
+
getRepeatCountForBar: (Z) => (l) => {
|
|
609
609
|
const U = /* @__PURE__ */ new Set();
|
|
610
|
-
return
|
|
610
|
+
return Z.beats.forEach((F) => {
|
|
611
611
|
F.bar === l && U.add(F.repeat);
|
|
612
612
|
}), U.size;
|
|
613
613
|
}
|
|
614
614
|
},
|
|
615
615
|
actions: {
|
|
616
616
|
// Load musical data
|
|
617
|
-
loadMusicData(
|
|
618
|
-
this.title =
|
|
617
|
+
loadMusicData(Z) {
|
|
618
|
+
this.title = Z.title || "Untitled", this.beats = Z.beats || [], this.practiceMarks = Z.practiceMarks || Z.marks || {}, this.parts = (Z.parts || []).map((l) => ({
|
|
619
619
|
...l,
|
|
620
620
|
solo: l.solo || !1,
|
|
621
621
|
mute: l.mute || !1
|
|
@@ -623,38 +623,38 @@ const g = (d, l) => {
|
|
|
623
623
|
},
|
|
624
624
|
// Calculate total duration from beats
|
|
625
625
|
calculateDuration() {
|
|
626
|
-
this.beats.length > 0 && (this.totalDuration = Math.max(...this.beats.map((
|
|
626
|
+
this.beats.length > 0 && (this.totalDuration = Math.max(...this.beats.map((Z) => Z.time)));
|
|
627
627
|
},
|
|
628
628
|
// Find the highest bar number
|
|
629
629
|
calculateMaxBar() {
|
|
630
|
-
this.beats.length > 0 && (this.maxBar = Math.max(...this.beats.map((
|
|
630
|
+
this.beats.length > 0 && (this.maxBar = Math.max(...this.beats.map((Z) => Z.bar)));
|
|
631
631
|
},
|
|
632
632
|
// Extract time signature from first beat
|
|
633
633
|
extractTimeSignature() {
|
|
634
634
|
this.beats.length > 0 && this.beats[0].timeSig && (this.timeSignature = this.beats[0].timeSig), this.beats.length > 0 && this.beats[0].tempo && (this.baseTempo = this.beats[0].tempo);
|
|
635
635
|
},
|
|
636
636
|
// Update practice marks
|
|
637
|
-
setPracticeMark(
|
|
638
|
-
this.practiceMarks[
|
|
637
|
+
setPracticeMark(Z, l) {
|
|
638
|
+
this.practiceMarks[Z] = l;
|
|
639
639
|
},
|
|
640
|
-
removePracticeMark(
|
|
641
|
-
delete this.practiceMarks[
|
|
640
|
+
removePracticeMark(Z) {
|
|
641
|
+
delete this.practiceMarks[Z];
|
|
642
642
|
},
|
|
643
643
|
// Update beats data (for when MIDI parser provides new beat information)
|
|
644
|
-
updateBeats(
|
|
645
|
-
console.log("Updating beats in music data store"), this.beats =
|
|
644
|
+
updateBeats(Z) {
|
|
645
|
+
console.log("Updating beats in music data store"), this.beats = Z, this.calculateDuration(), this.calculateMaxBar(), this.extractTimeSignature();
|
|
646
646
|
},
|
|
647
647
|
// Update total duration (for when audio engine provides actual duration)
|
|
648
|
-
setTotalDuration(
|
|
649
|
-
console.log("Setting total duration in music data store to:",
|
|
648
|
+
setTotalDuration(Z) {
|
|
649
|
+
console.log("Setting total duration in music data store to:", Z), this.totalDuration = Z;
|
|
650
650
|
},
|
|
651
651
|
// Validate bar number
|
|
652
|
-
isValidBar(
|
|
653
|
-
return this.beats.some((U) => U.bar ===
|
|
652
|
+
isValidBar(Z, l = 0) {
|
|
653
|
+
return this.beats.some((U) => U.bar === Z && U.repeat === l);
|
|
654
654
|
},
|
|
655
655
|
// Update parts (for when audio engine discovers parts from MIDI)
|
|
656
|
-
setParts(
|
|
657
|
-
this.parts =
|
|
656
|
+
setParts(Z) {
|
|
657
|
+
this.parts = Z.map((l) => ({
|
|
658
658
|
name: l.name,
|
|
659
659
|
volume: l.volume || 0.75,
|
|
660
660
|
solo: l.solo || !1,
|
|
@@ -691,20 +691,20 @@ const g = (d, l) => {
|
|
|
691
691
|
}),
|
|
692
692
|
getters: {
|
|
693
693
|
// Check if currently playing
|
|
694
|
-
isPlaying: (
|
|
694
|
+
isPlaying: (Z) => Z.transportState === "playing",
|
|
695
695
|
// Check if paused
|
|
696
|
-
isPaused: (
|
|
696
|
+
isPaused: (Z) => Z.transportState === "paused",
|
|
697
697
|
// Check if stopped
|
|
698
|
-
isStopped: (
|
|
698
|
+
isStopped: (Z) => Z.transportState === "stopped",
|
|
699
699
|
// Check if loop is configured
|
|
700
|
-
isLoopConfigured: (
|
|
700
|
+
isLoopConfigured: (Z) => Z.loopEnabled && Z.loopStart && Z.loopEnd && Z.loopEnd > Z.loopStart,
|
|
701
701
|
// Get loop range as string
|
|
702
|
-
loopRange: (
|
|
702
|
+
loopRange: (Z) => !Z.loopEnabled || !Z.loopStart || !Z.loopEnd ? null : `${Z.loopStart}-${Z.loopEnd}`
|
|
703
703
|
},
|
|
704
704
|
actions: {
|
|
705
705
|
// Transport controls
|
|
706
|
-
setTransportState(
|
|
707
|
-
["stopped", "playing", "paused"].includes(
|
|
706
|
+
setTransportState(Z) {
|
|
707
|
+
["stopped", "playing", "paused"].includes(Z) && (this.transportState = Z);
|
|
708
708
|
},
|
|
709
709
|
play() {
|
|
710
710
|
this.setTransportState("playing");
|
|
@@ -716,55 +716,55 @@ const g = (d, l) => {
|
|
|
716
716
|
this.setTransportState("stopped");
|
|
717
717
|
},
|
|
718
718
|
// Navigation settings
|
|
719
|
-
setAutoPlay(
|
|
720
|
-
this.autoPlay =
|
|
719
|
+
setAutoPlay(Z) {
|
|
720
|
+
this.autoPlay = Z;
|
|
721
721
|
},
|
|
722
|
-
setLoop(
|
|
723
|
-
this.loopEnabled =
|
|
722
|
+
setLoop(Z, l = null, U = null) {
|
|
723
|
+
this.loopEnabled = Z, l !== null && (this.loopStart = l), U !== null && (this.loopEnd = U);
|
|
724
724
|
},
|
|
725
|
-
setLoopStart(
|
|
726
|
-
this.loopStart =
|
|
725
|
+
setLoopStart(Z) {
|
|
726
|
+
this.loopStart = Z, this.loopEnd && this.loopEnd <= Z && (this.loopEnd = Z + 4);
|
|
727
727
|
},
|
|
728
|
-
setLoopEnd(
|
|
729
|
-
this.loopEnd =
|
|
728
|
+
setLoopEnd(Z) {
|
|
729
|
+
this.loopEnd = Z, this.loopStart && this.loopStart >= Z && (this.loopStart = Math.max(1, Z - 4));
|
|
730
730
|
},
|
|
731
731
|
// Lead-in settings
|
|
732
|
-
setLeadInEnabled(
|
|
733
|
-
this.leadInEnabled =
|
|
732
|
+
setLeadInEnabled(Z) {
|
|
733
|
+
this.leadInEnabled = Z;
|
|
734
734
|
},
|
|
735
|
-
setLeadInBars(
|
|
736
|
-
this.leadInBars = Math.max(1, Math.min(4,
|
|
735
|
+
setLeadInBars(Z) {
|
|
736
|
+
this.leadInBars = Math.max(1, Math.min(4, Z));
|
|
737
737
|
},
|
|
738
738
|
// Starting notes settings
|
|
739
|
-
setStartingNotesEnabled(
|
|
740
|
-
this.startingNotesEnabled =
|
|
739
|
+
setStartingNotesEnabled(Z) {
|
|
740
|
+
this.startingNotesEnabled = Z;
|
|
741
741
|
},
|
|
742
|
-
setStartingNotesSequential(
|
|
743
|
-
this.startingNotesSequential =
|
|
742
|
+
setStartingNotesSequential(Z) {
|
|
743
|
+
this.startingNotesSequential = Z;
|
|
744
744
|
},
|
|
745
745
|
// Metronome settings
|
|
746
|
-
setMetronomeEnabled(
|
|
747
|
-
this.metronomeEnabled =
|
|
746
|
+
setMetronomeEnabled(Z) {
|
|
747
|
+
this.metronomeEnabled = Z;
|
|
748
748
|
},
|
|
749
|
-
setMetronomeVolume(
|
|
750
|
-
this.metronomeVolume = Math.max(0, Math.min(1,
|
|
749
|
+
setMetronomeVolume(Z) {
|
|
750
|
+
this.metronomeVolume = Math.max(0, Math.min(1, Z));
|
|
751
751
|
},
|
|
752
752
|
// UI visibility controls
|
|
753
|
-
setTransportControlsVisible(
|
|
754
|
-
this.showTransportControls =
|
|
753
|
+
setTransportControlsVisible(Z) {
|
|
754
|
+
this.showTransportControls = Z;
|
|
755
755
|
},
|
|
756
|
-
setPartControlsVisible(
|
|
757
|
-
this.showPartControls =
|
|
756
|
+
setPartControlsVisible(Z) {
|
|
757
|
+
this.showPartControls = Z;
|
|
758
758
|
},
|
|
759
|
-
setNavigationControlsVisible(
|
|
760
|
-
this.showNavigationControls =
|
|
759
|
+
setNavigationControlsVisible(Z) {
|
|
760
|
+
this.showNavigationControls = Z;
|
|
761
761
|
},
|
|
762
762
|
// Position tracking
|
|
763
|
-
updateLastBarPosition(
|
|
764
|
-
this.lastBarPosition =
|
|
763
|
+
updateLastBarPosition(Z) {
|
|
764
|
+
this.lastBarPosition = Z;
|
|
765
765
|
},
|
|
766
|
-
updateLastPracticeMarkUsed(
|
|
767
|
-
this.lastPracticeMarkUsed =
|
|
766
|
+
updateLastPracticeMarkUsed(Z) {
|
|
767
|
+
this.lastPracticeMarkUsed = Z;
|
|
768
768
|
},
|
|
769
769
|
// Reset to defaults
|
|
770
770
|
resetToDefaults() {
|
|
@@ -772,35 +772,35 @@ const g = (d, l) => {
|
|
|
772
772
|
}
|
|
773
773
|
}
|
|
774
774
|
});
|
|
775
|
-
function fl(
|
|
776
|
-
return { all:
|
|
777
|
-
var F =
|
|
778
|
-
F ? F.push(U) :
|
|
775
|
+
function fl(Z) {
|
|
776
|
+
return { all: Z = Z || /* @__PURE__ */ new Map(), on: function(l, U) {
|
|
777
|
+
var F = Z.get(l);
|
|
778
|
+
F ? F.push(U) : Z.set(l, [U]);
|
|
779
779
|
}, off: function(l, U) {
|
|
780
|
-
var F =
|
|
781
|
-
F && (U ? F.splice(F.indexOf(U) >>> 0, 1) :
|
|
780
|
+
var F = Z.get(l);
|
|
781
|
+
F && (U ? F.splice(F.indexOf(U) >>> 0, 1) : Z.set(l, []));
|
|
782
782
|
}, emit: function(l, U) {
|
|
783
|
-
var F =
|
|
784
|
-
F && F.slice().map(function(
|
|
785
|
-
|
|
786
|
-
}), (F =
|
|
787
|
-
|
|
783
|
+
var F = Z.get(l);
|
|
784
|
+
F && F.slice().map(function(d) {
|
|
785
|
+
d(U);
|
|
786
|
+
}), (F = Z.get("*")) && F.slice().map(function(d) {
|
|
787
|
+
d(l, U);
|
|
788
788
|
});
|
|
789
789
|
} };
|
|
790
790
|
}
|
|
791
|
-
function Xl(
|
|
792
|
-
return { all:
|
|
793
|
-
var F =
|
|
794
|
-
F ? F.push(U) :
|
|
791
|
+
function Xl(Z) {
|
|
792
|
+
return { all: Z = Z || /* @__PURE__ */ new Map(), on: function(l, U) {
|
|
793
|
+
var F = Z.get(l);
|
|
794
|
+
F ? F.push(U) : Z.set(l, [U]);
|
|
795
795
|
}, off: function(l, U) {
|
|
796
|
-
var F =
|
|
797
|
-
F && (U ? F.splice(F.indexOf(U) >>> 0, 1) :
|
|
796
|
+
var F = Z.get(l);
|
|
797
|
+
F && (U ? F.splice(F.indexOf(U) >>> 0, 1) : Z.set(l, []));
|
|
798
798
|
}, emit: function(l, U) {
|
|
799
|
-
var F =
|
|
800
|
-
F && F.slice().map(function(
|
|
801
|
-
|
|
802
|
-
}), (F =
|
|
803
|
-
|
|
799
|
+
var F = Z.get(l);
|
|
800
|
+
F && F.slice().map(function(d) {
|
|
801
|
+
d(U);
|
|
802
|
+
}), (F = Z.get("*")) && F.slice().map(function(d) {
|
|
803
|
+
d(l, U);
|
|
804
804
|
});
|
|
805
805
|
} };
|
|
806
806
|
}
|
|
@@ -840,8 +840,8 @@ class Nl {
|
|
|
840
840
|
* @protected
|
|
841
841
|
*/
|
|
842
842
|
_emitProgress(l, U, F = null) {
|
|
843
|
-
const
|
|
844
|
-
F !== null && (
|
|
843
|
+
const d = { stage: l, message: U };
|
|
844
|
+
F !== null && (d.progress = Math.max(0, Math.min(1, F))), this.eventBus.emit("initProgress", d);
|
|
845
845
|
}
|
|
846
846
|
/**
|
|
847
847
|
* Initialize the audio engine - load soundfont and set up synthesis
|
|
@@ -878,21 +878,21 @@ class Nl {
|
|
|
878
878
|
async playMetronomeTick(l, U, F) {
|
|
879
879
|
try {
|
|
880
880
|
await this._ensureMetronomeBuffersLoaded();
|
|
881
|
-
const
|
|
882
|
-
if (!
|
|
881
|
+
const d = U ? this.accentTickBuffer : this.regularTickBuffer;
|
|
882
|
+
if (!d) {
|
|
883
883
|
console.warn("Metronome buffer not available");
|
|
884
884
|
return;
|
|
885
885
|
}
|
|
886
886
|
const Q = this.audioContext.createBufferSource();
|
|
887
|
-
Q.buffer =
|
|
887
|
+
Q.buffer = d;
|
|
888
888
|
const V = this.audioContext.createGain();
|
|
889
889
|
V.gain.value = F, Q.connect(V);
|
|
890
890
|
const t = this.getMetronomeOutput();
|
|
891
891
|
t ? V.connect(t) : V.connect(this.audioContext.destination);
|
|
892
892
|
const R = Math.max(l, this.audioContext.currentTime);
|
|
893
893
|
Q.start(R);
|
|
894
|
-
} catch (
|
|
895
|
-
console.warn("Buffer metronome playback failed:",
|
|
894
|
+
} catch (d) {
|
|
895
|
+
console.warn("Buffer metronome playback failed:", d);
|
|
896
896
|
}
|
|
897
897
|
}
|
|
898
898
|
/**
|
|
@@ -914,12 +914,12 @@ class Nl {
|
|
|
914
914
|
const [l, U] = await Promise.all([
|
|
915
915
|
fetch(pU),
|
|
916
916
|
fetch(YU)
|
|
917
|
-
]), [F,
|
|
917
|
+
]), [F, d] = await Promise.all([
|
|
918
918
|
l.arrayBuffer(),
|
|
919
919
|
U.arrayBuffer()
|
|
920
920
|
]), [Q, V] = await Promise.all([
|
|
921
921
|
this.audioContext.decodeAudioData(F),
|
|
922
|
-
this.audioContext.decodeAudioData(
|
|
922
|
+
this.audioContext.decodeAudioData(d)
|
|
923
923
|
]);
|
|
924
924
|
this.regularTickBuffer = Q, this.accentTickBuffer = V;
|
|
925
925
|
return;
|
|
@@ -1012,13 +1012,13 @@ class pl {
|
|
|
1012
1012
|
* @param {number} duration - Note duration in seconds
|
|
1013
1013
|
* @returns {string} Event ID for cancellation
|
|
1014
1014
|
*/
|
|
1015
|
-
playNote(l, U, F,
|
|
1015
|
+
playNote(l, U, F, d) {
|
|
1016
1016
|
this._validateActive();
|
|
1017
1017
|
const Q = this.engine.audioContext.currentTime, V = `${this.partId}_${l}_${U}_${Date.now()}`;
|
|
1018
|
-
let t = l, R =
|
|
1018
|
+
let t = l, R = d;
|
|
1019
1019
|
if (l < Q) {
|
|
1020
1020
|
const c = Q - l;
|
|
1021
|
-
t = Q, R = Math.max(0,
|
|
1021
|
+
t = Q, R = Math.max(0, d - c);
|
|
1022
1022
|
}
|
|
1023
1023
|
if (R <= 0)
|
|
1024
1024
|
return V;
|
|
@@ -1040,11 +1040,11 @@ class pl {
|
|
|
1040
1040
|
*/
|
|
1041
1041
|
playPreviewNote(l, U = {}) {
|
|
1042
1042
|
this._validateActive();
|
|
1043
|
-
const F = U.startTime ?? this.engine.audioContext.currentTime + 0.01,
|
|
1043
|
+
const F = U.startTime ?? this.engine.audioContext.currentTime + 0.01, d = U.duration ?? 0.5, Q = U.velocity ?? 100;
|
|
1044
1044
|
let V = null;
|
|
1045
|
-
U.instrument !== void 0 && (V = this.getInstrument(), this.setInstrument(U.instrument)), this.playNote(F, l, Q,
|
|
1045
|
+
U.instrument !== void 0 && (V = this.getInstrument(), this.setInstrument(U.instrument)), this.playNote(F, l, Q, d), V !== null && setTimeout(() => {
|
|
1046
1046
|
this.isDestroyed || this.setInstrument(V);
|
|
1047
|
-
}, (
|
|
1047
|
+
}, (d + 0.1) * 1e3);
|
|
1048
1048
|
}
|
|
1049
1049
|
/**
|
|
1050
1050
|
* Stop all notes on this channel
|
|
@@ -1288,7 +1288,7 @@ const Al = {
|
|
|
1288
1288
|
helicopter: 125,
|
|
1289
1289
|
applause: 126,
|
|
1290
1290
|
gunshot: 127
|
|
1291
|
-
}, yU = Object.entries(Al).reduce((
|
|
1291
|
+
}, yU = Object.entries(Al).reduce((Z, [l, U]) => (Z[U] = l, Z), {});
|
|
1292
1292
|
class EU {
|
|
1293
1293
|
/**
|
|
1294
1294
|
* Map common instrument names to MIDI program numbers
|
|
@@ -1320,8 +1320,8 @@ class EU {
|
|
|
1320
1320
|
}
|
|
1321
1321
|
}
|
|
1322
1322
|
class kU extends pl {
|
|
1323
|
-
constructor(l, U, F,
|
|
1324
|
-
super(l, U,
|
|
1323
|
+
constructor(l, U, F, d = {}) {
|
|
1324
|
+
super(l, U, d), this.midiChannel = F, this.currentVolume = d.initialVolume || 1, this.currentInstrument = d.instrument || "piano", this.outputGain = null, this._setupOutputNode(), this.setVolume(this.currentVolume), d.instrument && this.setInstrument(d.instrument);
|
|
1325
1325
|
}
|
|
1326
1326
|
getOutputNode() {
|
|
1327
1327
|
return this.outputGain;
|
|
@@ -1335,8 +1335,8 @@ class kU extends pl {
|
|
|
1335
1335
|
_actualNoteOn(l, U) {
|
|
1336
1336
|
const F = this.engine._getSynthesizer();
|
|
1337
1337
|
if (F && F.noteOn) {
|
|
1338
|
-
const
|
|
1339
|
-
F.noteOn(this.midiChannel, l,
|
|
1338
|
+
const d = Math.round(U * this.currentVolume);
|
|
1339
|
+
F.noteOn(this.midiChannel, l, d);
|
|
1340
1340
|
}
|
|
1341
1341
|
}
|
|
1342
1342
|
/**
|
|
@@ -1388,7 +1388,7 @@ class kU extends pl {
|
|
|
1388
1388
|
* @param {number} duration - Note duration in seconds
|
|
1389
1389
|
* @returns {string} Event ID for compatibility
|
|
1390
1390
|
*/
|
|
1391
|
-
playNote(l, U, F,
|
|
1391
|
+
playNote(l, U, F, d) {
|
|
1392
1392
|
this._validateActive();
|
|
1393
1393
|
const Q = `${this.partId}_${l}_${U}_${Date.now()}`, V = this.engine._getSynthesizer();
|
|
1394
1394
|
if (V && V.post) {
|
|
@@ -1413,13 +1413,13 @@ class kU extends pl {
|
|
|
1413
1413
|
channelOffset: 0,
|
|
1414
1414
|
force: !1,
|
|
1415
1415
|
options: {
|
|
1416
|
-
time: l +
|
|
1416
|
+
time: l + d
|
|
1417
1417
|
// Precise note-off timing!
|
|
1418
1418
|
}
|
|
1419
1419
|
}
|
|
1420
1420
|
});
|
|
1421
1421
|
} else
|
|
1422
|
-
return super.playNote(l, U, F,
|
|
1422
|
+
return super.playNote(l, U, F, d);
|
|
1423
1423
|
return Q;
|
|
1424
1424
|
}
|
|
1425
1425
|
/**
|
|
@@ -1475,7 +1475,7 @@ class rU extends Nl {
|
|
|
1475
1475
|
this._emitProgress("loading-soundfont", "Soundfont provided"), F = l;
|
|
1476
1476
|
else
|
|
1477
1477
|
throw new Error("Invalid soundfont data type. Expected string path or ArrayBuffer.");
|
|
1478
|
-
this._emitProgress("loading-worklet", "Loading audio worklet processor..."), await this._loadAudioWorkletSafely(), console.log("AudioWorklet loaded. Note: Worklet processor may persist across page reloads."), this._emitProgress("creating-synth", "Setting up audio channels..."), this._setupIndividualOutputs(), this.dummyTarget = this.audioContext.createGain(), await new Promise((
|
|
1478
|
+
this._emitProgress("loading-worklet", "Loading audio worklet processor..."), await this._loadAudioWorkletSafely(), console.log("AudioWorklet loaded. Note: Worklet processor may persist across page reloads."), this._emitProgress("creating-synth", "Setting up audio channels..."), this._setupIndividualOutputs(), this.dummyTarget = this.audioContext.createGain(), await new Promise((d) => setTimeout(d, 50)), this._emitProgress("creating-synth", "Initializing synthesizer..."), this.synthesizer = new U(this.audioContext), this._emitProgress("loading-soundbank", "Loading soundbank into synthesizer..."), await this.synthesizer.soundBankManager.addSoundBank(F, "main"), await this.synthesizer.isReady, this._emitProgress("finalizing", "Finalizing audio setup..."), this._connectIndividualOutputs(), this._initializeMetronomeChannel(), this._emitProgress("ready", "Audio engine ready"), this.isInitialized = !0;
|
|
1479
1479
|
}
|
|
1480
1480
|
createChannel(l, U = {}) {
|
|
1481
1481
|
if (this._validateInitialized(), this.partToMidiChannel.has(l))
|
|
@@ -1484,13 +1484,13 @@ class rU extends Nl {
|
|
|
1484
1484
|
if (F >= 15)
|
|
1485
1485
|
throw new Error("Maximum number of musical part channels (15) exceeded. Channel 15 is reserved for metronome.");
|
|
1486
1486
|
this.channelCounter++, this.partToMidiChannel.set(l, F), this.midiChannelToPart.set(F, l);
|
|
1487
|
-
const
|
|
1487
|
+
const d = new kU(
|
|
1488
1488
|
this,
|
|
1489
1489
|
l,
|
|
1490
1490
|
F,
|
|
1491
1491
|
U
|
|
1492
1492
|
);
|
|
1493
|
-
return this._registerChannel(
|
|
1493
|
+
return this._registerChannel(d), U.instrument && d.setInstrument(U.instrument), d;
|
|
1494
1494
|
}
|
|
1495
1495
|
allSoundsOff() {
|
|
1496
1496
|
if (this.synthesizer) {
|
|
@@ -1588,8 +1588,8 @@ class rU extends Nl {
|
|
|
1588
1588
|
const U = await fetch(l);
|
|
1589
1589
|
if (!U.ok)
|
|
1590
1590
|
throw new Error(`Failed to load soundfont: ${U.status} ${U.statusText}`);
|
|
1591
|
-
const F = U.headers.get("content-length"),
|
|
1592
|
-
if (!
|
|
1591
|
+
const F = U.headers.get("content-length"), d = F ? parseInt(F, 10) : null;
|
|
1592
|
+
if (!d || !U.body)
|
|
1593
1593
|
return await U.arrayBuffer();
|
|
1594
1594
|
const Q = U.body.getReader();
|
|
1595
1595
|
let V = 0;
|
|
@@ -1598,10 +1598,10 @@ class rU extends Nl {
|
|
|
1598
1598
|
const { done: n, value: m } = await Q.read();
|
|
1599
1599
|
if (n) break;
|
|
1600
1600
|
t.push(m), V += m.length;
|
|
1601
|
-
const W = V /
|
|
1601
|
+
const W = V / d, c = Math.round(W * 100);
|
|
1602
1602
|
this._emitProgress(
|
|
1603
1603
|
"loading-soundfont",
|
|
1604
|
-
`Downloading soundfont: ${c}% (${Math.round(V / 1024)} KB / ${Math.round(
|
|
1604
|
+
`Downloading soundfont: ${c}% (${Math.round(V / 1024)} KB / ${Math.round(d / 1024)} KB)`,
|
|
1605
1605
|
W
|
|
1606
1606
|
);
|
|
1607
1607
|
}
|
|
@@ -1624,7 +1624,7 @@ class rU extends Nl {
|
|
|
1624
1624
|
if (console.warn(`AudioWorklet loading failed (attempt ${l}/5):`, U.message), l === 5)
|
|
1625
1625
|
throw new Error(`AudioWorklet failed after 5 attempts: ${U.message}`);
|
|
1626
1626
|
const F = l * 500;
|
|
1627
|
-
await new Promise((
|
|
1627
|
+
await new Promise((d) => setTimeout(d, F));
|
|
1628
1628
|
}
|
|
1629
1629
|
}
|
|
1630
1630
|
/**
|
|
@@ -1653,8 +1653,8 @@ class rU extends Nl {
|
|
|
1653
1653
|
*/
|
|
1654
1654
|
async playMetronomeTick(l, U, F) {
|
|
1655
1655
|
try {
|
|
1656
|
-
const
|
|
1657
|
-
if (!
|
|
1656
|
+
const d = this.getMetronomeChannel(), Q = this._getSynthesizer();
|
|
1657
|
+
if (!d || !Q)
|
|
1658
1658
|
return super.playMetronomeTick(l, U, F);
|
|
1659
1659
|
const V = 15, t = U ? 86 : 60, R = Math.round(Math.min(127, Math.max(0, F * (U ? 127 : 100)))), a = this.audioContext.currentTime, n = Math.max(l, a), m = n - a;
|
|
1660
1660
|
Q.post ? (Q.post({
|
|
@@ -1688,8 +1688,8 @@ class rU extends Nl {
|
|
|
1688
1688
|
Q.noteOff && Q.noteOff(V, t);
|
|
1689
1689
|
}, 100);
|
|
1690
1690
|
}, m * 1e3);
|
|
1691
|
-
} catch (
|
|
1692
|
-
return console.warn("MIDI metronome failed, falling back to buffers:",
|
|
1691
|
+
} catch (d) {
|
|
1692
|
+
return console.warn("MIDI metronome failed, falling back to buffers:", d), super.playMetronomeTick(l, U, F);
|
|
1693
1693
|
}
|
|
1694
1694
|
}
|
|
1695
1695
|
/**
|
|
@@ -1775,12 +1775,8 @@ class LU {
|
|
|
1775
1775
|
for (const F of l) {
|
|
1776
1776
|
if (!F.name || !F.url)
|
|
1777
1777
|
continue;
|
|
1778
|
-
const
|
|
1779
|
-
|
|
1780
|
-
const t = parseInt(Q.prog, 10);
|
|
1781
|
-
t !== 0 && (V.instrument = t);
|
|
1782
|
-
}
|
|
1783
|
-
V.channel !== void 0 && (U[Z] = V);
|
|
1778
|
+
const d = F.name.toLowerCase(), Q = this._parseUrlParams(F.url), V = {};
|
|
1779
|
+
Q.track !== void 0 && (V.channel = parseInt(Q.track, 10)), Q.prog !== void 0 && (V.instrument = parseInt(Q.prog, 10)), V.channel !== void 0 && (U[d] = V);
|
|
1784
1780
|
}
|
|
1785
1781
|
return U;
|
|
1786
1782
|
}
|
|
@@ -1794,8 +1790,8 @@ class LU {
|
|
|
1794
1790
|
const U = {}, F = l.indexOf("?");
|
|
1795
1791
|
if (F === -1)
|
|
1796
1792
|
return U;
|
|
1797
|
-
const
|
|
1798
|
-
for (const Q of
|
|
1793
|
+
const d = l.substring(F + 1).split("&");
|
|
1794
|
+
for (const Q of d) {
|
|
1799
1795
|
const [V, t] = Q.split("=");
|
|
1800
1796
|
V && t !== void 0 && (U[V] = t);
|
|
1801
1797
|
}
|
|
@@ -1809,8 +1805,8 @@ class LU {
|
|
|
1809
1805
|
const U = new Uint8Array(l);
|
|
1810
1806
|
if (!(U[0] === 77 && U[1] === 84 && U[2] === 104 && U[3] === 100))
|
|
1811
1807
|
throw new Error("Not a valid MIDI file");
|
|
1812
|
-
const F = this._bytesToNumber(U.slice(4, 8)),
|
|
1813
|
-
format:
|
|
1808
|
+
const F = this._bytesToNumber(U.slice(4, 8)), d = this._bytesToNumber(U.slice(8, 10)), Q = this._bytesToNumber(U.slice(10, 12)), V = this._bytesToNumber(U.slice(12, 14)), t = V & 32768 ? null : V, R = {
|
|
1809
|
+
format: d,
|
|
1814
1810
|
ticksPerBeat: t,
|
|
1815
1811
|
tracks: [],
|
|
1816
1812
|
duration: 0
|
|
@@ -1836,13 +1832,13 @@ class LU {
|
|
|
1836
1832
|
events: [],
|
|
1837
1833
|
duration: 0
|
|
1838
1834
|
};
|
|
1839
|
-
let F = 0,
|
|
1835
|
+
let F = 0, d = 0, Q = null;
|
|
1840
1836
|
for (; F < l.length; ) {
|
|
1841
1837
|
let V = 0, t = 0;
|
|
1842
1838
|
do
|
|
1843
1839
|
t = l[F++], V = V << 7 | t & 127;
|
|
1844
1840
|
while (t & 128);
|
|
1845
|
-
|
|
1841
|
+
d += V, t = l[F++];
|
|
1846
1842
|
let R = t;
|
|
1847
1843
|
if (t & 128)
|
|
1848
1844
|
Q = R;
|
|
@@ -1863,13 +1859,13 @@ class LU {
|
|
|
1863
1859
|
U.events.push({
|
|
1864
1860
|
type: "text",
|
|
1865
1861
|
text: this._bytesToString(m),
|
|
1866
|
-
tick:
|
|
1862
|
+
tick: d
|
|
1867
1863
|
});
|
|
1868
1864
|
break;
|
|
1869
1865
|
case 5:
|
|
1870
1866
|
U.lyrics.push({
|
|
1871
1867
|
text: this._bytesToString(m),
|
|
1872
|
-
tick:
|
|
1868
|
+
tick: d
|
|
1873
1869
|
});
|
|
1874
1870
|
break;
|
|
1875
1871
|
case 81:
|
|
@@ -1877,7 +1873,7 @@ class LU {
|
|
|
1877
1873
|
U.events.push({
|
|
1878
1874
|
type: "tempo",
|
|
1879
1875
|
bpm: c,
|
|
1880
|
-
tick:
|
|
1876
|
+
tick: d
|
|
1881
1877
|
});
|
|
1882
1878
|
break;
|
|
1883
1879
|
case 88:
|
|
@@ -1885,11 +1881,11 @@ class LU {
|
|
|
1885
1881
|
type: "timeSignature",
|
|
1886
1882
|
numerator: m[0],
|
|
1887
1883
|
denominator: Math.pow(2, m[1]),
|
|
1888
|
-
tick:
|
|
1884
|
+
tick: d
|
|
1889
1885
|
});
|
|
1890
1886
|
break;
|
|
1891
1887
|
case 47:
|
|
1892
|
-
U.duration =
|
|
1888
|
+
U.duration = d;
|
|
1893
1889
|
break;
|
|
1894
1890
|
}
|
|
1895
1891
|
} else if ((R & 240) === 144) {
|
|
@@ -1898,12 +1894,12 @@ class LU {
|
|
|
1898
1894
|
type: "noteOn",
|
|
1899
1895
|
noteNumber: n,
|
|
1900
1896
|
velocity: m,
|
|
1901
|
-
tick:
|
|
1897
|
+
tick: d,
|
|
1902
1898
|
channel: a
|
|
1903
1899
|
}) : U.notes.push({
|
|
1904
1900
|
type: "noteOff",
|
|
1905
1901
|
noteNumber: n,
|
|
1906
|
-
tick:
|
|
1902
|
+
tick: d,
|
|
1907
1903
|
channel: a
|
|
1908
1904
|
});
|
|
1909
1905
|
} else if ((R & 240) === 128) {
|
|
@@ -1911,7 +1907,7 @@ class LU {
|
|
|
1911
1907
|
l[F++], U.notes.push({
|
|
1912
1908
|
type: "noteOff",
|
|
1913
1909
|
noteNumber: n,
|
|
1914
|
-
tick:
|
|
1910
|
+
tick: d,
|
|
1915
1911
|
channel: a
|
|
1916
1912
|
});
|
|
1917
1913
|
} else if (R === 240 || R === 247) {
|
|
@@ -1924,7 +1920,7 @@ class LU {
|
|
|
1924
1920
|
controllerNumber: n,
|
|
1925
1921
|
value: m,
|
|
1926
1922
|
channel: a,
|
|
1927
|
-
tick:
|
|
1923
|
+
tick: d
|
|
1928
1924
|
});
|
|
1929
1925
|
} else if ((R & 240) === 192) {
|
|
1930
1926
|
const a = R & 15, n = l[F++];
|
|
@@ -1932,7 +1928,7 @@ class LU {
|
|
|
1932
1928
|
type: "programChange",
|
|
1933
1929
|
programNumber: n,
|
|
1934
1930
|
channel: a,
|
|
1935
|
-
tick:
|
|
1931
|
+
tick: d
|
|
1936
1932
|
});
|
|
1937
1933
|
} else if ((R & 240) === 208) {
|
|
1938
1934
|
const a = R & 15, n = l[F++];
|
|
@@ -1940,7 +1936,7 @@ class LU {
|
|
|
1940
1936
|
type: "channelAftertouch",
|
|
1941
1937
|
pressure: n,
|
|
1942
1938
|
channel: a,
|
|
1943
|
-
tick:
|
|
1939
|
+
tick: d
|
|
1944
1940
|
});
|
|
1945
1941
|
} else if ((R & 240) === 224) {
|
|
1946
1942
|
const a = R & 15, n = l[F++], m = (l[F++] << 7 | n) - 8192;
|
|
@@ -1948,7 +1944,7 @@ class LU {
|
|
|
1948
1944
|
type: "pitchBend",
|
|
1949
1945
|
value: m,
|
|
1950
1946
|
channel: a,
|
|
1951
|
-
tick:
|
|
1947
|
+
tick: d
|
|
1952
1948
|
});
|
|
1953
1949
|
} else if ((R & 240) === 160) {
|
|
1954
1950
|
const a = R & 15, n = l[F++], m = l[F++];
|
|
@@ -1957,7 +1953,7 @@ class LU {
|
|
|
1957
1953
|
noteNumber: n,
|
|
1958
1954
|
pressure: m,
|
|
1959
1955
|
channel: a,
|
|
1960
|
-
tick:
|
|
1956
|
+
tick: d
|
|
1961
1957
|
});
|
|
1962
1958
|
} else
|
|
1963
1959
|
console.warn(`Unknown event type: ${R.toString(16)} at position ${F - 1}`), F++;
|
|
@@ -1976,7 +1972,7 @@ class LU {
|
|
|
1976
1972
|
format: l.format,
|
|
1977
1973
|
ticksPerBeat: l.ticksPerBeat
|
|
1978
1974
|
};
|
|
1979
|
-
l.tracks.forEach((F,
|
|
1975
|
+
l.tracks.forEach((F, d) => {
|
|
1980
1976
|
if (F.name && !U.title && (U.title = F.name), F.events.filter((Q) => Q.type === "text").forEach((Q) => {
|
|
1981
1977
|
const V = Q.text.toLowerCase();
|
|
1982
1978
|
(V.includes("compos") || V.includes("by")) && !U.composer && (U.composer = Q.text);
|
|
@@ -1985,7 +1981,7 @@ class LU {
|
|
|
1985
1981
|
for (const V of this.partNames)
|
|
1986
1982
|
if (Q.includes(V)) {
|
|
1987
1983
|
U.partNames.push({
|
|
1988
|
-
index:
|
|
1984
|
+
index: d,
|
|
1989
1985
|
name: F.name
|
|
1990
1986
|
});
|
|
1991
1987
|
break;
|
|
@@ -2007,15 +2003,15 @@ class LU {
|
|
|
2007
2003
|
(m.type === "timeSignature" || m.type === "tempo") && F.push(m);
|
|
2008
2004
|
});
|
|
2009
2005
|
}), F.sort((n, m) => n.tick - m.tick);
|
|
2010
|
-
let
|
|
2006
|
+
let d = 0;
|
|
2011
2007
|
l.tracks.forEach((n) => {
|
|
2012
2008
|
n.notes && n.notes.forEach((m) => {
|
|
2013
|
-
m.type === "noteOff" && m.tick >
|
|
2009
|
+
m.type === "noteOff" && m.tick > d && (d = m.tick);
|
|
2014
2010
|
});
|
|
2015
|
-
}),
|
|
2011
|
+
}), d === 0 && (d = U * 8);
|
|
2016
2012
|
const Q = [], V = F.filter((n) => n.type === "timeSignature").sort((n, m) => n.tick - m.tick);
|
|
2017
2013
|
let t = { numerator: 4, denominator: 4 }, R = 0, a = 0;
|
|
2018
|
-
for (; R <
|
|
2014
|
+
for (; R < d; ) {
|
|
2019
2015
|
for (; a < V.length && V[a].tick <= R; )
|
|
2020
2016
|
t = V[a], a++;
|
|
2021
2017
|
let n;
|
|
@@ -2039,14 +2035,14 @@ class LU {
|
|
|
2039
2035
|
_extractParts(l) {
|
|
2040
2036
|
const U = {}, F = l.ticksPerBeat;
|
|
2041
2037
|
if (this.metadataOverrides.parts)
|
|
2042
|
-
for (const [
|
|
2038
|
+
for (const [d, Q] of Object.entries(this.metadataOverrides.parts)) {
|
|
2043
2039
|
if (Q.channel !== void 0 && Q.channel !== null) {
|
|
2044
2040
|
if (Q.channel === 15) {
|
|
2045
|
-
console.error(`Part "${
|
|
2041
|
+
console.error(`Part "${d}" uses channel 15 which is reserved for metronome. Skipping.`);
|
|
2046
2042
|
continue;
|
|
2047
2043
|
}
|
|
2048
|
-
if (Q.channel === 9 && console.warn(`Part "${
|
|
2049
|
-
console.error(`Part "${
|
|
2044
|
+
if (Q.channel === 9 && console.warn(`Part "${d}" uses channel 9 (drums/percussion). This may not be appropriate for vocal parts.`), Q.channel < 0 || Q.channel > 15) {
|
|
2045
|
+
console.error(`Part "${d}" has invalid channel ${Q.channel}. MIDI channels must be 0-15. Skipping.`);
|
|
2050
2046
|
continue;
|
|
2051
2047
|
}
|
|
2052
2048
|
}
|
|
@@ -2055,7 +2051,7 @@ class LU {
|
|
|
2055
2051
|
let V;
|
|
2056
2052
|
if (Q.channel !== void 0 && Q.channel !== null) {
|
|
2057
2053
|
if (V = this._extractPartDataByChannel(Q.channel, l, F), !V || V.notes.length === 0) {
|
|
2058
|
-
console.warn(`Part "${
|
|
2054
|
+
console.warn(`Part "${d}" specified channel ${Q.channel} but no notes found on that channel. Skipping.`);
|
|
2059
2055
|
continue;
|
|
2060
2056
|
}
|
|
2061
2057
|
} else if (Q.trackIndex !== void 0 && Q.trackIndex !== null) {
|
|
@@ -2064,7 +2060,7 @@ class LU {
|
|
|
2064
2060
|
const R = l.tracks[t];
|
|
2065
2061
|
V = this._extractPartDataFromTrack(R, t, l, F);
|
|
2066
2062
|
} else {
|
|
2067
|
-
console.warn(`Part "${
|
|
2063
|
+
console.warn(`Part "${d}" specified trackIndex ${t} but track not found. Skipping.`);
|
|
2068
2064
|
continue;
|
|
2069
2065
|
}
|
|
2070
2066
|
} else if (Q.trackName) {
|
|
@@ -2073,18 +2069,18 @@ class LU {
|
|
|
2073
2069
|
const R = l.tracks[t];
|
|
2074
2070
|
V = this._extractPartDataFromTrack(R, t, l, F);
|
|
2075
2071
|
} else {
|
|
2076
|
-
console.warn(`Part "${
|
|
2072
|
+
console.warn(`Part "${d}" specified trackName "${Q.trackName}" but track not found. Skipping.`);
|
|
2077
2073
|
continue;
|
|
2078
2074
|
}
|
|
2079
2075
|
}
|
|
2080
|
-
V && (Q.instrument !== void 0 && Q.instrument !== null && (V.defaultInstrument = this._resolveInstrument(Q.instrument)), U[
|
|
2076
|
+
V && (Q.instrument !== void 0 && Q.instrument !== null && (V.defaultInstrument = this._resolveInstrument(Q.instrument), V.programChanges = []), U[d] = V);
|
|
2081
2077
|
}
|
|
2082
2078
|
else
|
|
2083
|
-
l.tracks.forEach((
|
|
2084
|
-
if (!
|
|
2079
|
+
l.tracks.forEach((d, Q) => {
|
|
2080
|
+
if (!d.notes.length) return;
|
|
2085
2081
|
let V = null;
|
|
2086
|
-
if (
|
|
2087
|
-
const a =
|
|
2082
|
+
if (d.name) {
|
|
2083
|
+
const a = d.name.toLowerCase();
|
|
2088
2084
|
for (const n of this.partNames)
|
|
2089
2085
|
if (n.length === 1) {
|
|
2090
2086
|
if (a === n) {
|
|
@@ -2096,11 +2092,11 @@ class LU {
|
|
|
2096
2092
|
break;
|
|
2097
2093
|
}
|
|
2098
2094
|
}
|
|
2099
|
-
V || (V =
|
|
2095
|
+
V || (V = d.name || `Track ${Q + 1}`), V === "s" && (V = "soprano"), V === "a" && (V = "alto"), V === "t" && (V = "tenor"), V === "b" && (V = "bass");
|
|
2100
2096
|
let t = V, R = 2;
|
|
2101
2097
|
for (; U[t]; )
|
|
2102
2098
|
t = `${V} ${R}`, R++;
|
|
2103
|
-
V = t, U[V] = this._extractPartDataFromTrack(
|
|
2099
|
+
V = t, U[V] = this._extractPartDataFromTrack(d, Q, l, F);
|
|
2104
2100
|
});
|
|
2105
2101
|
this.parsedData.parts = U;
|
|
2106
2102
|
}
|
|
@@ -2109,7 +2105,7 @@ class LU {
|
|
|
2109
2105
|
* @private
|
|
2110
2106
|
*/
|
|
2111
2107
|
_extractPartDataByChannel(l, U, F) {
|
|
2112
|
-
const
|
|
2108
|
+
const d = [], Q = [], V = [], t = [];
|
|
2113
2109
|
U.tracks.forEach((a, n) => {
|
|
2114
2110
|
const m = {};
|
|
2115
2111
|
a.notes.forEach((W) => {
|
|
@@ -2121,7 +2117,7 @@ class LU {
|
|
|
2121
2117
|
};
|
|
2122
2118
|
else if (W.type === "noteOff" && m[W.noteNumber]) {
|
|
2123
2119
|
const c = m[W.noteNumber], s = W.tick - c.tick;
|
|
2124
|
-
|
|
2120
|
+
d.push({
|
|
2125
2121
|
pitch: W.noteNumber,
|
|
2126
2122
|
name: this._midiNoteToName(W.noteNumber),
|
|
2127
2123
|
startTick: c.tick,
|
|
@@ -2149,10 +2145,10 @@ class LU {
|
|
|
2149
2145
|
sourceTrackIndex: n
|
|
2150
2146
|
});
|
|
2151
2147
|
}), a.notes.some((W) => W.channel === l) && t.push(n);
|
|
2152
|
-
}),
|
|
2148
|
+
}), d.sort((a, n) => a.startTick - n.startTick), Q.sort((a, n) => a.tick - n.tick), V.sort((a, n) => a.tick - n.tick);
|
|
2153
2149
|
const R = V.length > 0 ? V[0].programNumber : 0;
|
|
2154
2150
|
return {
|
|
2155
|
-
notes:
|
|
2151
|
+
notes: d,
|
|
2156
2152
|
lyrics: Q,
|
|
2157
2153
|
channel: l,
|
|
2158
2154
|
trackIndices: t,
|
|
@@ -2165,7 +2161,7 @@ class LU {
|
|
|
2165
2161
|
* Extract part data from a MIDI track
|
|
2166
2162
|
* @private
|
|
2167
2163
|
*/
|
|
2168
|
-
_extractPartDataFromTrack(l, U, F,
|
|
2164
|
+
_extractPartDataFromTrack(l, U, F, d) {
|
|
2169
2165
|
const Q = [], V = {};
|
|
2170
2166
|
l.notes.forEach((n) => {
|
|
2171
2167
|
if (n.type === "noteOn")
|
|
@@ -2194,7 +2190,7 @@ class LU {
|
|
|
2194
2190
|
const t = l.lyrics.map((n) => ({
|
|
2195
2191
|
text: n.text,
|
|
2196
2192
|
tick: n.tick,
|
|
2197
|
-
time: n.tick /
|
|
2193
|
+
time: n.tick / d
|
|
2198
2194
|
// Time in quarter notes
|
|
2199
2195
|
}));
|
|
2200
2196
|
Q.sort((n, m) => n.startTick - m.startTick);
|
|
@@ -2266,10 +2262,10 @@ class LU {
|
|
|
2266
2262
|
* @private
|
|
2267
2263
|
*/
|
|
2268
2264
|
_readVariableLengthValue(l, U) {
|
|
2269
|
-
let F = 0,
|
|
2265
|
+
let F = 0, d, Q = 0;
|
|
2270
2266
|
do
|
|
2271
|
-
|
|
2272
|
-
while (
|
|
2267
|
+
d = l[U + Q++], F = F << 7 | d & 127;
|
|
2268
|
+
while (d & 128);
|
|
2273
2269
|
return { value: F, bytesRead: Q };
|
|
2274
2270
|
}
|
|
2275
2271
|
/**
|
|
@@ -2277,14 +2273,14 @@ class LU {
|
|
|
2277
2273
|
* @private
|
|
2278
2274
|
*/
|
|
2279
2275
|
_ticksToTime(l, U) {
|
|
2280
|
-
const F = U.ticksPerBeat || 480,
|
|
2276
|
+
const F = U.ticksPerBeat || 480, d = [];
|
|
2281
2277
|
U.tracks.forEach((R) => {
|
|
2282
2278
|
R.events.forEach((a) => {
|
|
2283
|
-
a.type === "tempo" &&
|
|
2279
|
+
a.type === "tempo" && d.push(a);
|
|
2284
2280
|
});
|
|
2285
|
-
}),
|
|
2281
|
+
}), d.sort((R, a) => R.tick - a.tick);
|
|
2286
2282
|
let Q = 0, V = 0, t = 120;
|
|
2287
|
-
for (const R of
|
|
2283
|
+
for (const R of d) {
|
|
2288
2284
|
if (R.tick > l) break;
|
|
2289
2285
|
if (R.tick > V) {
|
|
2290
2286
|
const a = (R.tick - V) / F * (60 / t);
|
|
@@ -2323,14 +2319,14 @@ class CU {
|
|
|
2323
2319
|
* @returns {Array} Bar order with bar numbers and repeat counts
|
|
2324
2320
|
*/
|
|
2325
2321
|
generateBarOrder(l, U) {
|
|
2326
|
-
const F = [],
|
|
2322
|
+
const F = [], d = {};
|
|
2327
2323
|
for (const Q of U) {
|
|
2328
2324
|
const V = l[Q.section];
|
|
2329
2325
|
if (!V)
|
|
2330
2326
|
throw new Error(`Invalid section index: ${Q.section}`);
|
|
2331
2327
|
const t = Q.section;
|
|
2332
|
-
|
|
2333
|
-
const R =
|
|
2328
|
+
d[t] || (d[t] = 0), d[t]++;
|
|
2329
|
+
const R = d[t], a = Q.from !== void 0 ? Q.from : this._getSectionStartBar(l, Q.section), n = Q.to !== void 0 ? Q.to : V.to, m = Q.as || 1;
|
|
2334
2330
|
for (let W = a; W <= n; W++)
|
|
2335
2331
|
this._shouldPlayBar(V, W, m) && F.push({
|
|
2336
2332
|
barNumber: W,
|
|
@@ -2349,25 +2345,25 @@ class CU {
|
|
|
2349
2345
|
*/
|
|
2350
2346
|
generateBarOrderFromLegacyBars(l, U) {
|
|
2351
2347
|
const F = [];
|
|
2352
|
-
let
|
|
2348
|
+
let d = 1, Q = 0, V;
|
|
2353
2349
|
for (const t of l) {
|
|
2354
|
-
t.from !== void 0 && (
|
|
2350
|
+
t.from !== void 0 && (d = t.from === -1 ? 0 : t.from, Q = 0), t.timeSig !== void 0 && (V = t.timeSig);
|
|
2355
2351
|
const R = t.repeat || 1;
|
|
2356
2352
|
let a = t.beats;
|
|
2357
2353
|
for (; a > 0; ) {
|
|
2358
|
-
const n = (V !== void 0 ? V : this._getBeatsPerBar(
|
|
2354
|
+
const n = (V !== void 0 ? V : this._getBeatsPerBar(d, U)) - Q;
|
|
2359
2355
|
a >= n ? (F.push({
|
|
2360
|
-
barNumber:
|
|
2356
|
+
barNumber: d,
|
|
2361
2357
|
repeat: R,
|
|
2362
2358
|
sectionIndex: 0,
|
|
2363
2359
|
// Legacy format doesn't have sections
|
|
2364
2360
|
voltaTime: 1
|
|
2365
2361
|
// Legacy format doesn't have voltas
|
|
2366
|
-
}), a -= n, Q = 0,
|
|
2362
|
+
}), a -= n, Q = 0, d === 0 ? d = 1 : d++) : (Q += a, a = 0);
|
|
2367
2363
|
}
|
|
2368
2364
|
}
|
|
2369
2365
|
return Q > 0 && F.push({
|
|
2370
|
-
barNumber:
|
|
2366
|
+
barNumber: d,
|
|
2371
2367
|
repeat: 1,
|
|
2372
2368
|
sectionIndex: 0,
|
|
2373
2369
|
voltaTime: 1
|
|
@@ -2397,10 +2393,10 @@ class CU {
|
|
|
2397
2393
|
*/
|
|
2398
2394
|
_getBeatsPerBar(l, U) {
|
|
2399
2395
|
const F = U.length > 0 && U[0].sig && U[0].sig[0] <= 2;
|
|
2400
|
-
let
|
|
2401
|
-
if (F ?
|
|
2396
|
+
let d;
|
|
2397
|
+
if (F ? d = l : d = l - 1, d < 0 || d >= U.length)
|
|
2402
2398
|
return 4;
|
|
2403
|
-
const Q = U[
|
|
2399
|
+
const Q = U[d];
|
|
2404
2400
|
return Q.sig ? Q.sig[0] : 4;
|
|
2405
2401
|
}
|
|
2406
2402
|
/**
|
|
@@ -2411,18 +2407,18 @@ class CU {
|
|
|
2411
2407
|
* @returns {Array} Beat table with time, repeat, bar, and beat information
|
|
2412
2408
|
*/
|
|
2413
2409
|
generateBeatTable(l, U) {
|
|
2414
|
-
const F = [],
|
|
2410
|
+
const F = [], d = {};
|
|
2415
2411
|
let Q = 0, V = 0;
|
|
2416
2412
|
const t = [...U];
|
|
2417
2413
|
for (; V < l.length && Q < t.length; ) {
|
|
2418
2414
|
const R = l[V], a = R.barNumber;
|
|
2419
|
-
if (
|
|
2415
|
+
if (d[a] === void 0) {
|
|
2420
2416
|
const c = t[Q];
|
|
2421
2417
|
if (!c || !c.sig)
|
|
2422
2418
|
throw new Error(`Invalid MIDI bar structure at index ${Q}`);
|
|
2423
|
-
|
|
2419
|
+
d[a] = c.sig[0];
|
|
2424
2420
|
}
|
|
2425
|
-
const n =
|
|
2421
|
+
const n = d[a];
|
|
2426
2422
|
let m = t[Q], W = m.sig[0];
|
|
2427
2423
|
for (; W < n && Q + 1 < t.length; ) {
|
|
2428
2424
|
const c = t[Q + 1], s = [
|
|
@@ -2460,8 +2456,8 @@ class CU {
|
|
|
2460
2456
|
}
|
|
2461
2457
|
let n = R ? R.time + a : 0;
|
|
2462
2458
|
for (; V < l.length; ) {
|
|
2463
|
-
const m = l[V], W = m.barNumber, c =
|
|
2464
|
-
|
|
2459
|
+
const m = l[V], W = m.barNumber, c = d[W] !== void 0 ? d[W] : 4;
|
|
2460
|
+
d[W] === void 0 && (d[W] = c);
|
|
2465
2461
|
const s = [];
|
|
2466
2462
|
for (let J = 0; J < c; J++)
|
|
2467
2463
|
s.push(n), n += a;
|
|
@@ -2479,18 +2475,18 @@ class CU {
|
|
|
2479
2475
|
* Generate beat entries for a single bar
|
|
2480
2476
|
* @private
|
|
2481
2477
|
*/
|
|
2482
|
-
_generateBeatsForBar(l, U, F,
|
|
2478
|
+
_generateBeatsForBar(l, U, F, d) {
|
|
2483
2479
|
const { beats: Q } = F;
|
|
2484
2480
|
if (!Q || !Array.isArray(Q))
|
|
2485
2481
|
throw new Error(`Invalid MIDI bar: missing beats array. Got: ${JSON.stringify(F)}`);
|
|
2486
|
-
const V = Q.slice(0,
|
|
2487
|
-
for (let t = 1; t <=
|
|
2482
|
+
const V = Q.slice(0, d);
|
|
2483
|
+
for (let t = 1; t <= d; t++) {
|
|
2488
2484
|
const R = {
|
|
2489
2485
|
time: V[t - 1],
|
|
2490
2486
|
repeat: U.repeat,
|
|
2491
2487
|
bar: U.barNumber,
|
|
2492
2488
|
beat: t,
|
|
2493
|
-
timeSig:
|
|
2489
|
+
timeSig: d
|
|
2494
2490
|
};
|
|
2495
2491
|
l.push(R);
|
|
2496
2492
|
}
|
|
@@ -2509,8 +2505,8 @@ class CU {
|
|
|
2509
2505
|
_shouldPlayBar(l, U, F) {
|
|
2510
2506
|
if (!l.voltas)
|
|
2511
2507
|
return !0;
|
|
2512
|
-
const
|
|
2513
|
-
return
|
|
2508
|
+
const d = l.voltas.indexOf(U);
|
|
2509
|
+
return d === -1 ? !0 : d + 1 === F;
|
|
2514
2510
|
}
|
|
2515
2511
|
}
|
|
2516
2512
|
class Jl {
|
|
@@ -2521,11 +2517,11 @@ class Jl {
|
|
|
2521
2517
|
* @param {Object} instrumentMap - Mapping of part names to instrument configurations
|
|
2522
2518
|
* @param {Object} [structureMetadata] - Optional score structure for beat mapping
|
|
2523
2519
|
*/
|
|
2524
|
-
constructor(l = null, U, F = null,
|
|
2520
|
+
constructor(l = null, U, F = null, d = null) {
|
|
2525
2521
|
if (!U)
|
|
2526
2522
|
throw new Error("Parsed MIDI data is required");
|
|
2527
|
-
this.audioEngine = l, this._audioEngineReady = !!(l && l.isInitialized), this.instrumentMap = F || {}, this.parsedData = U, this._isPlaying = !1, this._currentTime = 0, this._totalDuration = 0, this.playbackSpeed = 1, this.partChannels = /* @__PURE__ */ new Map(), this.partOutputs = /* @__PURE__ */ new Map(), this.playbackStartTime = 0, this.lookAheadTime = 0.05, this.scheduleInterval = null, this.partNotePointers = /* @__PURE__ */ new Map(), this.partProgramPointers = /* @__PURE__ */ new Map(), this.eventBus = Xl(), this.beatMapper = new CU(), this.beats = [], this.structureMetadata =
|
|
2528
|
-
const Q =
|
|
2523
|
+
this.audioEngine = l, this._audioEngineReady = !!(l && l.isInitialized), this.instrumentMap = F || {}, this.parsedData = U, this._isPlaying = !1, this._currentTime = 0, this._totalDuration = 0, this.playbackSpeed = 1, this.partChannels = /* @__PURE__ */ new Map(), this.partOutputs = /* @__PURE__ */ new Map(), this.playbackStartTime = 0, this.lookAheadTime = 0.05, this.scheduleInterval = null, this.partNotePointers = /* @__PURE__ */ new Map(), this.partProgramPointers = /* @__PURE__ */ new Map(), this.eventBus = Xl(), this.beatMapper = new CU(), this.beats = [], this.structureMetadata = d, this._calculateTotalDuration();
|
|
2524
|
+
const Q = d || this._createDefaultStructureMetadata();
|
|
2529
2525
|
this.beats = this.beatMapper.mapBeats(U, Q), this._audioEngineReady && (this._setupPartChannels(), this._resetNotePointers(), this._resetProgramPointers());
|
|
2530
2526
|
}
|
|
2531
2527
|
// ========================================
|
|
@@ -2599,8 +2595,8 @@ class Jl {
|
|
|
2599
2595
|
throw new Error("Playback speed must be greater than 0");
|
|
2600
2596
|
const F = U && this._isPlaying;
|
|
2601
2597
|
F && this.pause();
|
|
2602
|
-
const
|
|
2603
|
-
this.playbackSpeed = l, F ? this.play() : this.playbackStartTime = this.audioEngine.audioContext.currentTime -
|
|
2598
|
+
const d = (this.audioEngine.audioContext.currentTime - this.playbackStartTime) * this.playbackSpeed;
|
|
2599
|
+
this.playbackSpeed = l, F ? this.play() : this.playbackStartTime = this.audioEngine.audioContext.currentTime - d / this.playbackSpeed;
|
|
2604
2600
|
}
|
|
2605
2601
|
/**
|
|
2606
2602
|
* Navigate to a specific bar position
|
|
@@ -2620,7 +2616,7 @@ class Jl {
|
|
|
2620
2616
|
getTimeFromBar(l, U = 0) {
|
|
2621
2617
|
U || (U = 1);
|
|
2622
2618
|
const F = this.beats.find(
|
|
2623
|
-
(
|
|
2619
|
+
(d) => d.bar === l && d.beat === 1 && d.repeat === U
|
|
2624
2620
|
);
|
|
2625
2621
|
return F ? F.time : null;
|
|
2626
2622
|
}
|
|
@@ -2710,9 +2706,9 @@ class Jl {
|
|
|
2710
2706
|
*/
|
|
2711
2707
|
getAllNextNotes(l) {
|
|
2712
2708
|
const U = l ?? this.getCurrentTime(), F = {};
|
|
2713
|
-
for (const [
|
|
2709
|
+
for (const [d, Q] of Object.entries(this.parsedData.parts)) {
|
|
2714
2710
|
const V = Q.notes.find((t) => t.startTime >= U);
|
|
2715
|
-
F[
|
|
2711
|
+
F[d] = V ? {
|
|
2716
2712
|
pitch: V.pitch,
|
|
2717
2713
|
startTime: V.startTime
|
|
2718
2714
|
} : null;
|
|
@@ -2753,10 +2749,10 @@ class Jl {
|
|
|
2753
2749
|
*/
|
|
2754
2750
|
_setupPartChannels() {
|
|
2755
2751
|
Object.keys(this.parsedData.parts).forEach((l) => {
|
|
2756
|
-
const U = this.parsedData.parts[l], F = this.instrumentMap[l] || {},
|
|
2752
|
+
const U = this.parsedData.parts[l], F = this.instrumentMap[l] || {}, d = F.instrument !== void 0 ? F.instrument : U.defaultInstrument !== void 0 ? U.defaultInstrument : 0;
|
|
2757
2753
|
try {
|
|
2758
2754
|
const Q = this.audioEngine.createChannel(l, {
|
|
2759
|
-
instrument:
|
|
2755
|
+
instrument: d,
|
|
2760
2756
|
initialVolume: F.volume || 1
|
|
2761
2757
|
});
|
|
2762
2758
|
this.partChannels.set(l, Q);
|
|
@@ -2796,7 +2792,7 @@ class Jl {
|
|
|
2796
2792
|
this.scheduleInterval || (this.scheduleInterval = setInterval(() => {
|
|
2797
2793
|
if (!this._isPlaying) return;
|
|
2798
2794
|
const l = (this.audioEngine.audioContext.currentTime - this.playbackStartTime) * this.playbackSpeed, U = l + this.lookAheadTime;
|
|
2799
|
-
for (const [F,
|
|
2795
|
+
for (const [F, d] of this.partChannels) {
|
|
2800
2796
|
const Q = this.parsedData.parts[F];
|
|
2801
2797
|
if (Q) {
|
|
2802
2798
|
if (Q.programChanges && Q.programChanges.length > 0) {
|
|
@@ -2806,7 +2802,7 @@ class Jl {
|
|
|
2806
2802
|
V++;
|
|
2807
2803
|
for (; V < t.length && t[V].time <= U; ) {
|
|
2808
2804
|
const R = t[V];
|
|
2809
|
-
|
|
2805
|
+
d.setInstrument(R.programNumber), V++;
|
|
2810
2806
|
}
|
|
2811
2807
|
this.partProgramPointers.set(F, V);
|
|
2812
2808
|
}
|
|
@@ -2819,7 +2815,7 @@ class Jl {
|
|
|
2819
2815
|
const R = t[V];
|
|
2820
2816
|
if (R.endTime - R.startTime >= 0.01) {
|
|
2821
2817
|
const a = this.playbackStartTime + R.startTime / this.playbackSpeed, n = (R.endTime - R.startTime) / this.playbackSpeed;
|
|
2822
|
-
|
|
2818
|
+
d.playNote(a, R.pitch, R.velocity, n);
|
|
2823
2819
|
}
|
|
2824
2820
|
V++;
|
|
2825
2821
|
}
|
|
@@ -2838,10 +2834,10 @@ class Jl {
|
|
|
2838
2834
|
for (const [U] of this.partChannels) {
|
|
2839
2835
|
const F = this.parsedData.parts[U];
|
|
2840
2836
|
if (!F || !F.notes) continue;
|
|
2841
|
-
let
|
|
2842
|
-
for (;
|
|
2843
|
-
|
|
2844
|
-
this.partNotePointers.set(U,
|
|
2837
|
+
let d = 0;
|
|
2838
|
+
for (; d < F.notes.length && F.notes[d].endTime < l; )
|
|
2839
|
+
d++;
|
|
2840
|
+
this.partNotePointers.set(U, d);
|
|
2845
2841
|
}
|
|
2846
2842
|
}
|
|
2847
2843
|
/**
|
|
@@ -2851,14 +2847,14 @@ class Jl {
|
|
|
2851
2847
|
_resetProgramPointers() {
|
|
2852
2848
|
const l = this._currentTime;
|
|
2853
2849
|
for (const [U, F] of this.partChannels) {
|
|
2854
|
-
const
|
|
2855
|
-
if (!
|
|
2850
|
+
const d = this.parsedData.parts[U];
|
|
2851
|
+
if (!d || !d.programChanges) {
|
|
2856
2852
|
this.partProgramPointers.set(U, 0);
|
|
2857
2853
|
continue;
|
|
2858
2854
|
}
|
|
2859
|
-
let Q = 0, V =
|
|
2860
|
-
for (; Q <
|
|
2861
|
-
V =
|
|
2855
|
+
let Q = 0, V = d.defaultInstrument;
|
|
2856
|
+
for (; Q < d.programChanges.length && d.programChanges[Q].time <= l; )
|
|
2857
|
+
V = d.programChanges[Q].programNumber, Q++;
|
|
2862
2858
|
F.setInstrument(V), this.partProgramPointers.set(U, Q);
|
|
2863
2859
|
}
|
|
2864
2860
|
}
|
|
@@ -2900,8 +2896,8 @@ class Jl {
|
|
|
2900
2896
|
(this.eventBus.all.get(l) || []).forEach((F) => {
|
|
2901
2897
|
try {
|
|
2902
2898
|
F(U);
|
|
2903
|
-
} catch (
|
|
2904
|
-
console.error(`Error in ${l} event listener:`,
|
|
2899
|
+
} catch (d) {
|
|
2900
|
+
console.error(`Error in ${l} event listener:`, d);
|
|
2905
2901
|
}
|
|
2906
2902
|
});
|
|
2907
2903
|
}
|
|
@@ -3310,14 +3306,14 @@ class xU {
|
|
|
3310
3306
|
throw new Error("Audio engine not ready. Call setAudioEngine() first.");
|
|
3311
3307
|
if (this.isCalibrating)
|
|
3312
3308
|
throw new Error("Calibration already in progress");
|
|
3313
|
-
const U = l.measurements || 5, F = l.sampleIntervalMs || 10,
|
|
3309
|
+
const U = l.measurements || 5, F = l.sampleIntervalMs || 10, d = l.threshold || 0.01, Q = l.timeout || 3e3, V = l.silent !== void 0 ? l.silent : !0, t = l.updateBaseline !== void 0 ? l.updateBaseline : !0;
|
|
3314
3310
|
this.isCalibrating = !0;
|
|
3315
3311
|
try {
|
|
3316
3312
|
V && await this._setupSilentCalibration();
|
|
3317
3313
|
const R = await this._performLatencyMeasurement(
|
|
3318
3314
|
U,
|
|
3319
3315
|
F,
|
|
3320
|
-
|
|
3316
|
+
d,
|
|
3321
3317
|
Q
|
|
3322
3318
|
);
|
|
3323
3319
|
this.measuredLatencyMs = R, t && await this._updateBaselineLatency(R);
|
|
@@ -3427,7 +3423,7 @@ class xU {
|
|
|
3427
3423
|
previewNextNotes(l = {}) {
|
|
3428
3424
|
if (!this.midiPlayer)
|
|
3429
3425
|
throw new Error("No MIDI data loaded");
|
|
3430
|
-
const U = l.delayBetweenParts ?? 0.3, F = l.duration ?? 0.5,
|
|
3426
|
+
const U = l.delayBetweenParts ?? 0.3, F = l.duration ?? 0.5, d = l.velocity ?? 100, Q = this.midiPlayer.getAllNextNotes(), V = l.partOrder ?? this.getPartNames();
|
|
3431
3427
|
let t = this.audioEngine.audioContext.currentTime + 0.01;
|
|
3432
3428
|
const R = [];
|
|
3433
3429
|
for (const a of V) {
|
|
@@ -3439,7 +3435,7 @@ class xU {
|
|
|
3439
3435
|
W && W.gain.value === 0 || (m.playPreviewNote(n.pitch, {
|
|
3440
3436
|
startTime: t,
|
|
3441
3437
|
duration: F,
|
|
3442
|
-
velocity:
|
|
3438
|
+
velocity: d,
|
|
3443
3439
|
instrument: l.instrument
|
|
3444
3440
|
}), R.push({
|
|
3445
3441
|
partName: a,
|
|
@@ -3568,10 +3564,10 @@ class xU {
|
|
|
3568
3564
|
startBeat: { bar: 1, beat: 1, timeSig: 4 }
|
|
3569
3565
|
};
|
|
3570
3566
|
const l = this.midiPlayer.beats, U = this.frozenTime, F = this.leadInConfig.bars;
|
|
3571
|
-
let
|
|
3572
|
-
for (; l[
|
|
3573
|
-
const V = l[
|
|
3574
|
-
t ? Q = t.time - V.time :
|
|
3567
|
+
let d = l.length - 1, Q = 0.5;
|
|
3568
|
+
for (; l[d].time > U; ) d--;
|
|
3569
|
+
const V = l[d], t = l[d + 1];
|
|
3570
|
+
t ? Q = t.time - V.time : d > 0 && (Q = V.time - l[d - 1].time);
|
|
3575
3571
|
const R = this.midiPlayer && this.midiPlayer.playbackSpeed || 1, a = Q / R, n = V.timeSig === 1, m = n && t ? t.timeSig : V.timeSig, W = n ? m - 1 : V.beat > 1 ? V.beat - 1 : 0, c = F * m + W;
|
|
3576
3572
|
return {
|
|
3577
3573
|
totalBeats: c,
|
|
@@ -3590,10 +3586,10 @@ class xU {
|
|
|
3590
3586
|
* @private
|
|
3591
3587
|
*/
|
|
3592
3588
|
_generateBeatSequence(l, U, F) {
|
|
3593
|
-
const
|
|
3589
|
+
const d = [];
|
|
3594
3590
|
for (let Q = 0; Q < l; Q++) {
|
|
3595
3591
|
const V = Q % F + 1;
|
|
3596
|
-
|
|
3592
|
+
d.push({
|
|
3597
3593
|
beat: V,
|
|
3598
3594
|
isAccent: V === 1,
|
|
3599
3595
|
time: Q * U,
|
|
@@ -3602,7 +3598,7 @@ class xU {
|
|
|
3602
3598
|
// Absolute time (includes startup delay)
|
|
3603
3599
|
});
|
|
3604
3600
|
}
|
|
3605
|
-
return
|
|
3601
|
+
return d;
|
|
3606
3602
|
}
|
|
3607
3603
|
/**
|
|
3608
3604
|
* Start lead-in tick scheduling using beat-index approach
|
|
@@ -3613,9 +3609,9 @@ class xU {
|
|
|
3613
3609
|
this.leadInBeatIndex = 0, this.leadInScheduledBeats = /* @__PURE__ */ new Set();
|
|
3614
3610
|
const U = this.leadInData.beatSequence, F = 10;
|
|
3615
3611
|
this.leadInStartTime = this.audioEngine.audioContext.currentTime, this.leadInInterval = setInterval(() => {
|
|
3616
|
-
const
|
|
3617
|
-
for (this.leadInProgress = Math.min(1,
|
|
3618
|
-
const Q = U[this.leadInBeatIndex], V = Q.time -
|
|
3612
|
+
const d = this.audioEngine.audioContext.currentTime - this.leadInStartTime;
|
|
3613
|
+
for (this.leadInProgress = Math.min(1, d / this.leadInData.duration); this.leadInBeatIndex < U.length; ) {
|
|
3614
|
+
const Q = U[this.leadInBeatIndex], V = Q.time - d;
|
|
3619
3615
|
if (V > 0.05)
|
|
3620
3616
|
break;
|
|
3621
3617
|
if (!this.leadInScheduledBeats.has(this.leadInBeatIndex) && V >= -0.05 && V <= 0.05) {
|
|
@@ -3671,7 +3667,7 @@ class xU {
|
|
|
3671
3667
|
this.state = "playing", this._resetMetronomeBeatTracking(), U && this._emitEvent("playbackStarted", {
|
|
3672
3668
|
startupDelayMs: F ? 0 : this.startupConfig.delayMs
|
|
3673
3669
|
});
|
|
3674
|
-
const
|
|
3670
|
+
const d = () => {
|
|
3675
3671
|
if (this.state === "playing")
|
|
3676
3672
|
try {
|
|
3677
3673
|
this.midiPlayer.play(), l && this._startMetronome();
|
|
@@ -3679,7 +3675,7 @@ class xU {
|
|
|
3679
3675
|
this.state = "stopped", this._emitEvent("error", Q);
|
|
3680
3676
|
}
|
|
3681
3677
|
};
|
|
3682
|
-
F ?
|
|
3678
|
+
F ? d() : setTimeout(d, this.startupConfig.delayMs), this.timeUpdateInterval || this._startTimeUpdateLoop();
|
|
3683
3679
|
}
|
|
3684
3680
|
/**
|
|
3685
3681
|
* Start metronome during MIDI playback
|
|
@@ -3718,10 +3714,10 @@ class xU {
|
|
|
3718
3714
|
const U = this.midiPlayer.beats;
|
|
3719
3715
|
if (!U || U.length === 0)
|
|
3720
3716
|
return;
|
|
3721
|
-
const F = this.midiPlayer.getCurrentTime(),
|
|
3717
|
+
const F = this.midiPlayer.getCurrentTime(), d = 0.1;
|
|
3722
3718
|
for (let Q = this.nextBeatIndex; Q < U.length; Q++) {
|
|
3723
3719
|
const V = U[Q], t = this.midiPlayer.playbackSpeed || 1, R = l + (V.time - F) / t;
|
|
3724
|
-
if (R > this.audioEngine.audioContext.currentTime +
|
|
3720
|
+
if (R > this.audioEngine.audioContext.currentTime + d)
|
|
3725
3721
|
break;
|
|
3726
3722
|
if (R >= this.audioEngine.audioContext.currentTime - 0.01) {
|
|
3727
3723
|
const a = Math.max(R, this.audioEngine.audioContext.currentTime + 1e-3), n = V.isDownbeat || V.beat === 1;
|
|
@@ -3742,11 +3738,11 @@ class xU {
|
|
|
3742
3738
|
this.nextBeatIndex++;
|
|
3743
3739
|
const F = l + 0.15;
|
|
3744
3740
|
for (; this.nextBeatIndex < U.length; ) {
|
|
3745
|
-
const
|
|
3746
|
-
if (
|
|
3741
|
+
const d = U[this.nextBeatIndex], Q = d.time - l;
|
|
3742
|
+
if (d.time > F)
|
|
3747
3743
|
break;
|
|
3748
3744
|
if (Q >= -0.025 && Q <= 0.15) {
|
|
3749
|
-
const V = this.audioEngine.audioContext.currentTime + 5e-3, t = this.audioEngine.audioContext.currentTime + Math.max(Q, 5e-3), R = Math.max(V, t), a =
|
|
3745
|
+
const V = this.audioEngine.audioContext.currentTime + 5e-3, t = this.audioEngine.audioContext.currentTime + Math.max(Q, 5e-3), R = Math.max(V, t), a = d.beat === 1;
|
|
3750
3746
|
this._scheduleTickAtTime(R, a);
|
|
3751
3747
|
}
|
|
3752
3748
|
this.nextBeatIndex++;
|
|
@@ -3851,8 +3847,8 @@ class xU {
|
|
|
3851
3847
|
(this.eventBus.all.get(l) || []).forEach((F) => {
|
|
3852
3848
|
try {
|
|
3853
3849
|
F(U);
|
|
3854
|
-
} catch (
|
|
3855
|
-
console.error(`Error in ${l} event listener:`,
|
|
3850
|
+
} catch (d) {
|
|
3851
|
+
console.error(`Error in ${l} event listener:`, d);
|
|
3856
3852
|
}
|
|
3857
3853
|
});
|
|
3858
3854
|
}
|
|
@@ -3921,7 +3917,10 @@ class xU {
|
|
|
3921
3917
|
* @private
|
|
3922
3918
|
*/
|
|
3923
3919
|
_completeMidiPlayerSetup() {
|
|
3924
|
-
this._partOutputsMap.clear(), Object.keys(this.midiPlayer.parsedData.parts).
|
|
3920
|
+
this._partOutputsMap.clear(), Object.keys(this.midiPlayer.parsedData.parts).sort((l, U) => {
|
|
3921
|
+
const F = this.midiPlayer.parsedData.parts[l], d = this.midiPlayer.parsedData.parts[U], Q = F.channel !== void 0 ? F.channel : F.trackIndex, V = d.channel !== void 0 ? d.channel : d.trackIndex;
|
|
3922
|
+
return Q - V;
|
|
3923
|
+
}).forEach((l) => {
|
|
3925
3924
|
const U = this.midiPlayer.getPartOutput(l);
|
|
3926
3925
|
U && this._partOutputsMap.set(l, U);
|
|
3927
3926
|
}), this._setupEventDelegation(), this.state = "ready";
|
|
@@ -3944,12 +3943,20 @@ class xU {
|
|
|
3944
3943
|
flute: { instrument: "flute", volume: 0.8 },
|
|
3945
3944
|
trumpet: { instrument: "trumpet", volume: 0.7 }
|
|
3946
3945
|
};
|
|
3947
|
-
return Object.keys(l).forEach((
|
|
3948
|
-
const Q =
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3946
|
+
return Object.keys(l).forEach((d) => {
|
|
3947
|
+
const Q = l[d];
|
|
3948
|
+
if (Q.defaultInstrument !== void 0)
|
|
3949
|
+
U[d] = {
|
|
3950
|
+
instrument: Q.defaultInstrument,
|
|
3951
|
+
volume: 1
|
|
3952
|
+
};
|
|
3953
|
+
else {
|
|
3954
|
+
const V = d.toLowerCase(), t = F[V] || F.piano;
|
|
3955
|
+
U[d] = {
|
|
3956
|
+
instrument: t.instrument,
|
|
3957
|
+
volume: t.volume
|
|
3958
|
+
};
|
|
3959
|
+
}
|
|
3953
3960
|
}), U;
|
|
3954
3961
|
}
|
|
3955
3962
|
// ========================================
|
|
@@ -3969,19 +3976,19 @@ class xU {
|
|
|
3969
3976
|
const U = this.audioEngine.getMetronomeAnalyser();
|
|
3970
3977
|
if (!U)
|
|
3971
3978
|
throw new Error("Metronome analyser not available for signal capture");
|
|
3972
|
-
const F = l.sampleIntervalMs || 2,
|
|
3979
|
+
const F = l.sampleIntervalMs || 2, d = l.captureDurationMs || 1500, Q = this.audioEngine.audioContext.currentTime + 0.1;
|
|
3973
3980
|
await this.audioEngine.playMetronomeTick(Q, !0, 1);
|
|
3974
3981
|
const V = await this._captureAnalyserTimeSeries(
|
|
3975
3982
|
U,
|
|
3976
3983
|
Q,
|
|
3977
3984
|
F,
|
|
3978
|
-
|
|
3985
|
+
d
|
|
3979
3986
|
);
|
|
3980
3987
|
return {
|
|
3981
3988
|
scheduledTime: Q,
|
|
3982
3989
|
samples: V,
|
|
3983
3990
|
sampleIntervalMs: F,
|
|
3984
|
-
captureDurationMs:
|
|
3991
|
+
captureDurationMs: d
|
|
3985
3992
|
};
|
|
3986
3993
|
}
|
|
3987
3994
|
/**
|
|
@@ -3993,7 +4000,7 @@ class xU {
|
|
|
3993
4000
|
* @returns {Promise<number>} Average latency in milliseconds
|
|
3994
4001
|
* @private
|
|
3995
4002
|
*/
|
|
3996
|
-
async _performLatencyMeasurement(l, U, F,
|
|
4003
|
+
async _performLatencyMeasurement(l, U, F, d) {
|
|
3997
4004
|
const Q = this.audioEngine.getMetronomeAnalyser();
|
|
3998
4005
|
if (!Q)
|
|
3999
4006
|
throw new Error("Metronome analyser not available for latency measurement");
|
|
@@ -4007,7 +4014,7 @@ class xU {
|
|
|
4007
4014
|
W,
|
|
4008
4015
|
U,
|
|
4009
4016
|
F,
|
|
4010
|
-
|
|
4017
|
+
d
|
|
4011
4018
|
);
|
|
4012
4019
|
if (c) {
|
|
4013
4020
|
const s = c.latencyMs;
|
|
@@ -4044,7 +4051,7 @@ class xU {
|
|
|
4044
4051
|
* @returns {Promise<Object|null>} Detection result {latencyMs, rms, peak} or null if timeout
|
|
4045
4052
|
* @private
|
|
4046
4053
|
*/
|
|
4047
|
-
async _detectOnsetByThreshold(l, U, F,
|
|
4054
|
+
async _detectOnsetByThreshold(l, U, F, d, Q) {
|
|
4048
4055
|
const V = this.audioEngine.audioContext, t = l.fftSize, R = new Float32Array(t), a = Math.max(0, (U - V.currentTime) * 1e3 - 20);
|
|
4049
4056
|
await new Promise((m) => setTimeout(m, a));
|
|
4050
4057
|
const n = performance.now();
|
|
@@ -4061,7 +4068,7 @@ class xU {
|
|
|
4061
4068
|
c += R[J] * R[J], p > s && (s = p);
|
|
4062
4069
|
}
|
|
4063
4070
|
const N = Math.sqrt(c / t);
|
|
4064
|
-
if (N >=
|
|
4071
|
+
if (N >= d) {
|
|
4065
4072
|
clearInterval(W);
|
|
4066
4073
|
const J = V.currentTime, p = (J - U) * 1e3;
|
|
4067
4074
|
m({
|
|
@@ -4083,11 +4090,11 @@ class xU {
|
|
|
4083
4090
|
* @returns {Promise<Array>} Array of samples {time, rms, peak, relativeTime}
|
|
4084
4091
|
* @private
|
|
4085
4092
|
*/
|
|
4086
|
-
async _captureAnalyserTimeSeries(l, U, F,
|
|
4093
|
+
async _captureAnalyserTimeSeries(l, U, F, d) {
|
|
4087
4094
|
const Q = this.audioEngine.audioContext, V = l.fftSize, t = new Float32Array(V), R = [], a = performance.now(), n = Math.max(0, (U - Q.currentTime) * 1e3 - 20);
|
|
4088
4095
|
return await new Promise((m) => setTimeout(m, n)), new Promise((m) => {
|
|
4089
4096
|
const W = setInterval(() => {
|
|
4090
|
-
if (performance.now() - a - n >=
|
|
4097
|
+
if (performance.now() - a - n >= d) {
|
|
4091
4098
|
clearInterval(W), m(R);
|
|
4092
4099
|
return;
|
|
4093
4100
|
}
|
|
@@ -4121,8 +4128,8 @@ class MU {
|
|
|
4121
4128
|
// Initialize audio system
|
|
4122
4129
|
async initializeAudioSystem() {
|
|
4123
4130
|
if (this.isInitialized) return;
|
|
4124
|
-
this.audioContext = new (window.AudioContext || window.webkitAudioContext)(), this.audioContext.state === "suspended" && await this.audioContext.resume(), this.audioEngine = new rU(this.audioContext), this.audioEngine.on("initProgress", (
|
|
4125
|
-
this.eventBus.emit("initProgress",
|
|
4131
|
+
this.audioContext = new (window.AudioContext || window.webkitAudioContext)(), this.audioContext.state === "suspended" && await this.audioContext.resume(), this.audioEngine = new rU(this.audioContext), this.audioEngine.on("initProgress", (d) => {
|
|
4132
|
+
this.eventBus.emit("initProgress", d);
|
|
4126
4133
|
});
|
|
4127
4134
|
const l = [
|
|
4128
4135
|
"/FluidR3Mono_GM.sf3",
|
|
@@ -4130,20 +4137,20 @@ class MU {
|
|
|
4130
4137
|
"/soundfont.sf2"
|
|
4131
4138
|
];
|
|
4132
4139
|
let U = !1, F = null;
|
|
4133
|
-
for (const
|
|
4140
|
+
for (const d of l)
|
|
4134
4141
|
try {
|
|
4135
|
-
await this.audioEngine.initialize(
|
|
4142
|
+
await this.audioEngine.initialize(d), console.log(`Loaded soundfont: ${d}`), U = !0;
|
|
4136
4143
|
break;
|
|
4137
4144
|
} catch (Q) {
|
|
4138
|
-
console.warn(`Failed to load soundfont ${
|
|
4145
|
+
console.warn(`Failed to load soundfont ${d}:`, Q.message), F = Q;
|
|
4139
4146
|
}
|
|
4140
4147
|
if (!U) {
|
|
4141
|
-
const
|
|
4148
|
+
const d = "No soundfont could be loaded";
|
|
4142
4149
|
throw this.eventBus.emit("initProgress", {
|
|
4143
4150
|
stage: "error",
|
|
4144
|
-
message:
|
|
4151
|
+
message: d,
|
|
4145
4152
|
error: F
|
|
4146
|
-
}), new Error(
|
|
4153
|
+
}), new Error(d);
|
|
4147
4154
|
}
|
|
4148
4155
|
this.setupMasterAudioGraph(), this.isInitialized = !0, console.log("AudioEngineService initialized successfully");
|
|
4149
4156
|
}
|
|
@@ -4158,7 +4165,7 @@ class MU {
|
|
|
4158
4165
|
else {
|
|
4159
4166
|
if (this.beats = l.beats || [], this.practiceMarks = l.marks || l.practiceMarks || {}, this.beats.length > 0) {
|
|
4160
4167
|
const U = this.beats[this.beats.length - 1], F = U.tempo > 0 ? 60 / U.tempo : 0.75;
|
|
4161
|
-
this.songDuration = U.time + F, this.maxBar = Math.max(...this.beats.map((
|
|
4168
|
+
this.songDuration = U.time + F, this.maxBar = Math.max(...this.beats.map((d) => d.bar));
|
|
4162
4169
|
} else
|
|
4163
4170
|
this.songDuration = 0, this.maxBar = 0;
|
|
4164
4171
|
this.setupLegacyParts(l.parts || []), this.eventBus.emit("initialized", { parts: Array.from(this.parts.values()) });
|
|
@@ -4196,8 +4203,8 @@ class MU {
|
|
|
4196
4203
|
// Silent calibration
|
|
4197
4204
|
});
|
|
4198
4205
|
console.log(`Measured audio latency: ${F} ms`), this.setupPlaybackManagerEventDelegation(), await this.playbackManager.load(l, U);
|
|
4199
|
-
const
|
|
4200
|
-
this.setupMidiParts(
|
|
4206
|
+
const d = this.playbackManager.getPartNames();
|
|
4207
|
+
this.setupMidiParts(d), this.eventBus.emit("initialized", { parts: Array.from(this.parts.values()) }), await this.setupPartAudioRouting(d), this.setupMetronomeAudioRouting(), this.extractMusicDataFromPlayer(), this.updateSongDurationFromPlayer(), console.log("MIDI playback with PlaybackManager setup complete");
|
|
4201
4208
|
} catch (F) {
|
|
4202
4209
|
throw console.error("Failed to setup MIDI playback:", F), F;
|
|
4203
4210
|
}
|
|
@@ -4223,10 +4230,10 @@ class MU {
|
|
|
4223
4230
|
for (const [l, U] of this.playbackManager.getPartOutputs()) {
|
|
4224
4231
|
const F = this.audioContext.createGain();
|
|
4225
4232
|
F.gain.value = 1;
|
|
4226
|
-
const
|
|
4227
|
-
|
|
4233
|
+
const d = this.audioContext.createAnalyser();
|
|
4234
|
+
d.fftSize = 256, d.smoothingTimeConstant = 0.3, U.connect(F), F.connect(d), d.connect(this.masterGain);
|
|
4228
4235
|
const Q = this.sanitizePartName(l);
|
|
4229
|
-
this.partGainNodes.set(Q, F), this.partAnalyserNodes.set(Q,
|
|
4236
|
+
this.partGainNodes.set(Q, F), this.partAnalyserNodes.set(Q, d), console.log(`Audio routing established for part: ${l}`);
|
|
4230
4237
|
}
|
|
4231
4238
|
}
|
|
4232
4239
|
// Set up metronome audio routing (separate from parts)
|
|
@@ -4274,8 +4281,8 @@ class MU {
|
|
|
4274
4281
|
setupPlaybackManagerEventDelegation() {
|
|
4275
4282
|
this.playbackManager.on("timeupdate", ({ audioTime: l, leadInProgress: U }) => {
|
|
4276
4283
|
this.currentTime = l, this.eventBus.emit("timeChanged", { currentTime: l, leadInProgress: U });
|
|
4277
|
-
}), this.playbackManager.on("beatAudible", ({ bar: l, beat: U, isLeadIn: F, repeat:
|
|
4278
|
-
this.eventBus.emit("barChanged", { bar: l, beat: U, repeat:
|
|
4284
|
+
}), this.playbackManager.on("beatAudible", ({ bar: l, beat: U, isLeadIn: F, repeat: d, time: Q }) => {
|
|
4285
|
+
this.eventBus.emit("barChanged", { bar: l, beat: U, repeat: d, time: Q, isLeadIn: F });
|
|
4279
4286
|
}), this.playbackManager.on("leadInStarted", ({ totalBeats: l, duration: U, bars: F }) => {
|
|
4280
4287
|
this.eventBus.emit("leadInStarted", { bars: F, totalBeats: l, duration: U });
|
|
4281
4288
|
}), this.playbackManager.on("leadInEnded", () => {
|
|
@@ -4386,16 +4393,16 @@ class MU {
|
|
|
4386
4393
|
return this.metronomeVolume || 0.7;
|
|
4387
4394
|
}
|
|
4388
4395
|
setPartVolume(l, U) {
|
|
4389
|
-
const F = this.sanitizePartName(l),
|
|
4390
|
-
|
|
4396
|
+
const F = this.sanitizePartName(l), d = this.parts.get(F);
|
|
4397
|
+
d ? (d.volume = Math.max(0, Math.min(1, U)), this.updatePartAudioState(F), this.eventBus.emit("partVolumeChanged", { partName: l, volume: U })) : (console.log(`Part not found: "${l}" (sanitized: "${F}")`), console.log("Available parts:", [...this.parts.keys()]));
|
|
4391
4398
|
}
|
|
4392
4399
|
setPartMuted(l, U) {
|
|
4393
|
-
const F = this.sanitizePartName(l),
|
|
4394
|
-
|
|
4400
|
+
const F = this.sanitizePartName(l), d = this.parts.get(F);
|
|
4401
|
+
d && (d.muted = U, this.updatePartAudioState(F), this.eventBus.emit("partMutedChanged", { partName: l, muted: U }));
|
|
4395
4402
|
}
|
|
4396
4403
|
setPartSolo(l, U) {
|
|
4397
|
-
const F = this.sanitizePartName(l),
|
|
4398
|
-
|
|
4404
|
+
const F = this.sanitizePartName(l), d = this.parts.get(F);
|
|
4405
|
+
d && (d.solo = U, this.updateAllPartsAudioState(), this.eventBus.emit("partSoloChanged", { partName: l, solo: U }));
|
|
4399
4406
|
}
|
|
4400
4407
|
// Helper method to determine if a part should be effectively muted
|
|
4401
4408
|
isPartEffectivelyMuted(l) {
|
|
@@ -4406,8 +4413,8 @@ class MU {
|
|
|
4406
4413
|
updatePartAudioState(l) {
|
|
4407
4414
|
const U = this.parts.get(l), F = this.partGainNodes.get(l);
|
|
4408
4415
|
if (U && F) {
|
|
4409
|
-
const
|
|
4410
|
-
F.gain.value =
|
|
4416
|
+
const d = this.isPartEffectivelyMuted(U.name);
|
|
4417
|
+
F.gain.value = d ? 0 : U.volume;
|
|
4411
4418
|
}
|
|
4412
4419
|
}
|
|
4413
4420
|
// Update audio state for all parts (needed when solo state changes)
|
|
@@ -4424,17 +4431,17 @@ class MU {
|
|
|
4424
4431
|
if (!F)
|
|
4425
4432
|
return 0;
|
|
4426
4433
|
try {
|
|
4427
|
-
const
|
|
4434
|
+
const d = F.frequencyBinCount, Q = new Uint8Array(d);
|
|
4428
4435
|
F.getByteFrequencyData(Q);
|
|
4429
4436
|
let V = 0;
|
|
4430
|
-
for (let R = 0; R <
|
|
4437
|
+
for (let R = 0; R < d; R++) {
|
|
4431
4438
|
const a = Q[R] / 255;
|
|
4432
4439
|
V += a * a;
|
|
4433
4440
|
}
|
|
4434
|
-
const t = Math.sqrt(V /
|
|
4441
|
+
const t = Math.sqrt(V / d);
|
|
4435
4442
|
return Math.min(1, Math.pow(t * 2, 0.7));
|
|
4436
|
-
} catch (
|
|
4437
|
-
return console.warn(`Failed to get level for part ${l}:`,
|
|
4443
|
+
} catch (d) {
|
|
4444
|
+
return console.warn(`Failed to get level for part ${l}:`, d), 0;
|
|
4438
4445
|
}
|
|
4439
4446
|
}
|
|
4440
4447
|
// Special features (maintain DummyAudioEngine interface)
|
|
@@ -4443,7 +4450,7 @@ class MU {
|
|
|
4443
4450
|
}
|
|
4444
4451
|
playStartingNotes() {
|
|
4445
4452
|
console.log(this.parts);
|
|
4446
|
-
const l = [...this.parts.values()], U = l.some((
|
|
4453
|
+
const l = [...this.parts.values()], U = l.some((d) => d.solo), F = l.filter((d) => U ? d.solo : !d.muted).map((d) => d.name);
|
|
4447
4454
|
console.log(l, U, F), this.playbackManager.previewNextNotes({
|
|
4448
4455
|
instrument: "piano",
|
|
4449
4456
|
// Use piano for clear pitch reference
|
|
@@ -4513,55 +4520,55 @@ class MU {
|
|
|
4513
4520
|
}
|
|
4514
4521
|
const e = new MU();
|
|
4515
4522
|
function Rl() {
|
|
4516
|
-
const
|
|
4517
|
-
|
|
4518
|
-
},
|
|
4519
|
-
|
|
4523
|
+
const Z = Ul(), l = tl(), U = NU(), F = ({ currentTime: b }) => {
|
|
4524
|
+
Z.setCurrentTime(b);
|
|
4525
|
+
}, d = ({ isPlaying: b }) => {
|
|
4526
|
+
Z.setPlaybackState(b), U.setTransportState(b ? "playing" : "stopped");
|
|
4520
4527
|
}, Q = (b) => {
|
|
4521
|
-
b && (
|
|
4528
|
+
b && (Z.isLeadInActive ? b.isLeadIn && b.beat !== void 0 && Z.setCurrentBar(null, b.beat, null) : (Z.setCurrentBar(b.bar, b.beat, b.repeat), U.updateLastBarPosition(b.bar)));
|
|
4522
4529
|
}, V = ({ speed: b }) => {
|
|
4523
|
-
|
|
4530
|
+
Z.setPlaybackSpeed(b);
|
|
4524
4531
|
}, t = ({ volume: b }) => {
|
|
4525
|
-
|
|
4532
|
+
Z.setMasterVolume(b);
|
|
4526
4533
|
}, R = ({ partName: b, volume: o }) => {
|
|
4527
|
-
|
|
4534
|
+
Z.setPartVolume(b, o);
|
|
4528
4535
|
}, a = ({ partName: b, muted: o }) => {
|
|
4529
|
-
|
|
4536
|
+
Z.setPartMuted(b, o);
|
|
4530
4537
|
}, n = ({ partName: b, solo: o }) => {
|
|
4531
|
-
|
|
4538
|
+
Z.setPartSolo(b, o);
|
|
4532
4539
|
}, m = ({ bars: b }) => {
|
|
4533
|
-
|
|
4540
|
+
Z.setLeadInActive(!0, b);
|
|
4534
4541
|
}, W = () => {
|
|
4535
|
-
|
|
4542
|
+
Z.setLeadInActive(!1);
|
|
4536
4543
|
}, c = () => {
|
|
4537
|
-
|
|
4544
|
+
Z.setStartingNotesActive(!0);
|
|
4538
4545
|
}, s = () => {
|
|
4539
|
-
|
|
4546
|
+
Z.setStartingNotesActive(!1);
|
|
4540
4547
|
}, N = ({ mark: b }) => {
|
|
4541
4548
|
U.updateLastPracticeMarkUsed(b);
|
|
4542
4549
|
}, J = ({ parts: b }) => {
|
|
4543
|
-
|
|
4550
|
+
Z.initializeParts(b), l.setParts(b);
|
|
4544
4551
|
}, p = ({ finalTime: b }) => {
|
|
4545
|
-
|
|
4552
|
+
Z.setPlaybackState(!1), U.setTransportState("stopped"), console.log(`Song ended at time: ${b}`);
|
|
4546
4553
|
}, M = ({ duration: b }) => {
|
|
4547
4554
|
console.log("Updating total duration in store to:", b), l.setTotalDuration(b);
|
|
4548
4555
|
}, y = ({ beats: b, practiceMarks: o, maxBar: q }) => {
|
|
4549
4556
|
console.log(`Updating music data store with ${b.length} beats and ${Object.keys(o).length} practice marks`), l.updateBeats(b), l.practiceMarks = o, l.maxBar = q;
|
|
4550
4557
|
}, u = () => {
|
|
4551
|
-
e.on("timeChanged", F), e.on("playbackStateChanged",
|
|
4558
|
+
e.on("timeChanged", F), e.on("playbackStateChanged", d), e.on("barChanged", Q), e.on("speedChanged", V), e.on("masterVolumeChanged", t), e.on("partVolumeChanged", R), e.on("partMutedChanged", a), e.on("partSoloChanged", n), e.on("leadInStarted", m), e.on("leadInCompleted", W), e.on("startingNotesStarted", c), e.on("startingNotesCompleted", s), e.on("practiceMarkChanged", N), e.on("initialized", J), e.on("songEnded", p), e.on("durationUpdated", M), e.on("musicDataExtracted", y);
|
|
4552
4559
|
}, k = () => {
|
|
4553
|
-
e.off("timeChanged", F), e.off("playbackStateChanged",
|
|
4560
|
+
e.off("timeChanged", F), e.off("playbackStateChanged", d), e.off("barChanged", Q), e.off("speedChanged", V), e.off("masterVolumeChanged", t), e.off("partVolumeChanged", R), e.off("partMutedChanged", a), e.off("partSoloChanged", n), e.off("leadInStarted", m), e.off("leadInCompleted", W), e.off("startingNotesStarted", c), e.off("startingNotesCompleted", s), e.off("practiceMarkChanged", N), e.off("initialized", J), e.off("songEnded", p), e.off("durationUpdated", M), e.off("musicDataExtracted", y);
|
|
4554
4561
|
};
|
|
4555
4562
|
(() => {
|
|
4556
4563
|
El(() => {
|
|
4557
|
-
const b =
|
|
4564
|
+
const b = Z.masterVolume;
|
|
4558
4565
|
try {
|
|
4559
4566
|
e.getMasterVolume() !== b && e.setMasterVolume(b);
|
|
4560
4567
|
} catch (o) {
|
|
4561
4568
|
console.warn("Master volume sync skipped during initialization:", o.message);
|
|
4562
4569
|
}
|
|
4563
4570
|
}), El(() => {
|
|
4564
|
-
const b =
|
|
4571
|
+
const b = Z.metronomeVolume;
|
|
4565
4572
|
try {
|
|
4566
4573
|
e.getMetronomeVolume() !== b && e.setMetronomeVolume(b);
|
|
4567
4574
|
} catch (o) {
|
|
@@ -4571,13 +4578,13 @@ function Rl() {
|
|
|
4571
4578
|
})();
|
|
4572
4579
|
const H = async (b) => {
|
|
4573
4580
|
try {
|
|
4574
|
-
if (
|
|
4581
|
+
if (Z.setLoaded(!1), u(), l.loadMusicData(b), await e.initialize(b), !b.midiData && b.beats && b.beats.length > 0) {
|
|
4575
4582
|
const o = b.beats[0];
|
|
4576
|
-
|
|
4583
|
+
Z.setCurrentBar(o.bar, o.beat, o.repeat), e.setTime(o.time);
|
|
4577
4584
|
}
|
|
4578
|
-
e.updateToggleStates(
|
|
4585
|
+
e.updateToggleStates(Z.metronomeEnabled, Z.leadInEnabled), Z.setLoaded(!0);
|
|
4579
4586
|
} catch (o) {
|
|
4580
|
-
throw console.error("Failed to initialize audio engine:", o),
|
|
4587
|
+
throw console.error("Failed to initialize audio engine:", o), Z.setLoaded(!1), o;
|
|
4581
4588
|
}
|
|
4582
4589
|
}, A = () => {
|
|
4583
4590
|
e.play();
|
|
@@ -4611,11 +4618,11 @@ function Rl() {
|
|
|
4611
4618
|
const q = l.getBarForMark(b);
|
|
4612
4619
|
q && Yl(q, o);
|
|
4613
4620
|
}, $l = () => {
|
|
4614
|
-
const b = !
|
|
4615
|
-
return
|
|
4621
|
+
const b = !Z.metronomeEnabled;
|
|
4622
|
+
return Z.setMetronomeEnabled(b), e.setMetronomeEnabled(b), b;
|
|
4616
4623
|
}, lU = () => {
|
|
4617
|
-
const b = !
|
|
4618
|
-
return
|
|
4624
|
+
const b = !Z.leadInEnabled;
|
|
4625
|
+
return Z.setLeadInEnabled(b), e.updateToggleStates(Z.metronomeEnabled, b), b;
|
|
4619
4626
|
};
|
|
4620
4627
|
return cl(() => {
|
|
4621
4628
|
k();
|
|
@@ -4645,13 +4652,13 @@ function Rl() {
|
|
|
4645
4652
|
toggleMetronome: $l,
|
|
4646
4653
|
toggleLeadIn: lU,
|
|
4647
4654
|
setMetronomeEnabled: (b) => {
|
|
4648
|
-
|
|
4655
|
+
Z.setMetronomeEnabled(b), e.setMetronomeEnabled(b);
|
|
4649
4656
|
},
|
|
4650
4657
|
// Complex operations
|
|
4651
4658
|
playFromBar: Yl,
|
|
4652
4659
|
playFromMark: _l,
|
|
4653
4660
|
// Access to stores for components
|
|
4654
|
-
audioState:
|
|
4661
|
+
audioState: Z,
|
|
4655
4662
|
musicData: l,
|
|
4656
4663
|
playbackState: U,
|
|
4657
4664
|
// Direct access to engine for advanced use
|
|
@@ -4668,7 +4675,7 @@ const zU = {
|
|
|
4668
4675
|
level: {
|
|
4669
4676
|
type: Number,
|
|
4670
4677
|
default: 0,
|
|
4671
|
-
validator: (
|
|
4678
|
+
validator: (Z) => Z >= 0 && Z <= 1
|
|
4672
4679
|
}
|
|
4673
4680
|
}, {
|
|
4674
4681
|
volume: { default: 0.75 },
|
|
@@ -4679,16 +4686,16 @@ const zU = {
|
|
|
4679
4686
|
soloModifiers: {}
|
|
4680
4687
|
}),
|
|
4681
4688
|
emits: ["update:volume", "update:mute", "update:solo"],
|
|
4682
|
-
setup(
|
|
4689
|
+
setup(Z) {
|
|
4683
4690
|
$((c) => ({
|
|
4684
4691
|
"746d5fc3": a.value
|
|
4685
4692
|
}));
|
|
4686
|
-
const l =
|
|
4693
|
+
const l = Z;
|
|
4687
4694
|
Ul();
|
|
4688
|
-
const U = Rl(), F = _(
|
|
4695
|
+
const U = Rl(), F = _(Z, "volume"), d = _(Z, "mute"), Q = _(Z, "solo");
|
|
4689
4696
|
v(F, (c) => {
|
|
4690
4697
|
U.setPartVolume(l.name, c);
|
|
4691
|
-
}), v(
|
|
4698
|
+
}), v(d, (c) => {
|
|
4692
4699
|
U.setPartMuted(l.name, c);
|
|
4693
4700
|
}), v(Q, (c) => {
|
|
4694
4701
|
U.setPartSolo(l.name, c);
|
|
@@ -4700,7 +4707,7 @@ const zU = {
|
|
|
4700
4707
|
const W = x(0);
|
|
4701
4708
|
return el(() => {
|
|
4702
4709
|
m = setInterval(() => {
|
|
4703
|
-
if (
|
|
4710
|
+
if (d.value)
|
|
4704
4711
|
W.value = 0;
|
|
4705
4712
|
else
|
|
4706
4713
|
try {
|
|
@@ -4718,8 +4725,8 @@ const zU = {
|
|
|
4718
4725
|
}, [
|
|
4719
4726
|
C(XU, {
|
|
4720
4727
|
class: "tri",
|
|
4721
|
-
mute:
|
|
4722
|
-
"onUpdate:mute": s[0] || (s[0] = (N) =>
|
|
4728
|
+
mute: d.value,
|
|
4729
|
+
"onUpdate:mute": s[0] || (s[0] = (N) => d.value = N),
|
|
4723
4730
|
solo: Q.value,
|
|
4724
4731
|
"onUpdate:solo": s[1] || (s[1] = (N) => Q.value = N)
|
|
4725
4732
|
}, null, 8, ["mute", "solo"]),
|
|
@@ -4728,7 +4735,7 @@ const zU = {
|
|
|
4728
4735
|
class: "name"
|
|
4729
4736
|
}, {
|
|
4730
4737
|
default: D(() => [
|
|
4731
|
-
ol(K(
|
|
4738
|
+
ol(K(Z.name), 1)
|
|
4732
4739
|
]),
|
|
4733
4740
|
_: 1
|
|
4734
4741
|
}),
|
|
@@ -4746,12 +4753,12 @@ const zU = {
|
|
|
4746
4753
|
class: "mark-grid-container"
|
|
4747
4754
|
}, jU = { class: "mark-grid" }, PU = ["onClick"], wU = {
|
|
4748
4755
|
__name: "BarInput",
|
|
4749
|
-
setup(
|
|
4756
|
+
setup(Z) {
|
|
4750
4757
|
$((B) => ({
|
|
4751
4758
|
b117cda6: p.value,
|
|
4752
4759
|
"7cd7b1c8": M.value
|
|
4753
4760
|
}));
|
|
4754
|
-
const l = O("el"), U = O("rpt"), { width: F, height:
|
|
4761
|
+
const l = O("el"), U = O("rpt"), { width: F, height: d } = ll(l), Q = tl(), V = Ul(), t = Rl(), R = x("1"), a = x("A"), n = x(0), m = x(2), W = x(!1), c = x(!1), s = x(!1), N = x(!0);
|
|
4755
4762
|
let J = null;
|
|
4756
4763
|
v(() => {
|
|
4757
4764
|
var B;
|
|
@@ -4771,7 +4778,7 @@ const zU = {
|
|
|
4771
4778
|
}), v(c, () => {
|
|
4772
4779
|
c.value && P();
|
|
4773
4780
|
});
|
|
4774
|
-
const p = G(() => Math.min(
|
|
4781
|
+
const p = G(() => Math.min(d.value / 2.25, F.value / 4.5) + "px"), M = G(() => Math.min(F.value / 15, d.value / 6.4) + "px"), y = G(() => Object.keys(Q.practiceMarks).sort()), u = G(() => y.value.length > 0);
|
|
4775
4782
|
function k(B) {
|
|
4776
4783
|
const S = Object.keys(Q.practiceMarks).filter((T) => Q.practiceMarks[T] <= B).sort((T, I) => Q.practiceMarks[I] - Q.practiceMarks[T]);
|
|
4777
4784
|
S.length > 0 && (a.value = S[0]);
|
|
@@ -4917,23 +4924,23 @@ const zU = {
|
|
|
4917
4924
|
},
|
|
4918
4925
|
formatValue: {
|
|
4919
4926
|
type: Function,
|
|
4920
|
-
default: (
|
|
4927
|
+
default: (Z) => Z.toString()
|
|
4921
4928
|
},
|
|
4922
4929
|
parseValue: {
|
|
4923
4930
|
type: Function,
|
|
4924
|
-
default: (
|
|
4931
|
+
default: (Z) => parseFloat(Z)
|
|
4925
4932
|
},
|
|
4926
4933
|
validateInput: {
|
|
4927
4934
|
type: Function,
|
|
4928
|
-
default: (
|
|
4935
|
+
default: (Z) => Z.replace(/[^0-9.]/g, "")
|
|
4929
4936
|
},
|
|
4930
4937
|
transformSliderToDisplay: {
|
|
4931
4938
|
type: Function,
|
|
4932
|
-
default: (
|
|
4939
|
+
default: (Z) => Z
|
|
4933
4940
|
},
|
|
4934
4941
|
transformDisplayToSlider: {
|
|
4935
4942
|
type: Function,
|
|
4936
|
-
default: (
|
|
4943
|
+
default: (Z) => Z
|
|
4937
4944
|
},
|
|
4938
4945
|
maxChars: {
|
|
4939
4946
|
type: Number,
|
|
@@ -4944,23 +4951,23 @@ const zU = {
|
|
|
4944
4951
|
valueModifiers: {}
|
|
4945
4952
|
}),
|
|
4946
4953
|
emits: ["update:value"],
|
|
4947
|
-
setup(
|
|
4954
|
+
setup(Z) {
|
|
4948
4955
|
$((n) => ({
|
|
4949
|
-
"0d0963e0":
|
|
4950
|
-
"4ad34b2f":
|
|
4951
|
-
"02156786":
|
|
4956
|
+
"0d0963e0": Z.textColor,
|
|
4957
|
+
"4ad34b2f": Z.backgroundColor,
|
|
4958
|
+
"02156786": Z.color,
|
|
4952
4959
|
"715a9528": R.value,
|
|
4953
4960
|
"30d64f7d": t.value,
|
|
4954
|
-
b8fbe65e:
|
|
4961
|
+
b8fbe65e: Z.focusColor
|
|
4955
4962
|
}));
|
|
4956
|
-
const l =
|
|
4963
|
+
const l = Z, U = O("el"), { width: F, height: d } = ll(U), Q = _(Z, "value"), V = x(l.formatValue(l.transformSliderToDisplay(Q.value)));
|
|
4957
4964
|
v(Q, () => {
|
|
4958
4965
|
const n = l.transformSliderToDisplay(Q.value);
|
|
4959
4966
|
V.value = l.formatValue(n);
|
|
4960
4967
|
}), v(V, () => {
|
|
4961
4968
|
V.value = l.validateInput(V.value), l.maxChars && V.value.length > l.maxChars && (V.value = V.value.slice(0, l.maxChars));
|
|
4962
4969
|
});
|
|
4963
|
-
const t = G(() => Math.min(
|
|
4970
|
+
const t = G(() => Math.min(d.value / 2.25, F.value / 2.2) + "px"), R = G(() => Math.min(F.value / 3, d.value / 6.4) + "px");
|
|
4964
4971
|
function a() {
|
|
4965
4972
|
const n = l.parseValue(V.value), m = l.transformDisplayToSlider(n);
|
|
4966
4973
|
Q.value = Math.min(Math.max(m, l.sliderMin), l.sliderMax);
|
|
@@ -4981,27 +4988,27 @@ const zU = {
|
|
|
4981
4988
|
}, null, 544), [
|
|
4982
4989
|
[Kl, V.value]
|
|
4983
4990
|
]),
|
|
4984
|
-
h("div", fU, K(
|
|
4991
|
+
h("div", fU, K(Z.title), 1),
|
|
4985
4992
|
C(bl, {
|
|
4986
4993
|
class: "slider",
|
|
4987
4994
|
value: Q.value,
|
|
4988
4995
|
"onUpdate:value": m[1] || (m[1] = (W) => Q.value = W),
|
|
4989
|
-
"thumb-length":
|
|
4990
|
-
max:
|
|
4991
|
-
min:
|
|
4996
|
+
"thumb-length": Z.thumbLength,
|
|
4997
|
+
max: Z.sliderMax,
|
|
4998
|
+
min: Z.sliderMin
|
|
4992
4999
|
}, null, 8, ["value", "thumb-length", "max", "min"])
|
|
4993
5000
|
], 512));
|
|
4994
5001
|
}
|
|
4995
5002
|
}, ql = /* @__PURE__ */ g(AU, [["__scopeId", "data-v-79c7a539"]]), qU = {
|
|
4996
5003
|
__name: "SpeedInput",
|
|
4997
|
-
setup(
|
|
5004
|
+
setup(Z) {
|
|
4998
5005
|
const l = Ul(), U = Rl(), F = G({
|
|
4999
5006
|
get: () => Math.log2(l.playbackSpeed) * 0.5 + 0.5,
|
|
5000
5007
|
set: (a) => {
|
|
5001
5008
|
const n = Math.pow(2, a * 2 - 1);
|
|
5002
5009
|
U.setPlaybackSpeed(n);
|
|
5003
5010
|
}
|
|
5004
|
-
}),
|
|
5011
|
+
}), d = (a) => Math.floor(Math.pow(2, a * 2 - 1) * 100 + 0.5) + "", Q = (a) => parseFloat(a), V = (a) => a.replace(/\D/g, ""), t = (a) => a, R = (a) => {
|
|
5005
5012
|
const n = Math.log2(a / 100) * 0.5 + 0.5;
|
|
5006
5013
|
return Math.min(Math.max(n, 0), 1);
|
|
5007
5014
|
};
|
|
@@ -5011,7 +5018,7 @@ const zU = {
|
|
|
5011
5018
|
title: "Speed",
|
|
5012
5019
|
color: "#336",
|
|
5013
5020
|
"text-color": "#aad",
|
|
5014
|
-
"format-value":
|
|
5021
|
+
"format-value": d,
|
|
5015
5022
|
"parse-value": Q,
|
|
5016
5023
|
"validate-input": V,
|
|
5017
5024
|
"transform-slider-to-display": t,
|
|
@@ -5022,8 +5029,8 @@ const zU = {
|
|
|
5022
5029
|
}
|
|
5023
5030
|
}, _U = {
|
|
5024
5031
|
__name: "TimeInput",
|
|
5025
|
-
setup(
|
|
5026
|
-
const l = Ul(), U = tl(), F = Rl(),
|
|
5032
|
+
setup(Z) {
|
|
5033
|
+
const l = Ul(), U = tl(), F = Rl(), d = (a) => a.toFixed(1), Q = (a) => parseFloat(a), V = (a) => a.replace(/[^0-9.]/g, ""), t = (a) => a, R = (a) => a;
|
|
5027
5034
|
return (a, n) => (X(), nl(ql, {
|
|
5028
5035
|
value: r(l).currentTime,
|
|
5029
5036
|
"onUpdate:value": [
|
|
@@ -5037,7 +5044,7 @@ const zU = {
|
|
|
5037
5044
|
"background-color": "#111117",
|
|
5038
5045
|
"slider-max": r(U).totalDuration,
|
|
5039
5046
|
"slider-min": 0,
|
|
5040
|
-
"format-value":
|
|
5047
|
+
"format-value": d,
|
|
5041
5048
|
"parse-value": Q,
|
|
5042
5049
|
"validate-input": V,
|
|
5043
5050
|
"transform-slider-to-display": t,
|
|
@@ -5047,16 +5054,16 @@ const zU = {
|
|
|
5047
5054
|
}
|
|
5048
5055
|
}, $U = { class: "inner" }, lF = {
|
|
5049
5056
|
__name: "AudioButton",
|
|
5050
|
-
setup(
|
|
5057
|
+
setup(Z) {
|
|
5051
5058
|
const l = x(!1), U = () => l.value = !0, F = () => l.value = !1;
|
|
5052
|
-
return (
|
|
5059
|
+
return (d, Q) => (X(), Y("div", {
|
|
5053
5060
|
class: L(["button-outer", { down: l.value }]),
|
|
5054
5061
|
onPointerdown: U,
|
|
5055
5062
|
onPointerup: F,
|
|
5056
5063
|
onPointerleave: F
|
|
5057
5064
|
}, [
|
|
5058
5065
|
h("div", $U, [
|
|
5059
|
-
Vl(
|
|
5066
|
+
Vl(d.$slots, "default", {}, void 0, !0)
|
|
5060
5067
|
])
|
|
5061
5068
|
], 34));
|
|
5062
5069
|
}
|
|
@@ -5065,9 +5072,9 @@ const zU = {
|
|
|
5065
5072
|
viewBox: "0 0 48 48"
|
|
5066
5073
|
}, QF = ["d"], VF = {
|
|
5067
5074
|
__name: "MixerControls",
|
|
5068
|
-
setup(
|
|
5075
|
+
setup(Z) {
|
|
5069
5076
|
const l = tl(), U = Ul(), F = Rl();
|
|
5070
|
-
function
|
|
5077
|
+
function d() {
|
|
5071
5078
|
U.isPlaying ? F.stop() : F.play();
|
|
5072
5079
|
}
|
|
5073
5080
|
function Q() {
|
|
@@ -5190,7 +5197,7 @@ const zU = {
|
|
|
5190
5197
|
}),
|
|
5191
5198
|
C(Fl, {
|
|
5192
5199
|
class: "button",
|
|
5193
|
-
onClick:
|
|
5200
|
+
onClick: d
|
|
5194
5201
|
}, {
|
|
5195
5202
|
default: D(() => [
|
|
5196
5203
|
(X(), Y("svg", ZF, [
|
|
@@ -5295,8 +5302,8 @@ const zU = {
|
|
|
5295
5302
|
default: null
|
|
5296
5303
|
}
|
|
5297
5304
|
},
|
|
5298
|
-
setup(
|
|
5299
|
-
const l =
|
|
5305
|
+
setup(Z) {
|
|
5306
|
+
const l = Z, U = G(() => l.progress !== null), F = G(() => l.progress === null ? 0 : Math.max(0, Math.min(100, l.progress * 100))), d = G(() => l.hasError ? l.errorMessage : l.message);
|
|
5300
5307
|
return (Q, V) => (X(), Y("div", RF, [
|
|
5301
5308
|
U.value ? (X(), Y("div", aF, [
|
|
5302
5309
|
h("div", {
|
|
@@ -5306,8 +5313,8 @@ const zU = {
|
|
|
5306
5313
|
])) : f("", !0),
|
|
5307
5314
|
h("div", nF, [
|
|
5308
5315
|
h("div", {
|
|
5309
|
-
class: L(["message", { error:
|
|
5310
|
-
}, K(
|
|
5316
|
+
class: L(["message", { error: Z.hasError }])
|
|
5317
|
+
}, K(d.value), 3)
|
|
5311
5318
|
])
|
|
5312
5319
|
]));
|
|
5313
5320
|
}
|
|
@@ -5335,15 +5342,15 @@ const zU = {
|
|
|
5335
5342
|
* @param {string} event.message - Human-readable message
|
|
5336
5343
|
* @param {number} [event.progress] - Optional progress (0-1)
|
|
5337
5344
|
*/
|
|
5338
|
-
updateProgress(
|
|
5339
|
-
this.currentStage =
|
|
5345
|
+
updateProgress(Z) {
|
|
5346
|
+
this.currentStage = Z.stage, this.message = Z.message, this.progress = Z.progress ?? null, Z.stage === "ready" ? (this.isInitializing = !1, this.isReady = !0) : (this.isInitializing = !0, this.isReady = !1), this.hasError = !1, this.errorMessage = null;
|
|
5340
5347
|
},
|
|
5341
5348
|
/**
|
|
5342
5349
|
* Set error state
|
|
5343
5350
|
* @param {string} message - Error message
|
|
5344
5351
|
*/
|
|
5345
|
-
setError(
|
|
5346
|
-
this.hasError = !0, this.errorMessage =
|
|
5352
|
+
setError(Z) {
|
|
5353
|
+
this.hasError = !0, this.errorMessage = Z, this.isInitializing = !1, this.isReady = !1;
|
|
5347
5354
|
},
|
|
5348
5355
|
/**
|
|
5349
5356
|
* Reset initialization state
|
|
@@ -5356,8 +5363,8 @@ const zU = {
|
|
|
5356
5363
|
* Should be called once during app startup
|
|
5357
5364
|
*/
|
|
5358
5365
|
initializeListeners() {
|
|
5359
|
-
e.on("initProgress", (
|
|
5360
|
-
this.updateProgress(
|
|
5366
|
+
e.on("initProgress", (Z) => {
|
|
5367
|
+
this.updateProgress(Z);
|
|
5361
5368
|
});
|
|
5362
5369
|
}
|
|
5363
5370
|
},
|
|
@@ -5365,12 +5372,12 @@ const zU = {
|
|
|
5365
5372
|
/**
|
|
5366
5373
|
* Whether to show the progress indicator
|
|
5367
5374
|
*/
|
|
5368
|
-
shouldShowProgress: (
|
|
5375
|
+
shouldShowProgress: (Z) => Z.isInitializing || Z.hasError,
|
|
5369
5376
|
/**
|
|
5370
5377
|
* Whether the progress bar should be visible
|
|
5371
5378
|
* Only show for stages that have progress data
|
|
5372
5379
|
*/
|
|
5373
|
-
hasProgressBar: (
|
|
5380
|
+
hasProgressBar: (Z) => Z.progress !== null
|
|
5374
5381
|
}
|
|
5375
5382
|
}), cF = { class: "container" }, eF = { class: "panel" }, sF = {
|
|
5376
5383
|
key: 0,
|
|
@@ -5384,15 +5391,15 @@ const zU = {
|
|
|
5384
5391
|
default: !0
|
|
5385
5392
|
}
|
|
5386
5393
|
},
|
|
5387
|
-
setup(
|
|
5394
|
+
setup(Z) {
|
|
5388
5395
|
$((W) => ({
|
|
5389
5396
|
"53ffcc08": a.value,
|
|
5390
5397
|
"53f8f922": n.value,
|
|
5391
5398
|
"2b0b3d37": m.value
|
|
5392
5399
|
}));
|
|
5393
|
-
const l =
|
|
5400
|
+
const l = Z, U = tl(), F = Ul(), d = bF();
|
|
5394
5401
|
el(() => {
|
|
5395
|
-
|
|
5402
|
+
d.initializeListeners();
|
|
5396
5403
|
});
|
|
5397
5404
|
const Q = O("container"), { width: V } = ll(Q), t = G(() => F.isLoaded), R = G(() => {
|
|
5398
5405
|
const W = V.value, c = U.parts.length;
|
|
@@ -5453,13 +5460,13 @@ const zU = {
|
|
|
5453
5460
|
_: 3
|
|
5454
5461
|
}, 8, ["title"]),
|
|
5455
5462
|
t.value ? f("", !0) : (X(), Y("div", sF)),
|
|
5456
|
-
l.showInitProgress && r(
|
|
5463
|
+
l.showInitProgress && r(d).shouldShowProgress ? (X(), nl(WF, {
|
|
5457
5464
|
key: 1,
|
|
5458
|
-
stage: r(
|
|
5459
|
-
message: r(
|
|
5460
|
-
progress: r(
|
|
5461
|
-
"has-error": r(
|
|
5462
|
-
"error-message": r(
|
|
5465
|
+
stage: r(d).currentStage,
|
|
5466
|
+
message: r(d).message,
|
|
5467
|
+
progress: r(d).progress,
|
|
5468
|
+
"has-error": r(d).hasError,
|
|
5469
|
+
"error-message": r(d).errorMessage
|
|
5463
5470
|
}, null, 8, ["stage", "message", "progress", "has-error", "error-message"])) : f("", !0)
|
|
5464
5471
|
])
|
|
5465
5472
|
])
|
|
@@ -5480,14 +5487,14 @@ const zU = {
|
|
|
5480
5487
|
default: ""
|
|
5481
5488
|
}
|
|
5482
5489
|
},
|
|
5483
|
-
setup(
|
|
5490
|
+
setup(Z) {
|
|
5484
5491
|
return $((l) => ({
|
|
5485
|
-
"66bea586":
|
|
5492
|
+
"66bea586": Z.colour
|
|
5486
5493
|
})), (l, U) => (X(), Y("div", SF, [
|
|
5487
5494
|
h("div", oF, [
|
|
5488
5495
|
h("div", XF, [
|
|
5489
|
-
|
|
5490
|
-
ol(K(
|
|
5496
|
+
Z.text || l.$slots.default ? (X(), Y("div", NF, [
|
|
5497
|
+
ol(K(Z.text) + " ", 1),
|
|
5491
5498
|
Vl(l.$slots, "default", {}, void 0, !0)
|
|
5492
5499
|
])) : f("", !0)
|
|
5493
5500
|
])
|
|
@@ -5503,7 +5510,7 @@ class YF {
|
|
|
5503
5510
|
initialize(l) {
|
|
5504
5511
|
if (this.musicData = l, this.beats = l.beats || [], this.practiceMarks = l.practiceMarks || {}, this.beats.length > 0) {
|
|
5505
5512
|
const U = this.beats[this.beats.length - 1], F = U.tempo > 0 ? 60 / U.tempo : 0.75;
|
|
5506
|
-
this.songDuration = U.time + F, this.maxBar = Math.max(...this.beats.map((
|
|
5513
|
+
this.songDuration = U.time + F, this.maxBar = Math.max(...this.beats.map((d) => d.bar));
|
|
5507
5514
|
} else
|
|
5508
5515
|
this.songDuration = 0, this.maxBar = 0;
|
|
5509
5516
|
l.parts && l.parts.forEach((U) => {
|
|
@@ -5601,8 +5608,8 @@ class YF {
|
|
|
5601
5608
|
return;
|
|
5602
5609
|
}
|
|
5603
5610
|
this.eventBus.emit("timeChanged", { currentTime: this.currentTime });
|
|
5604
|
-
const
|
|
5605
|
-
if (
|
|
5611
|
+
const d = this.getBarFromTime(this.currentTime);
|
|
5612
|
+
if (d && (this.eventBus.emit("barChanged", d), this.maxBar > 0 && d.bar > this.maxBar)) {
|
|
5606
5613
|
this.stop(), this.eventBus.emit("songEnded", { finalTime: this.currentTime });
|
|
5607
5614
|
return;
|
|
5608
5615
|
}
|
|
@@ -5631,10 +5638,10 @@ class YF {
|
|
|
5631
5638
|
getTimeFromBar(l, U = 0) {
|
|
5632
5639
|
if (!this.beats || this.beats.length === 0) return null;
|
|
5633
5640
|
let F = this.beats.find(
|
|
5634
|
-
(
|
|
5641
|
+
(d) => d.bar === l && d.beat === 1 && d.repeat === U
|
|
5635
5642
|
);
|
|
5636
5643
|
return F || (F = this.beats.find(
|
|
5637
|
-
(
|
|
5644
|
+
(d) => d.bar === l && d.beat === 1
|
|
5638
5645
|
)), F ? F.time : null;
|
|
5639
5646
|
}
|
|
5640
5647
|
destroy() {
|