@songram/songram-daw-engine 3.3.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1038,7 +1038,6 @@ export declare class MidiToneTrack implements PlayableTrack {
1038
1038
  private muteGain;
1039
1039
  private track;
1040
1040
  private effectsCleanup?;
1041
- private _debugNoteCount;
1042
1041
  constructor(options: MidiToneTrackOptions);
1043
1042
  /**
1044
1043
  * Trigger a note using the appropriate synth.
package/dist/index.js CHANGED
@@ -28,12 +28,12 @@ function et(a) {
28
28
  t && u && t.sampleRate !== u.sample_rate && console.warn(
29
29
  `Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${u.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`
30
30
  );
31
- const b = a.durationSamples ?? g;
31
+ const k = a.durationSamples ?? g;
32
32
  return {
33
33
  id: Vt(),
34
34
  audioBuffer: t,
35
35
  startSample: e,
36
- durationSamples: b,
36
+ durationSamples: k,
37
37
  offsetSamples: i,
38
38
  sampleRate: d,
39
39
  sourceDurationSamples: g,
@@ -75,11 +75,11 @@ function Ke(a) {
75
75
  t && u && t.sampleRate !== u.sample_rate && console.warn(
76
76
  `Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${u.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`
77
77
  );
78
- const b = a.duration ?? g;
78
+ const k = a.duration ?? g;
79
79
  return et({
80
80
  audioBuffer: t,
81
81
  startSample: Math.round(e * d),
82
- durationSamples: Math.round(b * d),
82
+ durationSamples: Math.round(k * d),
83
83
  offsetSamples: Math.round(i * d),
84
84
  sampleRate: d,
85
85
  sourceDurationSamples: Math.ceil(g * d),
@@ -339,7 +339,7 @@ function ae(a, t) {
339
339
  }
340
340
  return e;
341
341
  }
342
- function br(a, t, e, i, n, r = 0) {
342
+ function kr(a, t, e, i, n, r = 0) {
343
343
  const u = (e + i / 2 - r) * a / n * n / t + r - i / 2;
344
344
  return Math.max(0, u);
345
345
  }
@@ -475,7 +475,7 @@ class ce {
475
475
  );
476
476
  h !== 0 && (this._tracks = this._tracks.map((f) => {
477
477
  if (f.id !== t) return f;
478
- const d = f.clips.map((g, b) => b !== s ? g : i === "left" ? {
478
+ const d = f.clips.map((g, k) => k !== s ? g : i === "left" ? {
479
479
  ...g,
480
480
  startSample: g.startSample + h,
481
481
  offsetSamples: g.offsetSamples + h,
@@ -690,7 +690,7 @@ function Rt(a, t, e) {
690
690
  return vt(t, e);
691
691
  }
692
692
  }
693
- function bt(a, t, e, i = "linear", n = 0, r = 1) {
693
+ function kt(a, t, e, i = "linear", n = 0, r = 1) {
694
694
  if (!(e <= 0))
695
695
  if (i === "linear")
696
696
  a.setValueAtTime(n, t), a.linearRampToValueAtTime(r, t + e);
@@ -703,7 +703,7 @@ function bt(a, t, e, i = "linear", n = 0, r = 1) {
703
703
  a.setValueCurveAtTime(c, t, e);
704
704
  }
705
705
  }
706
- function kt(a, t, e, i = "linear", n = 1, r = 0) {
706
+ function bt(a, t, e, i = "linear", n = 1, r = 0) {
707
707
  if (!(e <= 0))
708
708
  if (i === "linear")
709
709
  a.setValueAtTime(n, t), a.linearRampToValueAtTime(r, t + e);
@@ -822,7 +822,7 @@ class de {
822
822
  if (n.fadeIn && c < n.fadeIn.duration) {
823
823
  const l = n.fadeIn.duration;
824
824
  if (c <= 0)
825
- bt(
825
+ kt(
826
826
  s,
827
827
  e,
828
828
  l,
@@ -832,7 +832,7 @@ class de {
832
832
  );
833
833
  else {
834
834
  const u = l - c, o = c / l, h = n.gain * o;
835
- bt(
835
+ kt(
836
836
  s,
837
837
  e,
838
838
  u,
@@ -847,7 +847,7 @@ class de {
847
847
  const u = n.duration - n.fadeOut.duration - c;
848
848
  if (u > 0) {
849
849
  const o = e + u;
850
- kt(
850
+ bt(
851
851
  s,
852
852
  o,
853
853
  n.fadeOut.duration,
@@ -857,7 +857,7 @@ class de {
857
857
  );
858
858
  } else if (u > -n.fadeOut.duration) {
859
859
  const o = -u, h = n.fadeOut.duration - o, f = o / n.fadeOut.duration, d = n.gain * (1 - f);
860
- kt(
860
+ bt(
861
861
  s,
862
862
  e,
863
863
  h,
@@ -977,7 +977,7 @@ function fe(a) {
977
977
  }
978
978
  class me {
979
979
  constructor(t) {
980
- this._debugNoteCount = 0, this.track = t.track;
980
+ this.track = t.track;
981
981
  const e = t.clips.reduce((n, r) => n + r.notes.length, 0);
982
982
  console.log(`[songram-daw:MidiToneTrack] Creating track "${t.track.id}" with ${t.clips.length} clips, ${e} total notes`), this.volumeNode = new W(this.gainToDb(t.track.gain)), this.panNode = new st(t.track.stereoPan), this.muteGain = new ot(t.track.muted ? 0 : 1), this.volumeNode.chain(this.panNode, this.muteGain), this.synth = new G(jt, t.synthOptions), this.synth.connect(this.volumeNode), this.kickSynth = new G($, {
983
983
  voice: $,
@@ -1047,7 +1047,7 @@ class me {
1047
1047
  * Routes per-note: channel 9 → percussion synths, others → melodic PolySynth.
1048
1048
  */
1049
1049
  triggerNote(t, e, i, n, r, s) {
1050
- if (this._debugNoteCount || (this._debugNoteCount = 0), this._debugNoteCount < 5 && (console.log(`[songram-daw:MidiToneTrack] Triggering note ${e} (MIDI ${t}), vel=${r.toFixed(2)}, dur=${i.toFixed(3)}s, ch=${s ?? "none"}`), this._debugNoteCount++), s === 9)
1050
+ if (s === 9)
1051
1051
  switch (fe(t)) {
1052
1052
  case "kick":
1053
1053
  this.kickSynth.triggerAttackRelease("C1", i, n, r);
@@ -1275,17 +1275,17 @@ const L = class L {
1275
1275
  }
1276
1276
  const u = F().rawContext, o = u.createBufferSource();
1277
1277
  o.buffer = l.buffer, o.playbackRate.value = l.playbackRate, (l.loopMode === 1 || l.loopMode === 3) && (o.loop = !0, o.loopStart = l.loopStart, o.loopEnd = l.loopEnd);
1278
- const h = l.buffer.duration / l.playbackRate, f = l.loopMode === 0 ? Math.max(e, h) : e, d = n * n, g = u.createGain(), { attackVolEnv: b, holdVolEnv: y, decayVolEnv: m, sustainVolEnv: v, releaseVolEnv: k } = l, p = d * v;
1279
- g.gain.setValueAtTime(0, i), g.gain.linearRampToValueAtTime(d, i + b), y > 1e-3 && g.gain.setValueAtTime(d, i + b + y);
1280
- const S = i + b + y;
1281
- g.gain.linearRampToValueAtTime(p, S + m), g.gain.setValueAtTime(p, i + f), g.gain.linearRampToValueAtTime(0, i + f + k), o.connect(g), g.connect(this.volumeNode.input.input), this.activeSources.add(o), o.onended = () => {
1278
+ const h = l.buffer.duration / l.playbackRate, f = l.loopMode === 0 ? Math.max(e, h) : e, d = n * n, g = u.createGain(), { attackVolEnv: k, holdVolEnv: y, decayVolEnv: m, sustainVolEnv: v, releaseVolEnv: b } = l, p = d * v;
1279
+ g.gain.setValueAtTime(0, i), g.gain.linearRampToValueAtTime(d, i + k), y > 1e-3 && g.gain.setValueAtTime(d, i + k + y);
1280
+ const S = i + k + y;
1281
+ g.gain.linearRampToValueAtTime(p, S + m), g.gain.setValueAtTime(p, i + f), g.gain.linearRampToValueAtTime(0, i + f + b), o.connect(g), g.connect(this.volumeNode.input.input), this.activeSources.add(o), o.onended = () => {
1282
1282
  this.activeSources.delete(o);
1283
1283
  try {
1284
1284
  g.disconnect();
1285
1285
  } catch (w) {
1286
1286
  console.warn("[songram-daw] GainNode already disconnected:", w);
1287
1287
  }
1288
- }, o.start(i), o.stop(i + f + k);
1288
+ }, o.start(i), o.stop(i + f + b);
1289
1289
  }
1290
1290
  gainToDb(t) {
1291
1291
  return 20 * Math.log10(t);
@@ -1652,7 +1652,7 @@ function ve(a) {
1652
1652
  const { midiNote: t, overrideRootKey: e, originalPitch: i, coarseTune: n, fineTune: r, pitchCorrection: s } = a, l = t - (e !== void 0 ? e : i !== 255 ? i : 60) + n + (r + s) / 100;
1653
1653
  return Math.pow(2, l / 12);
1654
1654
  }
1655
- function be(a) {
1655
+ function ke(a) {
1656
1656
  const { generators: t, header: e } = a, i = _(t, T.SampleModes) ?? 0, n = e.startLoop + (_(t, T.StartLoopAddrsOffset) ?? 0) + (_(t, T.StartLoopAddrsCoarseOffset) ?? 0) * 32768, r = e.endLoop + (_(t, T.EndLoopAddrsOffset) ?? 0) + (_(t, T.EndLoopAddrsCoarseOffset) ?? 0) * 32768, s = n / e.sampleRate, c = r / e.sampleRate, l = z(
1657
1657
  _(t, T.AttackVolEnv) ?? -12e3
1658
1658
  ), u = z(
@@ -1674,7 +1674,7 @@ function be(a) {
1674
1674
  releaseVolEnv: h
1675
1675
  };
1676
1676
  }
1677
- class kr {
1677
+ class br {
1678
1678
  /**
1679
1679
  * @param context Optional AudioContext for createBuffer(). If omitted, uses
1680
1680
  * an OfflineAudioContext which doesn't require user gesture — safe to
@@ -1736,7 +1736,7 @@ class kr {
1736
1736
  coarseTune: _(n.generators, T.CoarseTune) ?? 0,
1737
1737
  fineTune: _(n.generators, T.FineTune) ?? 0,
1738
1738
  pitchCorrection: r.header.pitchCorrection ?? 0
1739
- }), u = be({
1739
+ }), u = ke({
1740
1740
  generators: n.generators,
1741
1741
  header: n.sample.header
1742
1742
  });
@@ -1795,12 +1795,12 @@ function xr(a) {
1795
1795
  function Mr(a) {
1796
1796
  return V.has(a);
1797
1797
  }
1798
- function ke(a) {
1798
+ function be(a) {
1799
1799
  let t = null, e = !1, i = 0, n = !1, r = 0, s = 0, c = !1;
1800
1800
  function l(o, h) {
1801
1801
  const f = h.clips.filter((g) => g.audioBuffer && !g.midiNotes), d = h.clips.filter((g) => g.midiNotes && g.midiNotes.length > 0);
1802
1802
  if (f.length > 0) {
1803
- const g = Math.min(...f.map(q)), b = Math.max(...f.map(dt)), y = {
1803
+ const g = Math.min(...f.map(q)), k = Math.max(...f.map(dt)), y = {
1804
1804
  id: h.id,
1805
1805
  name: h.name,
1806
1806
  gain: h.volume,
@@ -1808,7 +1808,7 @@ function ke(a) {
1808
1808
  soloed: h.soloed,
1809
1809
  stereoPan: h.pan,
1810
1810
  startTime: g,
1811
- endTime: b
1811
+ endTime: k
1812
1812
  }, m = f.map((v) => ({
1813
1813
  buffer: v.audioBuffer,
1814
1814
  startTime: q(v) - g,
@@ -1825,7 +1825,7 @@ function ke(a) {
1825
1825
  });
1826
1826
  }
1827
1827
  if (d.length > 0) {
1828
- const g = Math.min(...d.map(q)), b = Math.max(...d.map(dt)), m = {
1828
+ const g = Math.min(...d.map(q)), k = Math.max(...d.map(dt)), m = {
1829
1829
  id: f.length > 0 ? `${h.id}:midi` : h.id,
1830
1830
  name: h.name,
1831
1831
  gain: h.volume,
@@ -1833,15 +1833,15 @@ function ke(a) {
1833
1833
  soloed: h.soloed,
1834
1834
  stereoPan: h.pan,
1835
1835
  startTime: g,
1836
- endTime: b
1837
- }, v = d.map((k) => ({
1838
- notes: k.midiNotes,
1839
- startTime: q(k) - g,
1840
- duration: mt(k),
1841
- offset: ft(k)
1836
+ endTime: k
1837
+ }, v = d.map((b) => ({
1838
+ notes: b.midiNotes,
1839
+ startTime: q(b) - g,
1840
+ duration: mt(b),
1841
+ offset: ft(b)
1842
1842
  }));
1843
1843
  if (a?.soundFontCache?.isLoaded) {
1844
- const k = d[0], S = k.midiChannel === 9, w = k.midiProgram ?? 0;
1844
+ const b = d[0], S = b.midiChannel === 9, w = b.midiProgram ?? 0;
1845
1845
  o.addSoundFontTrack({
1846
1846
  clips: v,
1847
1847
  track: m,
@@ -2050,8 +2050,8 @@ function we() {
2050
2050
  return o.microsecondsPerBeat = r.readUInt24(), o;
2051
2051
  case 84:
2052
2052
  if (o.type = "smpteOffset", d != 5) throw "Expected length for smpteOffset event is 5, got " + d;
2053
- var g = r.readUInt8(), b = { 0: 24, 32: 25, 64: 29, 96: 30 };
2054
- return o.frameRate = b[g & 96], o.hour = g & 31, o.min = r.readUInt8(), o.sec = r.readUInt8(), o.frame = r.readUInt8(), o.subFrame = r.readUInt8(), o;
2053
+ var g = r.readUInt8(), k = { 0: 24, 32: 25, 64: 29, 96: 30 };
2054
+ return o.frameRate = k[g & 96], o.hour = g & 31, o.min = r.readUInt8(), o.sec = r.readUInt8(), o.frame = r.readUInt8(), o.subFrame = r.readUInt8(), o;
2055
2055
  case 88:
2056
2056
  if (o.type = "timeSignature", d != 2 && d != 4) throw "Expected length for timeSignature event is 4 or 2, got " + d;
2057
2057
  return o.numerator = r.readUInt8(), o.denominator = 1 << r.readUInt8(), d === 4 ? (o.metronome = r.readUInt8(), o.thirtyseconds = r.readUInt8()) : (o.metronome = 36, o.thirtyseconds = 8), o;
@@ -2221,8 +2221,8 @@ function Te() {
2221
2221
  break;
2222
2222
  case "smpteOffset":
2223
2223
  r.writeUInt8(255), r.writeUInt8(84), r.writeVarInt(5);
2224
- var g = { 24: 0, 25: 32, 29: 64, 30: 96 }, b = s.hour & 31 | g[s.frameRate];
2225
- r.writeUInt8(b), r.writeUInt8(s.min), r.writeUInt8(s.sec), r.writeUInt8(s.frame), r.writeUInt8(s.subFrame);
2224
+ var g = { 24: 0, 25: 32, 29: 64, 30: 96 }, k = s.hour & 31 | g[s.frameRate];
2225
+ r.writeUInt8(k), r.writeUInt8(s.min), r.writeUInt8(s.sec), r.writeUInt8(s.frame), r.writeUInt8(s.subFrame);
2226
2226
  break;
2227
2227
  case "timeSignature":
2228
2228
  r.writeUInt8(255), r.writeUInt8(88), r.writeVarInt(4), r.writeUInt8(s.numerator);
@@ -2267,8 +2267,8 @@ function Te() {
2267
2267
  break;
2268
2268
  case "pitchBend":
2269
2269
  d = 224 | s.channel, d !== c && r.writeUInt8(d);
2270
- var v = 8192 + s.value, k = v & 127, p = v >> 7 & 127;
2271
- r.writeUInt8(k), r.writeUInt8(p);
2270
+ var v = 8192 + s.value, b = v & 127, p = v >> 7 & 127;
2271
+ r.writeUInt8(b), r.writeUInt8(p);
2272
2272
  break;
2273
2273
  default:
2274
2274
  throw "Unrecognized event type: " + u;
@@ -3016,7 +3016,7 @@ function Ut() {
3016
3016
  return p.type === "noteOn";
3017
3017
  }), g = u.filter(function(p) {
3018
3018
  return p.type === "noteOff";
3019
- }), b = function() {
3019
+ }), k = function() {
3020
3020
  var p = d.shift();
3021
3021
  y.channel = p.channel;
3022
3022
  var S = g.findIndex(function(N) {
@@ -3033,7 +3033,7 @@ function Ut() {
3033
3033
  });
3034
3034
  }
3035
3035
  }, y = this; d.length; )
3036
- b();
3036
+ k();
3037
3037
  var m = u.filter(function(p) {
3038
3038
  return p.type === "controller";
3039
3039
  });
@@ -3054,10 +3054,10 @@ function Ut() {
3054
3054
  value: p.value / Math.pow(2, 13)
3055
3055
  });
3056
3056
  });
3057
- var k = u.find(function(p) {
3057
+ var b = u.find(function(p) {
3058
3058
  return p.type === "endOfTrack";
3059
3059
  });
3060
- this.endOfTrackTicks = k !== void 0 ? k.absoluteTime : void 0;
3060
+ this.endOfTrackTicks = b !== void 0 ? b.absoluteTime : void 0;
3061
3061
  }
3062
3062
  }
3063
3063
  return l.prototype.addNote = function(u) {
@@ -3169,8 +3169,8 @@ var Ot;
3169
3169
  function Ne() {
3170
3170
  if (Ot) return P;
3171
3171
  Ot = 1;
3172
- var a = P && P.__spreadArray || function(m, v, k) {
3173
- if (k || arguments.length === 2) for (var p = 0, S = v.length, w; p < S; p++)
3172
+ var a = P && P.__spreadArray || function(m, v, b) {
3173
+ if (b || arguments.length === 2) for (var p = 0, S = v.length, w; p < S; p++)
3174
3174
  (w || !(p in v)) && (w || (w = Array.prototype.slice.call(v, 0, p)), w[p] = v[p]);
3175
3175
  return m.concat(w || Array.prototype.slice.call(v));
3176
3176
  };
@@ -3212,8 +3212,8 @@ function Ne() {
3212
3212
  };
3213
3213
  }
3214
3214
  function c(m) {
3215
- for (var v = [], k = 0; k < 127; k++)
3216
- m.controlChanges.hasOwnProperty(k) && m.controlChanges[k].forEach(function(p) {
3215
+ for (var v = [], b = 0; b < 127; b++)
3216
+ m.controlChanges.hasOwnProperty(b) && m.controlChanges[b].forEach(function(p) {
3217
3217
  v.push(s(p, m.channel));
3218
3218
  });
3219
3219
  return v;
@@ -3229,8 +3229,8 @@ function Ne() {
3229
3229
  }
3230
3230
  function u(m) {
3231
3231
  var v = [];
3232
- return m.pitchBends.forEach(function(k) {
3233
- v.push(l(k, m.channel));
3232
+ return m.pitchBends.forEach(function(b) {
3233
+ v.push(l(b, m.channel));
3234
3234
  }), v;
3235
3235
  }
3236
3236
  function o(m) {
@@ -3283,7 +3283,7 @@ function Ne() {
3283
3283
  type: "keySignature"
3284
3284
  };
3285
3285
  }
3286
- function b(m) {
3286
+ function k(m) {
3287
3287
  return {
3288
3288
  absoluteTime: m.ticks,
3289
3289
  deltaTime: 0,
@@ -3309,36 +3309,36 @@ function Ne() {
3309
3309
  text: m.header.name,
3310
3310
  type: "trackName"
3311
3311
  }
3312
- ], m.header.keySignatures.map(function(k) {
3313
- return g(k);
3314
- }), !0), m.header.meta.map(function(k) {
3315
- return b(k);
3316
- }), !0), m.header.tempos.map(function(k) {
3317
- return f(k);
3318
- }), !0), m.header.timeSignatures.map(function(k) {
3319
- return d(k);
3312
+ ], m.header.keySignatures.map(function(b) {
3313
+ return g(b);
3314
+ }), !0), m.header.meta.map(function(b) {
3315
+ return k(b);
3316
+ }), !0), m.header.tempos.map(function(b) {
3317
+ return f(b);
3318
+ }), !0), m.header.timeSignatures.map(function(b) {
3319
+ return d(b);
3320
3320
  }), !0)
3321
- ], m.tracks.map(function(k) {
3321
+ ], m.tracks.map(function(b) {
3322
3322
  return a(a(a([
3323
3323
  // Add the name
3324
- h(k.name),
3324
+ h(b.name),
3325
3325
  // the instrument
3326
- o(k)
3327
- ], r(k), !0), c(k), !0), u(k), !0);
3326
+ o(b)
3327
+ ], r(b), !0), c(b), !0), u(b), !0);
3328
3328
  }), !0)
3329
3329
  };
3330
- return v.tracks = v.tracks.map(function(k) {
3331
- k = k.sort(function(S, w) {
3330
+ return v.tracks = v.tracks.map(function(b) {
3331
+ b = b.sort(function(S, w) {
3332
3332
  return S.absoluteTime - w.absoluteTime;
3333
3333
  });
3334
3334
  var p = 0;
3335
- return k.forEach(function(S) {
3335
+ return b.forEach(function(S) {
3336
3336
  S.deltaTime = S.absoluteTime - p, p = S.absoluteTime, delete S.absoluteTime;
3337
- }), k.push({
3337
+ }), b.push({
3338
3338
  deltaTime: 0,
3339
3339
  meta: !0,
3340
3340
  type: "endOfTrack"
3341
- }), k;
3341
+ }), b;
3342
3342
  }), new Uint8Array((0, t.writeMidi)(v));
3343
3343
  }
3344
3344
  return P.encode = y, P;
@@ -3347,7 +3347,7 @@ var At;
3347
3347
  function Ue() {
3348
3348
  return At || (At = 1, (function(a) {
3349
3349
  var t = M && M.__awaiter || function(h, f, d, g) {
3350
- function b(y) {
3350
+ function k(y) {
3351
3351
  return y instanceof d ? y : new d(function(m) {
3352
3352
  m(y);
3353
3353
  });
@@ -3360,7 +3360,7 @@ function Ue() {
3360
3360
  m(w);
3361
3361
  }
3362
3362
  }
3363
- function k(S) {
3363
+ function b(S) {
3364
3364
  try {
3365
3365
  p(g.throw(S));
3366
3366
  } catch (w) {
@@ -3368,7 +3368,7 @@ function Ue() {
3368
3368
  }
3369
3369
  }
3370
3370
  function p(S) {
3371
- S.done ? y(S.value) : b(S.value).then(v, k);
3371
+ S.done ? y(S.value) : k(S.value).then(v, b);
3372
3372
  }
3373
3373
  p((g = g.apply(h, f || [])).next());
3374
3374
  });
@@ -3376,20 +3376,20 @@ function Ue() {
3376
3376
  var d = { label: 0, sent: function() {
3377
3377
  if (y[0] & 1) throw y[1];
3378
3378
  return y[1];
3379
- }, trys: [], ops: [] }, g, b, y, m;
3379
+ }, trys: [], ops: [] }, g, k, y, m;
3380
3380
  return m = { next: v(0), throw: v(1), return: v(2) }, typeof Symbol == "function" && (m[Symbol.iterator] = function() {
3381
3381
  return this;
3382
3382
  }), m;
3383
3383
  function v(p) {
3384
3384
  return function(S) {
3385
- return k([p, S]);
3385
+ return b([p, S]);
3386
3386
  };
3387
3387
  }
3388
- function k(p) {
3388
+ function b(p) {
3389
3389
  if (g) throw new TypeError("Generator is already executing.");
3390
3390
  for (; d; ) try {
3391
- if (g = 1, b && (y = p[0] & 2 ? b.return : p[0] ? b.throw || ((y = b.return) && y.call(b), 0) : b.next) && !(y = y.call(b, p[1])).done) return y;
3392
- switch (b = 0, y && (p = [p[0] & 2, y.value]), p[0]) {
3391
+ if (g = 1, k && (y = p[0] & 2 ? k.return : p[0] ? k.throw || ((y = k.return) && y.call(k), 0) : k.next) && !(y = y.call(k, p[1])).done) return y;
3392
+ switch (k = 0, y && (p = [p[0] & 2, y.value]), p[0]) {
3393
3393
  case 0:
3394
3394
  case 1:
3395
3395
  y = p;
@@ -3397,7 +3397,7 @@ function Ue() {
3397
3397
  case 4:
3398
3398
  return d.label++, { value: p[1], done: !1 };
3399
3399
  case 5:
3400
- d.label++, b = p[1], p = [0];
3400
+ d.label++, k = p[1], p = [0];
3401
3401
  continue;
3402
3402
  case 7:
3403
3403
  p = d.ops.pop(), d.trys.pop();
@@ -3424,7 +3424,7 @@ function Ue() {
3424
3424
  }
3425
3425
  p = f.call(h, d);
3426
3426
  } catch (S) {
3427
- p = [6, S], b = 0;
3427
+ p = [6, S], k = 0;
3428
3428
  } finally {
3429
3429
  g = y = 0;
3430
3430
  }
@@ -3439,8 +3439,8 @@ function Ue() {
3439
3439
  function h(f) {
3440
3440
  var d = this, g = null;
3441
3441
  if (f) {
3442
- var b = f instanceof ArrayBuffer ? new Uint8Array(f) : f;
3443
- g = (0, i.parseMidi)(b), g.tracks.forEach(function(y) {
3442
+ var k = f instanceof ArrayBuffer ? new Uint8Array(f) : f;
3443
+ g = (0, i.parseMidi)(k), g.tracks.forEach(function(y) {
3444
3444
  var m = 0;
3445
3445
  y.forEach(function(v) {
3446
3446
  m += v.deltaTime, v.absoluteTime = m;
@@ -3454,14 +3454,14 @@ function Ue() {
3454
3454
  return h.fromUrl = function(f) {
3455
3455
  return t(this, void 0, void 0, function() {
3456
3456
  var d, g;
3457
- return e(this, function(b) {
3458
- switch (b.label) {
3457
+ return e(this, function(k) {
3458
+ switch (k.label) {
3459
3459
  case 0:
3460
3460
  return [4, fetch(f)];
3461
3461
  case 1:
3462
- return d = b.sent(), d.ok ? [4, d.arrayBuffer()] : [3, 3];
3462
+ return d = k.sent(), d.ok ? [4, d.arrayBuffer()] : [3, 3];
3463
3463
  case 2:
3464
- return g = b.sent(), [2, new h(g)];
3464
+ return g = k.sent(), [2, new h(g)];
3465
3465
  case 3:
3466
3466
  throw new Error("Could not load '".concat(f, "'"));
3467
3467
  }
@@ -3518,8 +3518,8 @@ function Ue() {
3518
3518
  }, h.prototype.fromJSON = function(f) {
3519
3519
  var d = this;
3520
3520
  this.header = new n.Header(), this.header.fromJSON(f.header), this.tracks = f.tracks.map(function(g) {
3521
- var b = new r.Track(void 0, d.header);
3522
- return b.fromJSON(g), b;
3521
+ var k = new r.Track(void 0, d.header);
3522
+ return k.fromJSON(g), k;
3523
3523
  });
3524
3524
  }, h.prototype.clone = function() {
3525
3525
  var f = new h();
@@ -3538,14 +3538,14 @@ function Ue() {
3538
3538
  } });
3539
3539
  function o(h) {
3540
3540
  for (var f = [], d = 0; d < h.length; d++)
3541
- for (var g = f.length, b = /* @__PURE__ */ new Map(), y = Array(16).fill(0), m = 0, v = h[d]; m < v.length; m++) {
3542
- var k = v[m], p = g, S = k.channel;
3541
+ for (var g = f.length, k = /* @__PURE__ */ new Map(), y = Array(16).fill(0), m = 0, v = h[d]; m < v.length; m++) {
3542
+ var b = v[m], p = g, S = b.channel;
3543
3543
  if (S !== void 0) {
3544
- k.type === "programChange" && (y[S] = k.programNumber);
3544
+ b.type === "programChange" && (y[S] = b.programNumber);
3545
3545
  var w = y[S], N = "".concat(w, " ").concat(S);
3546
- b.has(N) ? p = b.get(N) : (p = g + b.size, b.set(N, p));
3546
+ k.has(N) ? p = k.get(N) : (p = g + k.size, k.set(N, p));
3547
3547
  }
3548
- f[p] || f.push([]), f[p].push(k);
3548
+ f[p] || f.push([]), f[p].push(b);
3549
3549
  }
3550
3550
  return f;
3551
3551
  }
@@ -3706,10 +3706,10 @@ function De(a, t = {}) {
3706
3706
  for (const h of i.tracks) {
3707
3707
  const f = h.channel, d = h.instrument.number, g = h.name || Dt(d);
3708
3708
  l.has(f) || l.set(f, { notes: [], programNumber: d, name: g });
3709
- const b = l.get(f);
3710
- h.name && !b.name.startsWith(h.name) && (b.name = h.name);
3709
+ const k = l.get(f);
3710
+ h.name && !k.name.startsWith(h.name) && (k.name = h.name);
3711
3711
  for (const y of h.notes)
3712
- b.notes.push({
3712
+ k.notes.push({
3713
3713
  midi: y.midi,
3714
3714
  name: y.name,
3715
3715
  time: y.time,
@@ -3747,15 +3747,15 @@ function De(a, t = {}) {
3747
3747
  return l.forEach(({ notes: h, programNumber: f, name: d }, g) => {
3748
3748
  if (h.length === 0) return;
3749
3749
  h.sort((y, m) => y.time - m.time);
3750
- let b = 0;
3750
+ let k = 0;
3751
3751
  for (const y of h) {
3752
3752
  const m = y.time + y.duration;
3753
- m > b && (b = m);
3753
+ m > k && (k = m);
3754
3754
  }
3755
3755
  o.push({
3756
3756
  name: d,
3757
3757
  notes: h,
3758
- duration: b,
3758
+ duration: k,
3759
3759
  channel: g,
3760
3760
  instrument: g === 9 ? "Percussion" : Dt(f),
3761
3761
  programNumber: f
@@ -4041,7 +4041,7 @@ class ze {
4041
4041
  }, this.handleStop = () => {
4042
4042
  this.events.emit("stop");
4043
4043
  };
4044
- const { adapter: e, audio: i, plugins: n = [], ...r } = t, s = e ?? ke(i);
4044
+ const { adapter: e, audio: i, plugins: n = [], ...r } = t, s = e ?? be(i);
4045
4045
  this.playlist = new ce({
4046
4046
  ...r,
4047
4047
  adapter: s
@@ -4078,17 +4078,17 @@ export {
4078
4078
  ce as PlaylistEngine,
4079
4079
  qe as PluginHost,
4080
4080
  ze as SongramEngine,
4081
- kr as SoundFontCache,
4081
+ br as SoundFontCache,
4082
4082
  nt as SoundFontToneTrack,
4083
4083
  pe as TonePlayout,
4084
4084
  de as ToneTrack,
4085
- bt as applyFadeIn,
4086
- kt as applyFadeOut,
4085
+ kt as applyFadeIn,
4086
+ bt as applyFadeOut,
4087
4087
  K as calculateDuration,
4088
4088
  ve as calculatePlaybackRate,
4089
4089
  pr as calculateSplitPoint,
4090
4090
  gr as calculateViewportBounds,
4091
- br as calculateZoomScrollPosition,
4091
+ kr as calculateZoomScrollPosition,
4092
4092
  ne as canSplitAt,
4093
4093
  pt as clampSeekPosition,
4094
4094
  mt as clipDurationTime,
@@ -4107,10 +4107,10 @@ export {
4107
4107
  Ar as createNoteOn,
4108
4108
  Vr as createSongramEngine,
4109
4109
  Ze as createTimeline,
4110
- ke as createToneAdapter,
4110
+ be as createToneAdapter,
4111
4111
  Xe as createTrack,
4112
4112
  Yt as dBToNormalized,
4113
- be as extractLoopAndEnvelope,
4113
+ ke as extractLoopAndEnvelope,
4114
4114
  ae as findClosestZoomIndex,
4115
4115
  er as findGaps,
4116
4116
  fr as gainToNormalized,