audio-mixer-engine 1.3.4 → 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 Jl(V) {
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 = Jl();
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 B = W + a * b, e = this._ticksToTime(B, l);
1582
- c.push(e);
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,24 +1992,24 @@ class Ol {
1992
1992
  // Total beats
1993
1993
  t.sig[1]
1994
1994
  // Keep original note value
1995
- ], B = [
1995
+ ], s = [
1996
1996
  ...t.beats || [],
1997
1997
  ...b.beats || []
1998
1998
  ];
1999
1999
  t = {
2000
2000
  sig: a,
2001
- beats: B
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, B = t.beats ? t.beats.slice(0, b) : [], e = t.beats ? t.beats.slice(b) : [], G = {
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: B
2008
- }, X = {
2007
+ beats: s
2008
+ }, S = {
2009
2009
  sig: [a, t.sig[1]],
2010
- beats: e
2010
+ beats: J
2011
2011
  };
2012
- R[d] = G, R.splice(d + 1, 0, X), t = G;
2012
+ R[d] = i, R.splice(d + 1, 0, S), t = i;
2013
2013
  }
2014
2014
  this._generateBeatsForBar(F, W, t, m), d++, Q++;
2015
2015
  }
@@ -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 e = 0; e < b; e++)
2028
+ for (let J = 0; J < b; J++)
2029
2029
  a.push(m), m += n;
2030
- const B = {
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, B, b), Q++;
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 = Jl(), this.beatMapper = new Ol(), this.beats = [], this.structureMetadata = Z, this._calculateTotalDuration();
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
  }
@@ -2524,28 +2524,28 @@ function Al(V) {
2524
2524
  throw new Error(`Unsupported MusicXML format: <${Z.tagName}>. Only <score-partwise> is supported.`);
2525
2525
  return U;
2526
2526
  }
2527
- function i(V, l) {
2527
+ function G(V, l) {
2528
2528
  for (const U of V.children)
2529
2529
  if (U.tagName === l) return U;
2530
2530
  return null;
2531
2531
  }
2532
- function E(V, l) {
2532
+ function p(V, l) {
2533
2533
  const U = [];
2534
2534
  for (const F of V.children)
2535
2535
  F.tagName === l && U.push(F);
2536
2536
  return U;
2537
2537
  }
2538
- function g(V, l) {
2539
- const U = i(V, l);
2538
+ function v(V, l) {
2539
+ const U = G(V, l);
2540
2540
  return U ? U.textContent.trim() : null;
2541
2541
  }
2542
- function p(V, l, U = null) {
2543
- const F = g(V, l);
2542
+ function y(V, l, U = null) {
2543
+ const F = v(V, l);
2544
2544
  if (F === null) return U;
2545
2545
  const Z = Number(F);
2546
2546
  return isNaN(Z) ? U : Z;
2547
2547
  }
2548
- function w(V, l) {
2548
+ function O(V, l) {
2549
2549
  return V.getAttribute(l);
2550
2550
  }
2551
2551
  function fl(V) {
@@ -2560,39 +2560,39 @@ function fl(V) {
2560
2560
  };
2561
2561
  }
2562
2562
  function _l(V) {
2563
- const l = g(V, "movement-title");
2563
+ const l = v(V, "movement-title");
2564
2564
  if (l) return l;
2565
- const U = i(V, "work");
2565
+ const U = G(V, "work");
2566
2566
  if (U) {
2567
- const F = g(U, "work-title");
2567
+ const F = v(U, "work-title");
2568
2568
  if (F) return F;
2569
2569
  }
2570
2570
  return null;
2571
2571
  }
2572
2572
  function $l(V) {
2573
2573
  let l = null, U = null;
2574
- const F = i(V, "identification");
2574
+ const F = G(V, "identification");
2575
2575
  if (!F) return { composer: l, arranger: U };
2576
- const Z = E(F, "creator");
2576
+ const Z = p(F, "creator");
2577
2577
  for (const d of Z) {
2578
- const Q = w(d, "type"), R = d.textContent.trim();
2578
+ const Q = O(d, "type"), R = d.textContent.trim();
2579
2579
  R && (Q === "composer" ? l = R : Q === "arranger" && (U = R));
2580
2580
  }
2581
2581
  return { composer: l, arranger: U };
2582
2582
  }
2583
2583
  function lU(V) {
2584
- const l = i(V, "identification");
2585
- return l ? g(l, "rights") : null;
2584
+ const l = G(V, "identification");
2585
+ return l ? v(l, "rights") : null;
2586
2586
  }
2587
2587
  function UU(V) {
2588
- const l = i(V, "part-list");
2589
- return l ? E(l, "score-part").map((F) => {
2590
- const Z = w(F, "id"), d = g(F, "part-name") || Z;
2588
+ const l = G(V, "part-list");
2589
+ return l ? p(l, "score-part").map((F) => {
2590
+ const Z = O(F, "id"), d = v(F, "part-name") || Z;
2591
2591
  let Q = null, R = null;
2592
- const W = i(F, "midi-instrument");
2592
+ const W = G(F, "midi-instrument");
2593
2593
  if (W) {
2594
- const n = p(W, "midi-program");
2595
- n !== null && (Q = n - 1), R = p(W, "midi-channel");
2594
+ const n = y(W, "midi-program");
2595
+ n !== null && (Q = n - 1), R = y(W, "midi-channel");
2596
2596
  }
2597
2597
  return { id: Z, name: d, midiProgram: Q, midiChannel: R };
2598
2598
  }) : [];
@@ -2614,11 +2614,11 @@ class FU {
2614
2614
  */
2615
2615
  processAttributes(l) {
2616
2616
  if (!l) return;
2617
- const U = p(l, "divisions");
2617
+ const U = y(l, "divisions");
2618
2618
  U !== null && U > 0 && (this.currentDivisions = U);
2619
- const F = i(l, "time");
2619
+ const F = G(l, "time");
2620
2620
  if (F) {
2621
- const Z = p(F, "beats"), d = p(F, "beat-type");
2621
+ const Z = y(F, "beats"), d = y(F, "beat-type");
2622
2622
  Z !== null && d !== null && (this.currentTimeSig = { numerator: Z, denominator: d }, this.timeSigChanges.push({
2623
2623
  tick: this.currentTick,
2624
2624
  numerator: Z,
@@ -2764,9 +2764,9 @@ class FU {
2764
2764
  * @param {Element} measureEl - <measure> element
2765
2765
  */
2766
2766
  processDirections(l) {
2767
- const U = E(l, "direction");
2767
+ const U = p(l, "direction");
2768
2768
  for (const F of U) {
2769
- const Z = i(F, "sound");
2769
+ const Z = G(F, "sound");
2770
2770
  if (Z) {
2771
2771
  const d = parseFloat(Z.getAttribute("tempo"));
2772
2772
  !isNaN(d) && d > 0 && this.processTempo(d);
@@ -2812,7 +2812,7 @@ const ZU = { C: 0, D: 2, E: 4, F: 5, G: 7, A: 9, B: 11 }, dU = ["C", "C#", "D",
2812
2812
  fz: 112
2813
2813
  };
2814
2814
  function VU(V) {
2815
- const l = g(V, "step"), U = p(V, "octave", 4), F = p(V, "alter", 0), Z = ZU[l];
2815
+ const l = v(V, "step"), U = y(V, "octave", 4), F = y(V, "alter", 0), Z = ZU[l];
2816
2816
  if (Z === void 0)
2817
2817
  throw new Error(`Unknown pitch step: ${l}`);
2818
2818
  return (U + 1) * 12 + Z + F;
@@ -2861,53 +2861,56 @@ class nU {
2861
2861
  continue;
2862
2862
  }
2863
2863
  if (n.tagName === "forward") {
2864
- const o = p(n, "duration", 0);
2865
- R += this.timing.xmlDurationToTicks(o);
2864
+ const X = y(n, "duration", 0);
2865
+ R += this.timing.xmlDurationToTicks(X);
2866
2866
  continue;
2867
2867
  }
2868
2868
  if (n.tagName === "backup") {
2869
- const o = p(n, "duration", 0);
2870
- R -= this.timing.xmlDurationToTicks(o);
2869
+ const X = y(n, "duration", 0);
2870
+ R -= this.timing.xmlDurationToTicks(X);
2871
2871
  continue;
2872
2872
  }
2873
2873
  if (n.tagName !== "note") continue;
2874
- const m = i(n, "chord") !== null, t = i(n, "rest") !== null, c = i(n, "grace") !== null, b = p(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 B = R;
2878
- if (m || (W = R), R = B + a, t) continue;
2879
- const e = i(n, "pitch");
2880
- if (!e) continue;
2881
- const G = VU(e), X = E(n, "tie");
2882
- let N = !1, z = !1;
2883
- for (const o of X) {
2884
- const C = w(o, "type");
2885
- C === "start" && (N = !0), C === "stop" && (z = !0);
2877
+ const J = R;
2878
+ if (m || (W = R), R = J + a, t) continue;
2879
+ const i = G(n, "pitch");
2880
+ if (!i) continue;
2881
+ const S = VU(i), Y = p(n, "tie");
2882
+ let L = !1, D = !1;
2883
+ for (const X of Y) {
2884
+ const C = O(X, "type");
2885
+ C === "start" && (L = !0), C === "stop" && (D = !0);
2886
2886
  }
2887
- if (z && this.pendingTies.has(G)) {
2888
- const o = this.pendingTies.get(G);
2889
- N ? o.endTick = B + a : (o.endTick = B + a, d.push(this._buildNote(o, F, Z)), this.pendingTies.delete(G));
2890
- } else N ? this.pendingTies.set(G, {
2891
- pitch: G,
2892
- startTick: B,
2893
- endTick: B + a,
2894
- velocity: this.currentVelocity
2887
+ if (D && this.pendingTies.has(S)) {
2888
+ const X = this.pendingTies.get(S);
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
+ } else L ? this.pendingTies.set(S, {
2891
+ pitch: S,
2892
+ startTick: J,
2893
+ endTick: J + a,
2894
+ velocity: this.currentVelocity,
2895
+ isTuplet: s
2895
2896
  }) : d.push(this._buildNote({
2896
- pitch: G,
2897
- startTick: B,
2898
- endTick: B + a,
2899
- velocity: this.currentVelocity
2897
+ pitch: S,
2898
+ startTick: J,
2899
+ endTick: J + a,
2900
+ velocity: this.currentVelocity,
2901
+ isTuplet: s
2900
2902
  }, F, Z));
2901
- const P = E(n, "lyric");
2902
- for (const o of P) {
2903
- const C = g(o, "text");
2903
+ const A = p(n, "lyric");
2904
+ for (const X of A) {
2905
+ const C = v(X, "text");
2904
2906
  if (C) {
2905
- const O = g(o, "syllabic");
2907
+ const K = v(X, "syllabic");
2906
2908
  Q.push({
2907
2909
  text: C,
2908
- syllabic: O || "single",
2909
- tick: B,
2910
- time: this.timing.tickToTime(B)
2910
+ syllabic: K || "single",
2911
+ tick: J,
2912
+ time: this.timing.tickToTime(J),
2913
+ isTuplet: s
2911
2914
  });
2912
2915
  }
2913
2916
  }
@@ -2948,7 +2951,8 @@ class nU {
2948
2951
  endTime: this.timing.tickToTime(l.endTick),
2949
2952
  velocity: l.velocity,
2950
2953
  channel: U,
2951
- sourceTrackIndex: F
2954
+ sourceTrackIndex: F,
2955
+ isTuplet: l.isTuplet || !1
2952
2956
  };
2953
2957
  }
2954
2958
  /**
@@ -2956,7 +2960,7 @@ class nU {
2956
2960
  * @private
2957
2961
  */
2958
2962
  _processDirectionDynamics(l) {
2959
- const U = E(l, "direction");
2963
+ const U = p(l, "direction");
2960
2964
  for (const F of U)
2961
2965
  this._processDirectionElement(F);
2962
2966
  }
@@ -2965,9 +2969,9 @@ class nU {
2965
2969
  * @private
2966
2970
  */
2967
2971
  _processDirectionElement(l) {
2968
- const U = E(l, "direction-type");
2972
+ const U = p(l, "direction-type");
2969
2973
  for (const F of U) {
2970
- const Z = i(F, "dynamics");
2974
+ const Z = G(F, "dynamics");
2971
2975
  if (Z) {
2972
2976
  const d = tU(Z);
2973
2977
  d !== null && (this.currentVelocity = d);
@@ -3001,12 +3005,12 @@ function WU(V) {
3001
3005
  tempo: null,
3002
3006
  divisions: null,
3003
3007
  beatsInMeasure: null
3004
- }, R = E(d, "barline");
3008
+ }, R = p(d, "barline");
3005
3009
  for (const m of R) {
3006
- w(m, "location");
3007
- const t = i(m, "repeat");
3010
+ O(m, "location");
3011
+ const t = G(m, "repeat");
3008
3012
  if (t) {
3009
- const b = w(t, "direction");
3013
+ const b = O(t, "direction");
3010
3014
  if (b === "forward")
3011
3015
  Q.repeatForward = !0;
3012
3016
  else if (b === "backward") {
@@ -3015,40 +3019,40 @@ function WU(V) {
3015
3019
  a && (Q.repeatCount = parseInt(a, 10));
3016
3020
  }
3017
3021
  }
3018
- const c = i(m, "ending");
3022
+ const c = G(m, "ending");
3019
3023
  if (c) {
3020
- const b = w(c, "type"), a = w(c, "number");
3021
- b === "start" && a && (Q.endings = a.split(/[,\s]+/).map((B) => parseInt(B.trim(), 10)).filter((B) => !isNaN(B))), (b === "stop" || b === "discontinue") && (Q.endingStop = !0);
3024
+ const b = O(c, "type"), a = O(c, "number");
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);
3022
3026
  }
3023
3027
  }
3024
- const W = E(d, "direction");
3028
+ const W = p(d, "direction");
3025
3029
  for (const m of W) {
3026
- const t = i(m, "sound");
3030
+ const t = G(m, "sound");
3027
3031
  if (t) {
3028
3032
  const b = t.getAttribute("segno");
3029
3033
  b && (Q.segno = b);
3030
3034
  const a = t.getAttribute("coda");
3031
3035
  a && (Q.coda = a), t.getAttribute("fine") === "yes" && (Q.fine = !0), t.getAttribute("dacapo") === "yes" && (Q.dacapo = !0);
3032
- const B = t.getAttribute("dalsegno");
3033
- B && (Q.dalsegno = B);
3034
- const e = t.getAttribute("tocoda");
3035
- e && (Q.tocoda = e);
3036
- const G = t.getAttribute("tempo");
3037
- G && (Q.tempo = parseFloat(G));
3036
+ const s = t.getAttribute("dalsegno");
3037
+ s && (Q.dalsegno = s);
3038
+ const J = t.getAttribute("tocoda");
3039
+ J && (Q.tocoda = J);
3040
+ const i = t.getAttribute("tempo");
3041
+ i && (Q.tempo = parseFloat(i));
3038
3042
  }
3039
- const c = E(m, "direction-type");
3043
+ const c = p(m, "direction-type");
3040
3044
  for (const b of c) {
3041
- const a = i(b, "rehearsal");
3045
+ const a = G(b, "rehearsal");
3042
3046
  a && (Q.rehearsal = a.textContent.trim());
3043
3047
  }
3044
3048
  }
3045
- const n = i(d, "attributes");
3049
+ const n = G(d, "attributes");
3046
3050
  if (n) {
3047
- const m = p(n, "divisions");
3051
+ const m = y(n, "divisions");
3048
3052
  m !== null && (Q.divisions = m);
3049
- const t = i(n, "time");
3053
+ const t = G(n, "time");
3050
3054
  if (t) {
3051
- const c = p(t, "beats"), b = p(t, "beat-type");
3055
+ const c = y(t, "beats"), b = y(t, "beat-type");
3052
3056
  c !== null && b !== null && (Q.timeSig = [c, b], Q.beatsInMeasure = c);
3053
3057
  }
3054
3058
  }
@@ -3155,7 +3159,7 @@ function bU(V) {
3155
3159
  F++;
3156
3160
  continue;
3157
3161
  }
3158
- W = JU(V, b), R = !W, F = b;
3162
+ W = sU(V, b), R = !W, F = b;
3159
3163
  continue;
3160
3164
  }
3161
3165
  F++;
@@ -3178,12 +3182,12 @@ function BU(V, l) {
3178
3182
  if (V[U].coda === l) return U;
3179
3183
  return -1;
3180
3184
  }
3181
- function JU(V, l) {
3185
+ function sU(V, l) {
3182
3186
  for (let U = l; U < V.length; U++)
3183
3187
  if (V[U].tocoda) return V[U].tocoda;
3184
3188
  return null;
3185
3189
  }
3186
- function sU(V) {
3190
+ function JU(V) {
3187
3191
  if (V.length === 0) return [];
3188
3192
  const l = [];
3189
3193
  let U = null;
@@ -3226,17 +3230,17 @@ class GU {
3226
3230
  * @returns {Object} parsedData with parts, barStructure, metadata, structureMetadata
3227
3231
  */
3228
3232
  convert(l, U = {}, F = null) {
3229
- var O, D;
3230
- const Z = typeof l == "string" ? Al(l) : l, d = Z.documentElement, Q = fl(Z), R = E(d, "part");
3233
+ var K, _;
3234
+ const Z = typeof l == "string" ? Al(l) : l, d = Z.documentElement, Q = fl(Z), R = p(d, "part");
3231
3235
  if (R.length === 0)
3232
3236
  throw new Error("MusicXML document contains no <part> elements");
3233
- const W = E(R[0], "measure"), n = WU(W), m = bU(n), t = m.length > 0 ? m : n.map((J, h) => ({
3234
- measureIndex: h,
3235
- scoreBarNumber: J.number,
3237
+ const W = p(R[0], "measure"), n = WU(W), m = bU(n), t = m.length > 0 ? m : n.map((h, B) => ({
3238
+ measureIndex: B,
3239
+ scoreBarNumber: h.number,
3236
3240
  repeat: 1,
3237
- beatsInMeasure: J.beatsInMeasure,
3238
- timeSig: J.timeSig,
3239
- tempo: J.tempo
3241
+ beatsInMeasure: h.beatsInMeasure,
3242
+ timeSig: h.timeSig,
3243
+ tempo: h.tempo
3240
3244
  })), c = new FU({
3241
3245
  defaultTempo: U.defaultTempo || 120,
3242
3246
  ticksPerBeat: bl
@@ -3254,131 +3258,137 @@ class GU {
3254
3258
  denominator: b.currentTimeSig.denominator
3255
3259
  }]
3256
3260
  });
3257
- const a = {}, B = /* @__PURE__ */ new Map();
3258
- for (let J = 0; J < R.length; J++) {
3259
- const h = R[J], s = w(h, "id"), u = Q.partInfos.find((I) => I.id === s) || {
3260
- id: s,
3261
- name: s,
3261
+ const a = {}, s = /* @__PURE__ */ new Map();
3262
+ for (let h = 0; h < R.length; h++) {
3263
+ const B = R[h], e = O(B, "id"), N = Q.partInfos.find((x) => x.id === e) || {
3264
+ id: e,
3265
+ name: e,
3262
3266
  midiProgram: null,
3263
3267
  midiChannel: null
3264
3268
  };
3265
- B.set(s, {
3266
- partElement: h,
3267
- measures: E(h, "measure"),
3268
- channel: J,
3269
+ s.set(e, {
3270
+ partElement: B,
3271
+ measures: p(B, "measure"),
3272
+ channel: h,
3269
3273
  // Synthetic channel number
3270
- trackIndex: J,
3271
- partInfo: u
3272
- }), a[u.name] = {
3274
+ trackIndex: h,
3275
+ partInfo: N
3276
+ }), a[N.name] = {
3273
3277
  notes: [],
3274
3278
  lyrics: [],
3275
- trackIndex: J,
3279
+ trackIndex: h,
3276
3280
  programChanges: [],
3277
- defaultInstrument: u.midiProgram !== null ? u.midiProgram : 52
3281
+ defaultInstrument: N.midiProgram !== null ? N.midiProgram : 52
3278
3282
  // Default to choir_aahs
3279
3283
  };
3280
3284
  }
3281
- const e = [], G = sU(t), X = eU(n), N = /* @__PURE__ */ new Map();
3282
- for (let J = 0; J < W.length; J++) {
3283
- const h = W[J], s = i(h, "attributes"), u = {};
3284
- if (s) {
3285
- const H = s.querySelector("divisions");
3286
- H && (u.divisions = parseInt(H.textContent, 10));
3287
- const y = i(s, "time");
3288
- if (y) {
3289
- const k = parseInt((O = i(y, "beats")) == null ? void 0 : O.textContent, 10), T = parseInt((D = i(y, "beat-type")) == null ? void 0 : D.textContent, 10);
3290
- !isNaN(k) && !isNaN(T) && (u.timeSig = { numerator: k, denominator: T });
3285
+ const J = [], i = JU(t), S = eU(n), Y = /* @__PURE__ */ new Map();
3286
+ for (let h = 0; h < W.length; h++) {
3287
+ const B = W[h], e = G(B, "attributes"), N = {};
3288
+ if (e) {
3289
+ const E = e.querySelector("divisions");
3290
+ E && (N.divisions = parseInt(E.textContent, 10));
3291
+ const k = G(e, "time");
3292
+ if (k) {
3293
+ const M = parseInt((K = G(k, "beats")) == null ? void 0 : K.textContent, 10), o = parseInt((_ = G(k, "beat-type")) == null ? void 0 : _.textContent, 10);
3294
+ !isNaN(M) && !isNaN(o) && (N.timeSig = { numerator: M, denominator: o });
3291
3295
  }
3292
3296
  }
3293
- const I = E(h, "direction");
3294
- for (const H of I) {
3295
- const y = i(H, "sound");
3296
- if (y) {
3297
- const k = parseFloat(y.getAttribute("tempo"));
3298
- !isNaN(k) && k > 0 && (u.tempo = k);
3299
- const T = i(y, "swing");
3300
- if (T)
3301
- if (i(T, "straight"))
3302
- u.swing = { straight: !0 };
3297
+ const x = p(B, "direction");
3298
+ for (const E of x) {
3299
+ const k = G(E, "sound");
3300
+ if (k) {
3301
+ const M = parseFloat(k.getAttribute("tempo"));
3302
+ !isNaN(M) && M > 0 && (N.tempo = M);
3303
+ const o = G(k, "swing");
3304
+ if (o)
3305
+ if (G(o, "straight"))
3306
+ N.swing = { straight: !0 };
3303
3307
  else {
3304
- const Y = p(T, "first"), v = p(T, "second"), f = g(T, "swing-type") || "eighth";
3305
- Y !== null && v !== null && Y > 0 && v > 0 && (u.swing = { first: Y, second: v, swingType: f });
3308
+ const H = y(o, "first"), j = y(o, "second"), f = v(o, "swing-type") || "eighth";
3309
+ H !== null && j !== null && H > 0 && j > 0 && (N.swing = { first: H, second: j, swingType: f });
3306
3310
  }
3307
3311
  }
3308
3312
  }
3309
- N.set(J, u);
3313
+ Y.set(h, N);
3310
3314
  }
3311
- const z = /* @__PURE__ */ new Map();
3312
- for (const [J, h] of B)
3313
- z.set(J, new nU(c, {
3315
+ const L = /* @__PURE__ */ new Map();
3316
+ for (const [h, B] of s)
3317
+ L.set(h, new nU(c, {
3314
3318
  defaultVelocity: U.defaultVelocity || 80
3315
3319
  }));
3316
- for (const J of t) {
3317
- const h = J.measureIndex, s = N.get(h) || {};
3318
- s.divisions && (c.currentDivisions = s.divisions), s.timeSig && (c.currentTimeSig = { ...s.timeSig }), s.tempo && c.processTempo(s.tempo), s.swing && c.processSwing(s.swing);
3319
- const u = c.currentTick, I = J.beatsInMeasure, H = c.generateBarStructureEntry(u, I);
3320
- e.push(H);
3321
- for (const [T, Y] of B) {
3322
- const v = Y.measures[h];
3323
- if (!v) continue;
3324
- const f = z.get(T), { notes: _, lyrics: j } = f.extractMeasure(
3325
- v,
3326
- u,
3327
- Y.channel,
3328
- Y.trackIndex
3329
- ), $ = Y.partInfo.name;
3330
- a[$].notes.push(..._), a[$].lyrics.push(...j);
3320
+ for (const h of t) {
3321
+ const B = h.measureIndex, e = Y.get(B) || {};
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
+ const N = c.currentTick, x = h.beatsInMeasure, E = c.generateBarStructureEntry(N, x);
3324
+ J.push(E);
3325
+ for (const [o, H] of s) {
3326
+ const j = H.measures[B];
3327
+ if (!j) continue;
3328
+ const f = L.get(o), { notes: q, lyrics: Fl } = f.extractMeasure(
3329
+ j,
3330
+ N,
3331
+ H.channel,
3332
+ H.trackIndex
3333
+ ), w = H.partInfo.name;
3334
+ a[w].notes.push(...q), a[w].lyrics.push(...Fl);
3331
3335
  }
3332
- const k = c.getTicksPerBeatInTimeSig() * I;
3333
- c.advance(k);
3336
+ const M = c.getTicksPerBeatInTimeSig() * x;
3337
+ c.advance(M);
3334
3338
  }
3335
- for (const [J, h] of B) {
3336
- const u = z.get(J).flushPendingTies(h.channel, h.trackIndex), I = h.partInfo.name;
3337
- a[I].notes.push(...u);
3339
+ for (const [h, B] of s) {
3340
+ const N = L.get(h).flushPendingTies(B.channel, B.trackIndex), x = B.partInfo.name;
3341
+ a[x].notes.push(...N);
3338
3342
  }
3339
- for (const J of Object.values(a))
3340
- J.notes.sort((h, s) => h.startTick - s.startTick || h.pitch - s.pitch);
3341
- if (c.swingMap.length > 0)
3342
- for (const J of Object.values(a)) {
3343
- for (const h of J.notes) {
3344
- const s = c.applySwingToTick(h.startTick), u = c.applySwingToTick(h.endTick);
3345
- h.startTick = s, h.endTick = u, h.duration = u - s, h.startTime = c.tickToTime(s), h.endTime = c.tickToTime(u);
3343
+ for (const h of Object.values(a))
3344
+ h.notes.sort((B, e) => B.startTick - e.startTick || B.pitch - e.pitch);
3345
+ const D = c.swingMap.length > 0;
3346
+ for (const h of Object.values(a)) {
3347
+ for (const B of h.notes) {
3348
+ if (D && !B.isTuplet) {
3349
+ const e = c.applySwingToTick(B.startTick), N = c.applySwingToTick(B.endTick);
3350
+ B.startTick = e, B.endTick = N, B.duration = N - e, B.startTime = c.tickToTime(e), B.endTime = c.tickToTime(N);
3346
3351
  }
3347
- for (const h of J.lyrics) {
3348
- const s = c.applySwingToTick(h.tick);
3349
- h.tick = s, h.time = c.tickToTime(s);
3352
+ delete B.isTuplet;
3353
+ }
3354
+ for (const B of h.lyrics) {
3355
+ if (D && !B.isTuplet) {
3356
+ const e = c.applySwingToTick(B.tick);
3357
+ B.tick = e, B.time = c.tickToTime(e);
3350
3358
  }
3359
+ delete B.isTuplet;
3351
3360
  }
3352
- const P = Q.partInfos.map((J, h) => ({
3353
- index: h,
3354
- name: J.name
3355
- })), o = {};
3356
- for (const [J, h] of B) {
3357
- const s = h.partInfo.name;
3358
- o[s] = {
3359
- trackIndex: h.trackIndex,
3360
- instrument: a[s].defaultInstrument,
3361
- order: h.trackIndex + 1
3361
+ }
3362
+ const A = Q.partInfos.map((h, B) => ({
3363
+ index: B,
3364
+ name: h.name
3365
+ })), X = {};
3366
+ for (const [h, B] of s) {
3367
+ const e = B.partInfo.name;
3368
+ X[e] = {
3369
+ trackIndex: B.trackIndex,
3370
+ instrument: a[e].defaultInstrument,
3371
+ order: B.trackIndex + 1
3362
3372
  };
3363
3373
  }
3364
3374
  const C = {
3365
3375
  parts: a,
3366
- barStructure: e,
3376
+ barStructure: J,
3367
3377
  metadata: {
3368
3378
  title: Q.title,
3369
3379
  composer: Q.composer,
3370
3380
  arranger: Q.arranger,
3371
3381
  copyright: Q.copyright,
3372
- partNames: P,
3382
+ partNames: A,
3373
3383
  format: 0,
3374
3384
  ticksPerBeat: bl
3375
3385
  },
3376
3386
  structureMetadata: {
3377
- bars: G,
3378
- marks: X,
3387
+ bars: i,
3388
+ marks: S,
3379
3389
  title: Q.title,
3380
3390
  composer: Q.composer,
3381
- parts: o
3391
+ parts: X
3382
3392
  }
3383
3393
  };
3384
3394
  return F && this._applyMetadataOverrides(C, F), C;
@@ -3419,11 +3429,11 @@ class GU {
3419
3429
  */
3420
3430
  _scanInitialAttributes(l, U) {
3421
3431
  if (l.length === 0) return;
3422
- const F = l[0], Z = i(F, "attributes");
3432
+ const F = l[0], Z = G(F, "attributes");
3423
3433
  Z && U.processAttributes(Z), U.processDirections(F);
3424
3434
  }
3425
3435
  }
3426
- var r = Uint8Array, A = Uint16Array, iU = Int32Array, pl = new r([
3436
+ var T = Uint8Array, $ = Uint16Array, iU = Int32Array, pl = new T([
3427
3437
  0,
3428
3438
  0,
3429
3439
  0,
@@ -3458,7 +3468,7 @@ var r = Uint8Array, A = Uint16Array, iU = Int32Array, pl = new r([
3458
3468
  0,
3459
3469
  /* impossible */
3460
3470
  0
3461
- ]), El = new r([
3471
+ ]), El = new T([
3462
3472
  0,
3463
3473
  0,
3464
3474
  0,
@@ -3492,8 +3502,8 @@ var r = Uint8Array, A = Uint16Array, iU = Int32Array, pl = new r([
3492
3502
  /* unused */
3493
3503
  0,
3494
3504
  0
3495
- ]), SU = new r([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), kl = function(V, l) {
3496
- for (var U = new A(31), F = 0; F < 31; ++F)
3505
+ ]), SU = new T([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), kl = function(V, l) {
3506
+ for (var U = new $(31), F = 0; F < 31; ++F)
3497
3507
  U[F] = l += 1 << V[F - 1];
3498
3508
  for (var Z = new iU(U[30]), F = 1; F < 30; ++F)
3499
3509
  for (var d = U[F]; d < U[F + 1]; ++d)
@@ -3501,46 +3511,46 @@ var r = Uint8Array, A = Uint16Array, iU = Int32Array, pl = new r([
3501
3511
  return { b: U, r: Z };
3502
3512
  }, Tl = kl(pl, 2), rl = Tl.b, uU = Tl.r;
3503
3513
  rl[28] = 258, uU[258] = 28;
3504
- var XU = kl(El, 0), NU = XU.b, al = new A(32768);
3505
- for (var S = 0; S < 32768; ++S) {
3506
- var q = (S & 43690) >> 1 | (S & 21845) << 1;
3507
- q = (q & 52428) >> 2 | (q & 13107) << 2, q = (q & 61680) >> 4 | (q & 3855) << 4, al[S] = ((q & 65280) >> 8 | (q & 255) << 8) >> 1;
3514
+ var XU = kl(El, 0), NU = XU.b, al = new $(32768);
3515
+ for (var u = 0; u < 32768; ++u) {
3516
+ var P = (u & 43690) >> 1 | (u & 21845) << 1;
3517
+ P = (P & 52428) >> 2 | (P & 13107) << 2, P = (P & 61680) >> 4 | (P & 3855) << 4, al[u] = ((P & 65280) >> 8 | (P & 255) << 8) >> 1;
3508
3518
  }
3509
- var Ul = (function(V, l, U) {
3510
- for (var F = V.length, Z = 0, d = new A(l); Z < F; ++Z)
3519
+ var ll = (function(V, l, U) {
3520
+ for (var F = V.length, Z = 0, d = new $(l); Z < F; ++Z)
3511
3521
  V[Z] && ++d[V[Z] - 1];
3512
- var Q = new A(l);
3522
+ var Q = new $(l);
3513
3523
  for (Z = 1; Z < l; ++Z)
3514
3524
  Q[Z] = Q[Z - 1] + d[Z - 1] << 1;
3515
3525
  var R;
3516
3526
  if (U) {
3517
- R = new A(1 << l);
3527
+ R = new $(1 << l);
3518
3528
  var W = 15 - l;
3519
3529
  for (Z = 0; Z < F; ++Z)
3520
3530
  if (V[Z])
3521
3531
  for (var n = Z << 4 | V[Z], m = l - V[Z], t = Q[V[Z] - 1]++ << m, c = t | (1 << m) - 1; t <= c; ++t)
3522
3532
  R[al[t] >> W] = n;
3523
3533
  } else
3524
- for (R = new A(F), Z = 0; Z < F; ++Z)
3534
+ for (R = new $(F), Z = 0; Z < F; ++Z)
3525
3535
  V[Z] && (R[Z] = al[Q[V[Z] - 1]++] >> 15 - V[Z]);
3526
3536
  return R;
3527
- }), Fl = new r(288);
3528
- for (var S = 0; S < 144; ++S)
3529
- Fl[S] = 8;
3530
- for (var S = 144; S < 256; ++S)
3531
- Fl[S] = 9;
3532
- for (var S = 256; S < 280; ++S)
3533
- Fl[S] = 7;
3534
- for (var S = 280; S < 288; ++S)
3535
- Fl[S] = 8;
3536
- var Ll = new r(32);
3537
- for (var S = 0; S < 32; ++S)
3538
- Ll[S] = 5;
3539
- var oU = /* @__PURE__ */ Ul(Fl, 9, 1), YU = /* @__PURE__ */ Ul(Ll, 5, 1), nl = function(V) {
3537
+ }), Ul = new T(288);
3538
+ for (var u = 0; u < 144; ++u)
3539
+ Ul[u] = 8;
3540
+ for (var u = 144; u < 256; ++u)
3541
+ Ul[u] = 9;
3542
+ for (var u = 256; u < 280; ++u)
3543
+ Ul[u] = 7;
3544
+ for (var u = 280; u < 288; ++u)
3545
+ Ul[u] = 8;
3546
+ var Ll = new T(32);
3547
+ for (var u = 0; u < 32; ++u)
3548
+ Ll[u] = 5;
3549
+ var oU = /* @__PURE__ */ ll(Ul, 9, 1), YU = /* @__PURE__ */ ll(Ll, 5, 1), nl = function(V) {
3540
3550
  for (var l = V[0], U = 1; U < V.length; ++U)
3541
3551
  V[U] > l && (l = V[U]);
3542
3552
  return l;
3543
- }, x = function(V, l, U) {
3553
+ }, z = function(V, l, U) {
3544
3554
  var F = l / 8 | 0;
3545
3555
  return (V[F] | V[F + 1] << 8) >> (l & 7) & U;
3546
3556
  }, Wl = function(V, l) {
@@ -3548,8 +3558,8 @@ var oU = /* @__PURE__ */ Ul(Fl, 9, 1), YU = /* @__PURE__ */ Ul(Ll, 5, 1), nl = f
3548
3558
  return (V[U] | V[U + 1] << 8 | V[U + 2] << 16) >> (l & 7);
3549
3559
  }, yU = function(V) {
3550
3560
  return (V + 7) / 8 | 0;
3551
- }, sl = function(V, l, U) {
3552
- return (l == null || l < 0) && (l = 0), (U == null || U > V.length) && (U = V.length), new r(V.subarray(l, U));
3561
+ }, Jl = function(V, l, U) {
3562
+ return (l == null || l < 0) && (l = 0), (U == null || U > V.length) && (U = V.length), new T(V.subarray(l, U));
3553
3563
  }, pU = [
3554
3564
  "unexpected EOF",
3555
3565
  "invalid block type",
@@ -3566,116 +3576,116 @@ var oU = /* @__PURE__ */ Ul(Fl, 9, 1), YU = /* @__PURE__ */ Ul(Ll, 5, 1), nl = f
3566
3576
  "stream finishing",
3567
3577
  "invalid zip data"
3568
3578
  // determined by unknown compression method
3569
- ], L = function(V, l, U) {
3579
+ ], r = function(V, l, U) {
3570
3580
  var F = new Error(l || pU[V]);
3571
- if (F.code = V, Error.captureStackTrace && Error.captureStackTrace(F, L), !U)
3581
+ if (F.code = V, Error.captureStackTrace && Error.captureStackTrace(F, r), !U)
3572
3582
  throw F;
3573
3583
  return F;
3574
3584
  }, EU = function(V, l, U, F) {
3575
3585
  var Z = V.length, d = F ? F.length : 0;
3576
3586
  if (!Z || l.f && !l.l)
3577
- return U || new r(0);
3587
+ return U || new T(0);
3578
3588
  var Q = !U, R = Q || l.i != 2, W = l.i;
3579
- Q && (U = new r(Z * 3));
3589
+ Q && (U = new T(Z * 3));
3580
3590
  var n = function(il) {
3581
3591
  var Sl = U.length;
3582
3592
  if (il > Sl) {
3583
- var ul = new r(Math.max(Sl * 2, il));
3593
+ var ul = new T(Math.max(Sl * 2, il));
3584
3594
  ul.set(U), U = ul;
3585
3595
  }
3586
- }, m = l.f || 0, t = l.p || 0, c = l.b || 0, b = l.l, a = l.d, B = l.m, e = l.n, G = Z * 8;
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;
3587
3597
  do {
3588
3598
  if (!b) {
3589
- m = x(V, t, 1);
3590
- var X = x(V, t + 1, 3);
3591
- if (t += 3, X)
3592
- if (X == 1)
3593
- b = oU, a = YU, B = 9, e = 5;
3594
- else if (X == 2) {
3595
- var o = x(V, t, 31) + 257, C = x(V, t + 10, 15) + 4, O = o + x(V, t + 5, 31) + 1;
3599
+ m = z(V, t, 1);
3600
+ var S = z(V, t + 1, 3);
3601
+ if (t += 3, S)
3602
+ if (S == 1)
3603
+ b = oU, a = YU, s = 9, J = 5;
3604
+ else if (S == 2) {
3605
+ var A = z(V, t, 31) + 257, X = z(V, t + 10, 15) + 4, C = A + z(V, t + 5, 31) + 1;
3596
3606
  t += 14;
3597
- for (var D = new r(O), J = new r(19), h = 0; h < C; ++h)
3598
- J[SU[h]] = x(V, t + h * 3, 7);
3599
- t += C * 3;
3600
- for (var s = nl(J), u = (1 << s) - 1, I = Ul(J, s, 1), h = 0; h < O; ) {
3601
- var H = I[x(V, t, u)];
3602
- t += H & 15;
3603
- var N = H >> 4;
3604
- if (N < 16)
3605
- D[h++] = N;
3607
+ for (var K = new T(C), _ = new T(19), h = 0; h < X; ++h)
3608
+ _[SU[h]] = z(V, t + h * 3, 7);
3609
+ t += X * 3;
3610
+ for (var B = nl(_), e = (1 << B) - 1, N = ll(_, B, 1), h = 0; h < C; ) {
3611
+ var x = N[z(V, t, e)];
3612
+ t += x & 15;
3613
+ var Y = x >> 4;
3614
+ if (Y < 16)
3615
+ K[h++] = Y;
3606
3616
  else {
3607
- var y = 0, k = 0;
3608
- for (N == 16 ? (k = 3 + x(V, t, 3), t += 2, y = D[h - 1]) : N == 17 ? (k = 3 + x(V, t, 7), t += 3) : N == 18 && (k = 11 + x(V, t, 127), t += 7); k--; )
3609
- D[h++] = y;
3617
+ var E = 0, k = 0;
3618
+ for (Y == 16 ? (k = 3 + z(V, t, 3), t += 2, E = K[h - 1]) : Y == 17 ? (k = 3 + z(V, t, 7), t += 3) : Y == 18 && (k = 11 + z(V, t, 127), t += 7); k--; )
3619
+ K[h++] = E;
3610
3620
  }
3611
3621
  }
3612
- var T = D.subarray(0, o), Y = D.subarray(o);
3613
- B = nl(T), e = nl(Y), b = Ul(T, B, 1), a = Ul(Y, e, 1);
3622
+ var M = K.subarray(0, A), o = K.subarray(A);
3623
+ s = nl(M), J = nl(o), b = ll(M, s, 1), a = ll(o, J, 1);
3614
3624
  } else
3615
- L(1);
3625
+ r(1);
3616
3626
  else {
3617
- var N = yU(t) + 4, z = V[N - 4] | V[N - 3] << 8, P = N + z;
3618
- if (P > Z) {
3619
- W && L(0);
3627
+ var Y = yU(t) + 4, L = V[Y - 4] | V[Y - 3] << 8, D = Y + L;
3628
+ if (D > Z) {
3629
+ W && r(0);
3620
3630
  break;
3621
3631
  }
3622
- R && n(c + z), U.set(V.subarray(N, P), c), l.b = c += z, l.p = t = P * 8, l.f = m;
3632
+ R && n(c + L), U.set(V.subarray(Y, D), c), l.b = c += L, l.p = t = D * 8, l.f = m;
3623
3633
  continue;
3624
3634
  }
3625
- if (t > G) {
3626
- W && L(0);
3635
+ if (t > i) {
3636
+ W && r(0);
3627
3637
  break;
3628
3638
  }
3629
3639
  }
3630
3640
  R && n(c + 131072);
3631
- for (var v = (1 << B) - 1, f = (1 << e) - 1, _ = t; ; _ = t) {
3632
- var y = b[Wl(V, t) & v], j = y >> 4;
3633
- if (t += y & 15, t > G) {
3634
- W && L(0);
3641
+ for (var H = (1 << s) - 1, j = (1 << J) - 1, f = t; ; f = t) {
3642
+ var E = b[Wl(V, t) & H], q = E >> 4;
3643
+ if (t += E & 15, t > i) {
3644
+ W && r(0);
3635
3645
  break;
3636
3646
  }
3637
- if (y || L(2), j < 256)
3638
- U[c++] = j;
3639
- else if (j == 256) {
3640
- _ = t, b = null;
3647
+ if (E || r(2), q < 256)
3648
+ U[c++] = q;
3649
+ else if (q == 256) {
3650
+ f = t, b = null;
3641
3651
  break;
3642
3652
  } else {
3643
- var $ = j - 254;
3644
- if (j > 264) {
3645
- var h = j - 257, ll = pl[h];
3646
- $ = x(V, t, (1 << ll) - 1) + rl[h], t += ll;
3653
+ var Fl = q - 254;
3654
+ if (q > 264) {
3655
+ var h = q - 257, w = pl[h];
3656
+ Fl = z(V, t, (1 << w) - 1) + rl[h], t += w;
3647
3657
  }
3648
- var Vl = a[Wl(V, t) & f], Rl = Vl >> 4;
3649
- Vl || L(3), t += Vl & 15;
3650
- var Y = NU[Rl];
3658
+ var Vl = a[Wl(V, t) & j], Rl = Vl >> 4;
3659
+ Vl || r(3), t += Vl & 15;
3660
+ var o = NU[Rl];
3651
3661
  if (Rl > 3) {
3652
- var ll = El[Rl];
3653
- Y += Wl(V, t) & (1 << ll) - 1, t += ll;
3662
+ var w = El[Rl];
3663
+ o += Wl(V, t) & (1 << w) - 1, t += w;
3654
3664
  }
3655
- if (t > G) {
3656
- W && L(0);
3665
+ if (t > i) {
3666
+ W && r(0);
3657
3667
  break;
3658
3668
  }
3659
3669
  R && n(c + 131072);
3660
- var el = c + $;
3661
- if (c < Y) {
3662
- var Gl = d - Y, Ml = Math.min(Y, el);
3663
- for (Gl + c < 0 && L(3); c < Ml; ++c)
3670
+ var el = c + Fl;
3671
+ if (c < o) {
3672
+ var Gl = d - o, Ml = Math.min(o, el);
3673
+ for (Gl + c < 0 && r(3); c < Ml; ++c)
3664
3674
  U[c] = F[Gl + c];
3665
3675
  }
3666
3676
  for (; c < el; ++c)
3667
- U[c] = U[c - Y];
3677
+ U[c] = U[c - o];
3668
3678
  }
3669
3679
  }
3670
- l.l = b, l.p = _, l.b = c, l.f = m, b && (m = 1, l.m = B, l.d = a, l.n = e);
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);
3671
3681
  } while (!m);
3672
- return c != U.length && Q ? sl(U, 0, c) : U.subarray(0, c);
3673
- }, kU = /* @__PURE__ */ new r(0), K = function(V, l) {
3682
+ return c != U.length && Q ? Jl(U, 0, c) : U.subarray(0, c);
3683
+ }, kU = /* @__PURE__ */ new T(0), g = function(V, l) {
3674
3684
  return V[l] | V[l + 1] << 8;
3675
- }, M = function(V, l) {
3685
+ }, I = function(V, l) {
3676
3686
  return (V[l] | V[l + 1] << 8 | V[l + 2] << 16 | V[l + 3] << 24) >>> 0;
3677
3687
  }, ml = function(V, l) {
3678
- return M(V, l) + M(V, l + 4) * 4294967296;
3688
+ return I(V, l) + I(V, l + 4) * 4294967296;
3679
3689
  };
3680
3690
  function TU(V, l) {
3681
3691
  return EU(V, { i: 2 }, l && l.out, l && l.dictionary);
@@ -3689,7 +3699,7 @@ var LU = function(V) {
3689
3699
  for (var l = "", U = 0; ; ) {
3690
3700
  var F = V[U++], Z = (F > 127) + (F > 223) + (F > 239);
3691
3701
  if (U + Z > V.length)
3692
- return { s: l, r: sl(V, U - 1) };
3702
+ return { s: l, r: Jl(V, U - 1) };
3693
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);
3694
3704
  }
3695
3705
  };
@@ -3702,33 +3712,33 @@ function Bl(V, l) {
3702
3712
  if (hl)
3703
3713
  return hl.decode(V);
3704
3714
  var Z = LU(V), d = Z.s, U = Z.r;
3705
- return U.length && L(8), d;
3715
+ return U.length && r(8), d;
3706
3716
  }
3707
3717
  }
3708
3718
  var CU = function(V, l) {
3709
- return l + 30 + K(V, l + 26) + K(V, l + 28);
3719
+ return l + 30 + g(V, l + 26) + g(V, l + 28);
3710
3720
  }, xU = function(V, l, U) {
3711
- var F = K(V, l + 28), Z = Bl(V.subarray(l + 46, l + 46 + F), !(K(V, l + 8) & 2048)), d = l + 46 + F, Q = M(V, l + 20), R = U && Q == 4294967295 ? MU(V, d) : [Q, M(V, l + 24), M(V, l + 42)], W = R[0], n = R[1], m = R[2];
3712
- return [K(V, l + 10), W, n, Z, d + K(V, l + 30) + K(V, l + 32), m];
3721
+ var F = g(V, l + 28), Z = Bl(V.subarray(l + 46, l + 46 + F), !(g(V, l + 8) & 2048)), d = l + 46 + F, Q = I(V, l + 20), R = U && Q == 4294967295 ? MU(V, d) : [Q, I(V, l + 24), I(V, l + 42)], W = R[0], n = R[1], m = R[2];
3722
+ return [g(V, l + 10), W, n, Z, d + g(V, l + 30) + g(V, l + 32), m];
3713
3723
  }, MU = function(V, l) {
3714
- for (; K(V, l) != 1; l += 4 + K(V, l + 2))
3724
+ for (; g(V, l) != 1; l += 4 + g(V, l + 2))
3715
3725
  ;
3716
3726
  return [ml(V, l + 12), ml(V, l + 4), ml(V, l + 20)];
3717
3727
  };
3718
3728
  function zU(V, l) {
3719
- for (var U = {}, F = V.length - 22; M(V, F) != 101010256; --F)
3720
- (!F || V.length - F > 65558) && L(13);
3721
- var Z = K(V, F + 8);
3729
+ for (var U = {}, F = V.length - 22; I(V, F) != 101010256; --F)
3730
+ (!F || V.length - F > 65558) && r(13);
3731
+ var Z = g(V, F + 8);
3722
3732
  if (!Z)
3723
3733
  return {};
3724
- var d = M(V, F + 16), Q = d == 4294967295 || Z == 65535;
3734
+ var d = I(V, F + 16), Q = d == 4294967295 || Z == 65535;
3725
3735
  if (Q) {
3726
- var R = M(V, F - 12);
3727
- Q = M(V, R) == 101075792, Q && (Z = M(V, R + 32), d = M(V, R + 48));
3736
+ var R = I(V, F - 12);
3737
+ Q = I(V, R) == 101075792, Q && (Z = I(V, R + 32), d = I(V, R + 48));
3728
3738
  }
3729
3739
  for (var W = 0; W < Z; ++W) {
3730
- var n = xU(V, d, Q), m = n[0], t = n[1], c = n[2], b = n[3], a = n[4], B = n[5], e = CU(V, B);
3731
- d = a, m ? m == 8 ? U[b] = TU(V.subarray(e, e + t), { out: new r(c) }) : L(14, "unknown compression type " + m) : U[b] = sl(V, e, e + t);
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);
3732
3742
  }
3733
3743
  return U;
3734
3744
  }
@@ -3834,7 +3844,7 @@ class jU {
3834
3844
  * @param {number} [options.startup.delayMs=25] - Startup delay in milliseconds
3835
3845
  */
3836
3846
  constructor(l = null, U = {}) {
3837
- 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 = Jl(), this._parser = new Pl(), this._musicXmlConverter = new GU(), this._partOutputsMap = /* @__PURE__ */ new Map(), this.instrumentMap = null, this.metronomeConfig = {
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 = {
3838
3848
  enabled: !1,
3839
3849
  tickInstrument: 115,
3840
3850
  // woodblock
@@ -3997,8 +4007,8 @@ class jU {
3997
4007
  */
3998
4008
  stop() {
3999
4009
  if (this.state === "stopped") return;
4000
- const l = this.state === "playing";
4001
- this.state = "stopped", this.frozenTime = 0, this.leadInData = null, this.leadInProgress = null, this.leadInStartTime = null, this._stopLeadIn(), this._stopMetronome(), this._stopTimeUpdateLoop(), this._resetMetronomeBeatTracking(), l && this.midiPlayer.stop(), this._emitEvent("playbackStopped", {});
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", {});
4002
4012
  }
4003
4013
  // ========================================
4004
4014
  // PUBLIC API - Positioning Methods
@@ -4988,20 +4998,20 @@ class jU {
4988
4998
  return;
4989
4999
  }
4990
5000
  l.getFloatTimeDomainData(W);
4991
- let a = 0, B = 0;
4992
- for (let G = 0; G < R; G++) {
4993
- const X = Math.abs(W[G]);
4994
- a += W[G] * W[G], X > B && (B = X);
5001
+ let a = 0, s = 0;
5002
+ for (let i = 0; i < R; i++) {
5003
+ const S = Math.abs(W[i]);
5004
+ a += W[i] * W[i], S > s && (s = S);
4995
5005
  }
4996
- const e = Math.sqrt(a / R);
4997
- if (e >= Z) {
5006
+ const J = Math.sqrt(a / R);
5007
+ if (J >= Z) {
4998
5008
  clearInterval(c);
4999
- const G = Q.currentTime, X = (G - U) * 1e3;
5009
+ const i = Q.currentTime, S = (i - U) * 1e3;
5000
5010
  t({
5001
- latencyMs: X,
5002
- rms: e,
5003
- peak: B,
5004
- detectedTime: G
5011
+ latencyMs: S,
5012
+ rms: J,
5013
+ peak: s,
5014
+ detectedTime: i
5005
5015
  });
5006
5016
  }
5007
5017
  }, F);
@@ -5025,18 +5035,18 @@ class jU {
5025
5035
  return;
5026
5036
  }
5027
5037
  l.getFloatTimeDomainData(R);
5028
- let a = 0, B = 0;
5029
- for (let X = 0; X < Q; X++) {
5030
- const N = Math.abs(R[X]);
5031
- a += R[X] * R[X], N > B && (B = N);
5038
+ let a = 0, s = 0;
5039
+ for (let S = 0; S < Q; S++) {
5040
+ const Y = Math.abs(R[S]);
5041
+ a += R[S] * R[S], Y > s && (s = Y);
5032
5042
  }
5033
- const e = Math.sqrt(a / Q), G = d.currentTime;
5043
+ const J = Math.sqrt(a / Q), i = d.currentTime;
5034
5044
  W.push({
5035
- time: G,
5036
- relativeTime: (G - U) * 1e3,
5045
+ time: i,
5046
+ relativeTime: (i - U) * 1e3,
5037
5047
  // ms relative to scheduled time
5038
- rms: e,
5039
- peak: B
5048
+ rms: J,
5049
+ peak: s
5040
5050
  });
5041
5051
  }, F);
5042
5052
  });