audio-mixer-engine 1.3.5 → 1.3.6
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function sl(V) {
|
|
2
2
|
return { all: V = V || /* @__PURE__ */ new Map(), on: function(l, U) {
|
|
3
3
|
var F = V.get(l);
|
|
4
4
|
F ? F.push(U) : V.set(l, [U]);
|
|
@@ -24,7 +24,7 @@ class dl {
|
|
|
24
24
|
constructor(l, U = {}) {
|
|
25
25
|
if (new.target === dl)
|
|
26
26
|
throw new Error("AudioEngine is abstract and cannot be instantiated directly");
|
|
27
|
-
this.audioContext = l, this.options = U, this.isInitialized = !1, this.channels = /* @__PURE__ */ new WeakMap(), this.activeChannels = /* @__PURE__ */ new Set(), this.eventBus =
|
|
27
|
+
this.audioContext = l, this.options = U, this.isInitialized = !1, this.channels = /* @__PURE__ */ new WeakMap(), this.activeChannels = /* @__PURE__ */ new Set(), this.eventBus = sl();
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Subscribe to engine events
|
|
@@ -1578,8 +1578,8 @@ class Pl {
|
|
|
1578
1578
|
m = W + U * 4 * R.numerator / R.denominator;
|
|
1579
1579
|
const t = R.numerator, c = [], b = U * (4 / R.denominator);
|
|
1580
1580
|
for (let a = 0; a < t; a++) {
|
|
1581
|
-
const
|
|
1582
|
-
c.push(
|
|
1581
|
+
const s = W + a * b, J = this._ticksToTime(s, l);
|
|
1582
|
+
c.push(J);
|
|
1583
1583
|
}
|
|
1584
1584
|
d.push({
|
|
1585
1585
|
sig: [R.numerator, R.denominator],
|
|
@@ -1992,22 +1992,22 @@ class Ol {
|
|
|
1992
1992
|
// Total beats
|
|
1993
1993
|
t.sig[1]
|
|
1994
1994
|
// Keep original note value
|
|
1995
|
-
],
|
|
1995
|
+
], s = [
|
|
1996
1996
|
...t.beats || [],
|
|
1997
1997
|
...b.beats || []
|
|
1998
1998
|
];
|
|
1999
1999
|
t = {
|
|
2000
2000
|
sig: a,
|
|
2001
|
-
beats:
|
|
2001
|
+
beats: s
|
|
2002
2002
|
}, R[d] = t, R.splice(d + 1, 1), c = a[0];
|
|
2003
2003
|
}
|
|
2004
2004
|
if (c > m) {
|
|
2005
|
-
const b = m, a = c - m,
|
|
2005
|
+
const b = m, a = c - m, s = t.beats ? t.beats.slice(0, b) : [], J = t.beats ? t.beats.slice(b) : [], i = {
|
|
2006
2006
|
sig: [b, t.sig[1]],
|
|
2007
|
-
beats:
|
|
2007
|
+
beats: s
|
|
2008
2008
|
}, S = {
|
|
2009
2009
|
sig: [a, t.sig[1]],
|
|
2010
|
-
beats:
|
|
2010
|
+
beats: J
|
|
2011
2011
|
};
|
|
2012
2012
|
R[d] = i, R.splice(d + 1, 0, S), t = i;
|
|
2013
2013
|
}
|
|
@@ -2025,14 +2025,14 @@ class Ol {
|
|
|
2025
2025
|
const t = l[Q], c = t.barNumber, b = Z[c] !== void 0 ? Z[c] : 4;
|
|
2026
2026
|
Z[c] === void 0 && (Z[c] = b);
|
|
2027
2027
|
const a = [];
|
|
2028
|
-
for (let
|
|
2028
|
+
for (let J = 0; J < b; J++)
|
|
2029
2029
|
a.push(m), m += n;
|
|
2030
|
-
const
|
|
2030
|
+
const s = {
|
|
2031
2031
|
sig: [b, 4],
|
|
2032
2032
|
// Default to quarter notes
|
|
2033
2033
|
beats: a
|
|
2034
2034
|
};
|
|
2035
|
-
this._generateBeatsForBar(F, t,
|
|
2035
|
+
this._generateBeatsForBar(F, t, s, b), Q++;
|
|
2036
2036
|
}
|
|
2037
2037
|
}
|
|
2038
2038
|
return F;
|
|
@@ -2086,7 +2086,7 @@ class tl {
|
|
|
2086
2086
|
constructor(l = null, U, F = null, Z = null) {
|
|
2087
2087
|
if (!U)
|
|
2088
2088
|
throw new Error("Parsed MIDI data is required");
|
|
2089
|
-
this.audioEngine = l, this._audioEngineReady = !!(l && l.isInitialized), this.instrumentMap = F || {}, this.parsedData = U, this._isPlaying = !1, this._isPreScheduling = !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 =
|
|
2089
|
+
this.audioEngine = l, this._audioEngineReady = !!(l && l.isInitialized), this.instrumentMap = F || {}, this.parsedData = U, this._isPlaying = !1, this._isPreScheduling = !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 = sl(), this.beatMapper = new Ol(), this.beats = [], this.structureMetadata = Z, this._calculateTotalDuration();
|
|
2090
2090
|
const d = Z || this._createDefaultStructureMetadata();
|
|
2091
2091
|
this.beats = this.beatMapper.mapBeats(U, d), this._audioEngineReady && (this._setupPartChannels(), this._resetNotePointers(), this._resetProgramPointers());
|
|
2092
2092
|
}
|
|
@@ -2871,11 +2871,11 @@ class nU {
|
|
|
2871
2871
|
continue;
|
|
2872
2872
|
}
|
|
2873
2873
|
if (n.tagName !== "note") continue;
|
|
2874
|
-
const m = G(n, "chord") !== null, t = G(n, "rest") !== null, c = G(n, "grace") !== null, b = y(n, "duration", 0), a = this.timing.xmlDurationToTicks(b),
|
|
2874
|
+
const m = G(n, "chord") !== null, t = G(n, "rest") !== null, c = G(n, "grace") !== null, b = y(n, "duration", 0), a = this.timing.xmlDurationToTicks(b), s = G(n, "time-modification") !== null;
|
|
2875
2875
|
if (c) continue;
|
|
2876
2876
|
m && (R = W);
|
|
2877
|
-
const
|
|
2878
|
-
if (m || (W = R), R =
|
|
2877
|
+
const J = R;
|
|
2878
|
+
if (m || (W = R), R = J + a, t) continue;
|
|
2879
2879
|
const i = G(n, "pitch");
|
|
2880
2880
|
if (!i) continue;
|
|
2881
2881
|
const S = VU(i), Y = p(n, "tie");
|
|
@@ -2886,19 +2886,19 @@ class nU {
|
|
|
2886
2886
|
}
|
|
2887
2887
|
if (D && this.pendingTies.has(S)) {
|
|
2888
2888
|
const X = this.pendingTies.get(S);
|
|
2889
|
-
L ? (X.endTick =
|
|
2889
|
+
L ? (X.endTick = J + a, X.isTuplet = X.isTuplet || s) : (X.endTick = J + a, X.isTuplet = X.isTuplet || s, d.push(this._buildNote(X, F, Z)), this.pendingTies.delete(S));
|
|
2890
2890
|
} else L ? this.pendingTies.set(S, {
|
|
2891
2891
|
pitch: S,
|
|
2892
|
-
startTick:
|
|
2893
|
-
endTick:
|
|
2892
|
+
startTick: J,
|
|
2893
|
+
endTick: J + a,
|
|
2894
2894
|
velocity: this.currentVelocity,
|
|
2895
|
-
isTuplet:
|
|
2895
|
+
isTuplet: s
|
|
2896
2896
|
}) : d.push(this._buildNote({
|
|
2897
2897
|
pitch: S,
|
|
2898
|
-
startTick:
|
|
2899
|
-
endTick:
|
|
2898
|
+
startTick: J,
|
|
2899
|
+
endTick: J + a,
|
|
2900
2900
|
velocity: this.currentVelocity,
|
|
2901
|
-
isTuplet:
|
|
2901
|
+
isTuplet: s
|
|
2902
2902
|
}, F, Z));
|
|
2903
2903
|
const A = p(n, "lyric");
|
|
2904
2904
|
for (const X of A) {
|
|
@@ -2908,9 +2908,9 @@ class nU {
|
|
|
2908
2908
|
Q.push({
|
|
2909
2909
|
text: C,
|
|
2910
2910
|
syllabic: K || "single",
|
|
2911
|
-
tick:
|
|
2912
|
-
time: this.timing.tickToTime(
|
|
2913
|
-
isTuplet:
|
|
2911
|
+
tick: J,
|
|
2912
|
+
time: this.timing.tickToTime(J),
|
|
2913
|
+
isTuplet: s
|
|
2914
2914
|
});
|
|
2915
2915
|
}
|
|
2916
2916
|
}
|
|
@@ -3022,7 +3022,7 @@ function WU(V) {
|
|
|
3022
3022
|
const c = G(m, "ending");
|
|
3023
3023
|
if (c) {
|
|
3024
3024
|
const b = O(c, "type"), a = O(c, "number");
|
|
3025
|
-
b === "start" && a && (Q.endings = a.split(/[,\s]+/).map((
|
|
3025
|
+
b === "start" && a && (Q.endings = a.split(/[,\s]+/).map((s) => parseInt(s.trim(), 10)).filter((s) => !isNaN(s))), (b === "stop" || b === "discontinue") && (Q.endingStop = !0);
|
|
3026
3026
|
}
|
|
3027
3027
|
}
|
|
3028
3028
|
const W = p(d, "direction");
|
|
@@ -3033,10 +3033,10 @@ function WU(V) {
|
|
|
3033
3033
|
b && (Q.segno = b);
|
|
3034
3034
|
const a = t.getAttribute("coda");
|
|
3035
3035
|
a && (Q.coda = a), t.getAttribute("fine") === "yes" && (Q.fine = !0), t.getAttribute("dacapo") === "yes" && (Q.dacapo = !0);
|
|
3036
|
-
const
|
|
3037
|
-
|
|
3038
|
-
const
|
|
3039
|
-
|
|
3036
|
+
const s = t.getAttribute("dalsegno");
|
|
3037
|
+
s && (Q.dalsegno = s);
|
|
3038
|
+
const J = t.getAttribute("tocoda");
|
|
3039
|
+
J && (Q.tocoda = J);
|
|
3040
3040
|
const i = t.getAttribute("tempo");
|
|
3041
3041
|
i && (Q.tempo = parseFloat(i));
|
|
3042
3042
|
}
|
|
@@ -3159,7 +3159,7 @@ function bU(V) {
|
|
|
3159
3159
|
F++;
|
|
3160
3160
|
continue;
|
|
3161
3161
|
}
|
|
3162
|
-
W =
|
|
3162
|
+
W = sU(V, b), R = !W, F = b;
|
|
3163
3163
|
continue;
|
|
3164
3164
|
}
|
|
3165
3165
|
F++;
|
|
@@ -3182,12 +3182,12 @@ function BU(V, l) {
|
|
|
3182
3182
|
if (V[U].coda === l) return U;
|
|
3183
3183
|
return -1;
|
|
3184
3184
|
}
|
|
3185
|
-
function
|
|
3185
|
+
function sU(V, l) {
|
|
3186
3186
|
for (let U = l; U < V.length; U++)
|
|
3187
3187
|
if (V[U].tocoda) return V[U].tocoda;
|
|
3188
3188
|
return null;
|
|
3189
3189
|
}
|
|
3190
|
-
function
|
|
3190
|
+
function JU(V) {
|
|
3191
3191
|
if (V.length === 0) return [];
|
|
3192
3192
|
const l = [];
|
|
3193
3193
|
let U = null;
|
|
@@ -3258,7 +3258,7 @@ class GU {
|
|
|
3258
3258
|
denominator: b.currentTimeSig.denominator
|
|
3259
3259
|
}]
|
|
3260
3260
|
});
|
|
3261
|
-
const a = {},
|
|
3261
|
+
const a = {}, s = /* @__PURE__ */ new Map();
|
|
3262
3262
|
for (let h = 0; h < R.length; h++) {
|
|
3263
3263
|
const B = R[h], e = O(B, "id"), N = Q.partInfos.find((x) => x.id === e) || {
|
|
3264
3264
|
id: e,
|
|
@@ -3266,7 +3266,7 @@ class GU {
|
|
|
3266
3266
|
midiProgram: null,
|
|
3267
3267
|
midiChannel: null
|
|
3268
3268
|
};
|
|
3269
|
-
|
|
3269
|
+
s.set(e, {
|
|
3270
3270
|
partElement: B,
|
|
3271
3271
|
measures: p(B, "measure"),
|
|
3272
3272
|
channel: h,
|
|
@@ -3282,7 +3282,7 @@ class GU {
|
|
|
3282
3282
|
// Default to choir_aahs
|
|
3283
3283
|
};
|
|
3284
3284
|
}
|
|
3285
|
-
const
|
|
3285
|
+
const J = [], i = JU(t), S = eU(n), Y = /* @__PURE__ */ new Map();
|
|
3286
3286
|
for (let h = 0; h < W.length; h++) {
|
|
3287
3287
|
const B = W[h], e = G(B, "attributes"), N = {};
|
|
3288
3288
|
if (e) {
|
|
@@ -3313,7 +3313,7 @@ class GU {
|
|
|
3313
3313
|
Y.set(h, N);
|
|
3314
3314
|
}
|
|
3315
3315
|
const L = /* @__PURE__ */ new Map();
|
|
3316
|
-
for (const [h, B] of
|
|
3316
|
+
for (const [h, B] of s)
|
|
3317
3317
|
L.set(h, new nU(c, {
|
|
3318
3318
|
defaultVelocity: U.defaultVelocity || 80
|
|
3319
3319
|
}));
|
|
@@ -3321,8 +3321,8 @@ class GU {
|
|
|
3321
3321
|
const B = h.measureIndex, e = Y.get(B) || {};
|
|
3322
3322
|
e.divisions && (c.currentDivisions = e.divisions), e.timeSig && (c.currentTimeSig = { ...e.timeSig }), e.tempo && c.processTempo(e.tempo), e.swing && c.processSwing(e.swing);
|
|
3323
3323
|
const N = c.currentTick, x = h.beatsInMeasure, E = c.generateBarStructureEntry(N, x);
|
|
3324
|
-
|
|
3325
|
-
for (const [o, H] of
|
|
3324
|
+
J.push(E);
|
|
3325
|
+
for (const [o, H] of s) {
|
|
3326
3326
|
const j = H.measures[B];
|
|
3327
3327
|
if (!j) continue;
|
|
3328
3328
|
const f = L.get(o), { notes: q, lyrics: Fl } = f.extractMeasure(
|
|
@@ -3336,7 +3336,7 @@ class GU {
|
|
|
3336
3336
|
const M = c.getTicksPerBeatInTimeSig() * x;
|
|
3337
3337
|
c.advance(M);
|
|
3338
3338
|
}
|
|
3339
|
-
for (const [h, B] of
|
|
3339
|
+
for (const [h, B] of s) {
|
|
3340
3340
|
const N = L.get(h).flushPendingTies(B.channel, B.trackIndex), x = B.partInfo.name;
|
|
3341
3341
|
a[x].notes.push(...N);
|
|
3342
3342
|
}
|
|
@@ -3363,7 +3363,7 @@ class GU {
|
|
|
3363
3363
|
index: B,
|
|
3364
3364
|
name: h.name
|
|
3365
3365
|
})), X = {};
|
|
3366
|
-
for (const [h, B] of
|
|
3366
|
+
for (const [h, B] of s) {
|
|
3367
3367
|
const e = B.partInfo.name;
|
|
3368
3368
|
X[e] = {
|
|
3369
3369
|
trackIndex: B.trackIndex,
|
|
@@ -3373,7 +3373,7 @@ class GU {
|
|
|
3373
3373
|
}
|
|
3374
3374
|
const C = {
|
|
3375
3375
|
parts: a,
|
|
3376
|
-
barStructure:
|
|
3376
|
+
barStructure: J,
|
|
3377
3377
|
metadata: {
|
|
3378
3378
|
title: Q.title,
|
|
3379
3379
|
composer: Q.composer,
|
|
@@ -3558,7 +3558,7 @@ var oU = /* @__PURE__ */ ll(Ul, 9, 1), YU = /* @__PURE__ */ ll(Ll, 5, 1), nl = f
|
|
|
3558
3558
|
return (V[U] | V[U + 1] << 8 | V[U + 2] << 16) >> (l & 7);
|
|
3559
3559
|
}, yU = function(V) {
|
|
3560
3560
|
return (V + 7) / 8 | 0;
|
|
3561
|
-
},
|
|
3561
|
+
}, Jl = function(V, l, U) {
|
|
3562
3562
|
return (l == null || l < 0) && (l = 0), (U == null || U > V.length) && (U = V.length), new T(V.subarray(l, U));
|
|
3563
3563
|
}, pU = [
|
|
3564
3564
|
"unexpected EOF",
|
|
@@ -3593,14 +3593,14 @@ var oU = /* @__PURE__ */ ll(Ul, 9, 1), YU = /* @__PURE__ */ ll(Ll, 5, 1), nl = f
|
|
|
3593
3593
|
var ul = new T(Math.max(Sl * 2, il));
|
|
3594
3594
|
ul.set(U), U = ul;
|
|
3595
3595
|
}
|
|
3596
|
-
}, m = l.f || 0, t = l.p || 0, c = l.b || 0, b = l.l, a = l.d,
|
|
3596
|
+
}, m = l.f || 0, t = l.p || 0, c = l.b || 0, b = l.l, a = l.d, s = l.m, J = l.n, i = Z * 8;
|
|
3597
3597
|
do {
|
|
3598
3598
|
if (!b) {
|
|
3599
3599
|
m = z(V, t, 1);
|
|
3600
3600
|
var S = z(V, t + 1, 3);
|
|
3601
3601
|
if (t += 3, S)
|
|
3602
3602
|
if (S == 1)
|
|
3603
|
-
b = oU, a = YU,
|
|
3603
|
+
b = oU, a = YU, s = 9, J = 5;
|
|
3604
3604
|
else if (S == 2) {
|
|
3605
3605
|
var A = z(V, t, 31) + 257, X = z(V, t + 10, 15) + 4, C = A + z(V, t + 5, 31) + 1;
|
|
3606
3606
|
t += 14;
|
|
@@ -3620,7 +3620,7 @@ var oU = /* @__PURE__ */ ll(Ul, 9, 1), YU = /* @__PURE__ */ ll(Ll, 5, 1), nl = f
|
|
|
3620
3620
|
}
|
|
3621
3621
|
}
|
|
3622
3622
|
var M = K.subarray(0, A), o = K.subarray(A);
|
|
3623
|
-
|
|
3623
|
+
s = nl(M), J = nl(o), b = ll(M, s, 1), a = ll(o, J, 1);
|
|
3624
3624
|
} else
|
|
3625
3625
|
r(1);
|
|
3626
3626
|
else {
|
|
@@ -3638,7 +3638,7 @@ var oU = /* @__PURE__ */ ll(Ul, 9, 1), YU = /* @__PURE__ */ ll(Ll, 5, 1), nl = f
|
|
|
3638
3638
|
}
|
|
3639
3639
|
}
|
|
3640
3640
|
R && n(c + 131072);
|
|
3641
|
-
for (var H = (1 <<
|
|
3641
|
+
for (var H = (1 << s) - 1, j = (1 << J) - 1, f = t; ; f = t) {
|
|
3642
3642
|
var E = b[Wl(V, t) & H], q = E >> 4;
|
|
3643
3643
|
if (t += E & 15, t > i) {
|
|
3644
3644
|
W && r(0);
|
|
@@ -3677,9 +3677,9 @@ var oU = /* @__PURE__ */ ll(Ul, 9, 1), YU = /* @__PURE__ */ ll(Ll, 5, 1), nl = f
|
|
|
3677
3677
|
U[c] = U[c - o];
|
|
3678
3678
|
}
|
|
3679
3679
|
}
|
|
3680
|
-
l.l = b, l.p = f, l.b = c, l.f = m, b && (m = 1, l.m =
|
|
3680
|
+
l.l = b, l.p = f, l.b = c, l.f = m, b && (m = 1, l.m = s, l.d = a, l.n = J);
|
|
3681
3681
|
} while (!m);
|
|
3682
|
-
return c != U.length && Q ?
|
|
3682
|
+
return c != U.length && Q ? Jl(U, 0, c) : U.subarray(0, c);
|
|
3683
3683
|
}, kU = /* @__PURE__ */ new T(0), g = function(V, l) {
|
|
3684
3684
|
return V[l] | V[l + 1] << 8;
|
|
3685
3685
|
}, I = function(V, l) {
|
|
@@ -3699,7 +3699,7 @@ var LU = function(V) {
|
|
|
3699
3699
|
for (var l = "", U = 0; ; ) {
|
|
3700
3700
|
var F = V[U++], Z = (F > 127) + (F > 223) + (F > 239);
|
|
3701
3701
|
if (U + Z > V.length)
|
|
3702
|
-
return { s: l, r:
|
|
3702
|
+
return { s: l, r: Jl(V, U - 1) };
|
|
3703
3703
|
Z ? Z == 3 ? (F = ((F & 15) << 18 | (V[U++] & 63) << 12 | (V[U++] & 63) << 6 | V[U++] & 63) - 65536, l += String.fromCharCode(55296 | F >> 10, 56320 | F & 1023)) : Z & 1 ? l += String.fromCharCode((F & 31) << 6 | V[U++] & 63) : l += String.fromCharCode((F & 15) << 12 | (V[U++] & 63) << 6 | V[U++] & 63) : l += String.fromCharCode(F);
|
|
3704
3704
|
}
|
|
3705
3705
|
};
|
|
@@ -3737,8 +3737,8 @@ function zU(V, l) {
|
|
|
3737
3737
|
Q = I(V, R) == 101075792, Q && (Z = I(V, R + 32), d = I(V, R + 48));
|
|
3738
3738
|
}
|
|
3739
3739
|
for (var W = 0; W < Z; ++W) {
|
|
3740
|
-
var n = xU(V, d, Q), m = n[0], t = n[1], c = n[2], b = n[3], a = n[4],
|
|
3741
|
-
d = a, m ? m == 8 ? U[b] = TU(V.subarray(
|
|
3740
|
+
var n = xU(V, d, Q), m = n[0], t = n[1], c = n[2], b = n[3], a = n[4], s = n[5], J = CU(V, s);
|
|
3741
|
+
d = a, m ? m == 8 ? U[b] = TU(V.subarray(J, J + t), { out: new T(c) }) : r(14, "unknown compression type " + m) : U[b] = Jl(V, J, J + t);
|
|
3742
3742
|
}
|
|
3743
3743
|
return U;
|
|
3744
3744
|
}
|
|
@@ -3844,7 +3844,7 @@ class jU {
|
|
|
3844
3844
|
* @param {number} [options.startup.delayMs=25] - Startup delay in milliseconds
|
|
3845
3845
|
*/
|
|
3846
3846
|
constructor(l = null, U = {}) {
|
|
3847
|
-
l instanceof tl ? (this.audioEngine = l.audioEngine, this.midiPlayer = l, this.parsedData = l.parsedData, this._audioEngineReady = !!(this.audioEngine && this.audioEngine.isInitialized)) : (this.audioEngine = l, this._audioEngineReady = !!(l && l.isInitialized), this.midiPlayer = null, this.parsedData = null), this.eventBus =
|
|
3847
|
+
l instanceof tl ? (this.audioEngine = l.audioEngine, this.midiPlayer = l, this.parsedData = l.parsedData, this._audioEngineReady = !!(this.audioEngine && this.audioEngine.isInitialized)) : (this.audioEngine = l, this._audioEngineReady = !!(l && l.isInitialized), this.midiPlayer = null, this.parsedData = null), this.eventBus = sl(), this._parser = new Pl(), this._musicXmlConverter = new GU(), this._partOutputsMap = /* @__PURE__ */ new Map(), this.instrumentMap = null, this.metronomeConfig = {
|
|
3848
3848
|
enabled: !1,
|
|
3849
3849
|
tickInstrument: 115,
|
|
3850
3850
|
// woodblock
|
|
@@ -4007,8 +4007,8 @@ class jU {
|
|
|
4007
4007
|
*/
|
|
4008
4008
|
stop() {
|
|
4009
4009
|
if (this.state === "stopped") return;
|
|
4010
|
-
const l = this.state
|
|
4011
|
-
this.
|
|
4010
|
+
const l = this.state;
|
|
4011
|
+
l === "lead-in" ? this._pauseLeadIn() : l === "playing" && (this.midiPlayer.pause(), this._stopMetronome()), this._stopLeadIn(), this._stopTimeUpdateLoop(), this.frozenTime = 0, this.leadInData = null, this.leadInProgress = null, this.leadInStartTime = null, this.midiPlayer && this.midiPlayer.skipToTime(0), this._resetMetronomeBeatTracking(), this.state = "stopped", this._emitEvent("playbackStopped", {});
|
|
4012
4012
|
}
|
|
4013
4013
|
// ========================================
|
|
4014
4014
|
// PUBLIC API - Positioning Methods
|
|
@@ -4998,19 +4998,19 @@ class jU {
|
|
|
4998
4998
|
return;
|
|
4999
4999
|
}
|
|
5000
5000
|
l.getFloatTimeDomainData(W);
|
|
5001
|
-
let a = 0,
|
|
5001
|
+
let a = 0, s = 0;
|
|
5002
5002
|
for (let i = 0; i < R; i++) {
|
|
5003
5003
|
const S = Math.abs(W[i]);
|
|
5004
|
-
a += W[i] * W[i], S >
|
|
5004
|
+
a += W[i] * W[i], S > s && (s = S);
|
|
5005
5005
|
}
|
|
5006
|
-
const
|
|
5007
|
-
if (
|
|
5006
|
+
const J = Math.sqrt(a / R);
|
|
5007
|
+
if (J >= Z) {
|
|
5008
5008
|
clearInterval(c);
|
|
5009
5009
|
const i = Q.currentTime, S = (i - U) * 1e3;
|
|
5010
5010
|
t({
|
|
5011
5011
|
latencyMs: S,
|
|
5012
|
-
rms:
|
|
5013
|
-
peak:
|
|
5012
|
+
rms: J,
|
|
5013
|
+
peak: s,
|
|
5014
5014
|
detectedTime: i
|
|
5015
5015
|
});
|
|
5016
5016
|
}
|
|
@@ -5035,18 +5035,18 @@ class jU {
|
|
|
5035
5035
|
return;
|
|
5036
5036
|
}
|
|
5037
5037
|
l.getFloatTimeDomainData(R);
|
|
5038
|
-
let a = 0,
|
|
5038
|
+
let a = 0, s = 0;
|
|
5039
5039
|
for (let S = 0; S < Q; S++) {
|
|
5040
5040
|
const Y = Math.abs(R[S]);
|
|
5041
|
-
a += R[S] * R[S], Y >
|
|
5041
|
+
a += R[S] * R[S], Y > s && (s = Y);
|
|
5042
5042
|
}
|
|
5043
|
-
const
|
|
5043
|
+
const J = Math.sqrt(a / Q), i = d.currentTime;
|
|
5044
5044
|
W.push({
|
|
5045
5045
|
time: i,
|
|
5046
5046
|
relativeTime: (i - U) * 1e3,
|
|
5047
5047
|
// ms relative to scheduled time
|
|
5048
|
-
rms:
|
|
5049
|
-
peak:
|
|
5048
|
+
rms: J,
|
|
5049
|
+
peak: s
|
|
5050
5050
|
});
|
|
5051
5051
|
}, F);
|
|
5052
5052
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "audio-mixer-engine",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"description": "Audio engine library for audio mixer applications with MIDI parsing, playback, and synthesis",
|
|
5
5
|
"main": "dist/audio-mixer-engine.cjs.js",
|
|
6
6
|
"module": "dist/audio-mixer-engine.es.js",
|
|
@@ -446,26 +446,29 @@ export default class PlaybackManager {
|
|
|
446
446
|
stop() {
|
|
447
447
|
if (this.state === 'stopped') return;
|
|
448
448
|
|
|
449
|
-
const
|
|
450
|
-
this.state = 'stopped';
|
|
451
|
-
this.frozenTime = 0;
|
|
452
|
-
this.leadInData = null;
|
|
453
|
-
this.leadInProgress = null;
|
|
454
|
-
this.leadInStartTime = null;
|
|
449
|
+
const previousState = this.state;
|
|
455
450
|
|
|
456
|
-
//
|
|
451
|
+
// Apply the same per-state cleanup as pause()
|
|
452
|
+
if (previousState === 'lead-in') {
|
|
453
|
+
this._pauseLeadIn();
|
|
454
|
+
} else if (previousState === 'playing') {
|
|
455
|
+
this.midiPlayer.pause();
|
|
456
|
+
this._stopMetronome();
|
|
457
|
+
}
|
|
457
458
|
this._stopLeadIn();
|
|
458
|
-
this._stopMetronome();
|
|
459
459
|
this._stopTimeUpdateLoop();
|
|
460
460
|
|
|
461
|
-
// Reset
|
|
462
|
-
this.
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
461
|
+
// Reset to beginning
|
|
462
|
+
this.frozenTime = 0;
|
|
463
|
+
this.leadInData = null;
|
|
464
|
+
this.leadInProgress = null;
|
|
465
|
+
this.leadInStartTime = null;
|
|
466
|
+
if (this.midiPlayer) {
|
|
467
|
+
this.midiPlayer.skipToTime(0);
|
|
467
468
|
}
|
|
469
|
+
this._resetMetronomeBeatTracking();
|
|
468
470
|
|
|
471
|
+
this.state = 'stopped';
|
|
469
472
|
this._emitEvent('playbackStopped', {});
|
|
470
473
|
}
|
|
471
474
|
|