@songram/songram-daw-engine 3.4.1 → 3.6.0

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.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { Volume as L, Panner as X, Gain as C, getDestination as O, getTransport as w, getContext as N, PolySynth as $, Synth as ce, MembraneSynth as j, NoiseSynth as ue, MetalSynth as dt, Part as lt, start as le, now as rt, Context as he, setContext as de, Sampler as fe, PitchShift as qt, BitCrusher as Lt, AutoFilter as zt, Tremolo as $t, Phaser as jt, Distortion as Ht, Chorus as Wt, PingPongDelay as Jt, FeedbackDelay as Kt, Freeverb as Xt, Reverb as Zt, Compressor as Qt, EQ3 as Yt, Sequence as pe, LFO as me, Meter as te, FFT as ge, Waveform as ye } from "tone";
2
- import { AMOscillator as Bs, AMSynth as Ds, Abs as Gs, Add as Rs, AmplitudeEnvelope as Vs, Analyser as qs, AutoFilter as Ls, AutoPanner as zs, AutoWah as $s, BiquadFilter as js, BitCrusher as Hs, Channel as Ws, Chebyshev as Js, Chorus as Ks, Compressor as Xs, Convolver as Zs, CrossFade as Qs, DCMeter as Ys, Distortion as tr, Draw as er, DuoSynth as nr, EQ3 as sr, Envelope as rr, FFT as ir, FMOscillator as ar, FMSynth as or, FatOscillator as cr, FeedbackDelay as ur, Filter as lr, Freeverb as hr, Frequency as dr, FrequencyEnvelope as fr, FrequencyShifter as pr, Gain as mr, Gate as gr, GrainPlayer as yr, GreaterThan as vr, GreaterThanZero as br, JCReverb as Sr, LFO as wr, Limiter as kr, Loop as Tr, LowpassCombFilter as Cr, MembraneSynth as Mr, Merge as _r, MetalSynth as Ir, Meter as xr, MidSideCompressor as Er, MidSideMerge as Pr, MidSideSplit as Fr, Midi as Ar, Mono as Nr, MonoSynth as Or, MultibandCompressor as Ur, MultibandSplit as Br, Multiply as Dr, Negate as Gr, NoiseSynth as Rr, OnePoleFilter as Vr, Oscillator as qr, PWMOscillator as Lr, PanVol as zr, Panner as $r, Panner3D as jr, Part as Hr, Pattern as Wr, Phaser as Jr, PingPongDelay as Kr, PitchShift as Xr, Player as Zr, Players as Qr, PluckSynth as Yr, PolySynth as ti, Pow as ei, PulseOscillator as ni, Reverb as si, Sampler as ri, Scale as ii, ScaleExp as ai, Sequence as oi, Signal as ci, Solo as ui, Split as li, StereoWidener as hi, Subtract as di, Synth as fi, Ticks as pi, Time as mi, ToneEvent as gi, Transport as yi, TransportTime as vi, Tremolo as bi, Vibrato as Si, Volume as wi, WaveShaper as ki, Waveform as Ti, getDraw as Ci, getTransport as Mi, immediate as _i, now as Ii } from "tone";
2
+ import { AMOscillator as Un, AMSynth as Bn, Abs as Dn, Add as Rn, AmplitudeEnvelope as Vn, Analyser as qn, AutoFilter as Ln, AutoPanner as zn, AutoWah as $n, BiquadFilter as jn, BitCrusher as Hn, Channel as Wn, Chebyshev as Jn, Chorus as Kn, Compressor as Xn, Convolver as Zn, CrossFade as Qn, DCMeter as Yn, Distortion as tr, Draw as er, DuoSynth as sr, EQ3 as nr, Envelope as rr, FFT as ir, FMOscillator as ar, FMSynth as or, FatOscillator as cr, FeedbackDelay as ur, Filter as lr, Freeverb as hr, Frequency as dr, FrequencyEnvelope as fr, FrequencyShifter as pr, Gain as mr, Gate as gr, GrainPlayer as yr, GreaterThan as vr, GreaterThanZero as br, JCReverb as Sr, LFO as wr, Limiter as kr, Loop as Tr, LowpassCombFilter as Cr, MembraneSynth as _r, Merge as Mr, MetalSynth as Ir, Meter as xr, MidSideCompressor as Er, MidSideMerge as Pr, MidSideSplit as Fr, Midi as Ar, Mono as Nr, MonoSynth as Or, MultibandCompressor as Gr, MultibandSplit as Ur, Multiply as Br, Negate as Dr, NoiseSynth as Rr, OnePoleFilter as Vr, Oscillator as qr, PWMOscillator as Lr, PanVol as zr, Panner as $r, Panner3D as jr, Part as Hr, Pattern as Wr, Phaser as Jr, PingPongDelay as Kr, PitchShift as Xr, Player as Zr, Players as Qr, PluckSynth as Yr, PolySynth as ti, Pow as ei, PulseOscillator as si, Reverb as ni, Sampler as ri, Scale as ii, ScaleExp as ai, Sequence as oi, Signal as ci, Solo as ui, Split as li, StereoWidener as hi, Subtract as di, Synth as fi, Ticks as pi, Time as mi, ToneEvent as gi, Transport as yi, TransportTime as vi, Tremolo as bi, Vibrato as Si, Volume as wi, WaveShaper as ki, Waveform as Ti, getDraw as Ci, getTransport as _i, immediate as Mi, now as Ii } from "tone";
3
3
  import ve from "eventemitter3";
4
- import { SoundFont2 as ft, GeneratorType as M } from "soundfont2";
5
- const Pn = 1e3;
4
+ import { SoundFont2 as ft, GeneratorType as _ } from "soundfont2";
5
+ const Es = 1e3;
6
6
  function it(i) {
7
7
  const {
8
8
  audioBuffer: t,
9
9
  startSample: e,
10
- offsetSamples: n = 0,
10
+ offsetSamples: s = 0,
11
11
  gain: r = 1,
12
- name: s,
12
+ name: n,
13
13
  color: a,
14
14
  fadeIn: o,
15
15
  fadeOut: u,
@@ -35,11 +35,11 @@ function it(i) {
35
35
  audioBuffer: t,
36
36
  startSample: e,
37
37
  durationSamples: v,
38
- offsetSamples: n,
38
+ offsetSamples: s,
39
39
  sampleRate: f,
40
40
  sourceDurationSamples: y,
41
41
  gain: r,
42
- name: s,
42
+ name: n,
43
43
  color: a,
44
44
  fadeIn: o,
45
45
  fadeOut: u,
@@ -49,13 +49,13 @@ function it(i) {
49
49
  midiProgram: d
50
50
  };
51
51
  }
52
- function Fn(i) {
52
+ function Ps(i) {
53
53
  const {
54
54
  audioBuffer: t,
55
55
  startTime: e,
56
- offset: n = 0,
56
+ offset: s = 0,
57
57
  gain: r = 1,
58
- name: s,
58
+ name: n,
59
59
  color: a,
60
60
  fadeIn: o,
61
61
  fadeOut: u,
@@ -81,11 +81,11 @@ function Fn(i) {
81
81
  audioBuffer: t,
82
82
  startSample: Math.round(e * f),
83
83
  durationSamples: Math.round(v * f),
84
- offsetSamples: Math.round(n * f),
84
+ offsetSamples: Math.round(s * f),
85
85
  sampleRate: f,
86
86
  sourceDurationSamples: Math.ceil(y * f),
87
87
  gain: r,
88
- name: s,
88
+ name: n,
89
89
  color: a,
90
90
  fadeIn: o,
91
91
  fadeOut: u,
@@ -95,13 +95,13 @@ function Fn(i) {
95
95
  midiProgram: d
96
96
  });
97
97
  }
98
- function An(i) {
98
+ function Fs(i) {
99
99
  const {
100
100
  name: t,
101
101
  clips: e = [],
102
- muted: n = !1,
102
+ muted: s = !1,
103
103
  soloed: r = !1,
104
- volume: s = 1,
104
+ volume: n = 1,
105
105
  pan: a = 0,
106
106
  color: o,
107
107
  height: u,
@@ -112,9 +112,9 @@ function An(i) {
112
112
  id: ee(),
113
113
  name: t,
114
114
  clips: e,
115
- muted: n,
115
+ muted: s,
116
116
  soloed: r,
117
- volume: s,
117
+ volume: n,
118
118
  pan: a,
119
119
  color: o,
120
120
  height: u,
@@ -122,10 +122,10 @@ function An(i) {
122
122
  spectrogramColorMap: c
123
123
  };
124
124
  }
125
- function Nn(i, t = 44100, e) {
126
- const r = i.reduce((s, a) => {
125
+ function As(i, t = 44100, e) {
126
+ const r = i.reduce((n, a) => {
127
127
  const o = a.clips.reduce((u, l) => Math.max(u, l.startSample + l.durationSamples), 0);
128
- return Math.max(s, o);
128
+ return Math.max(n, o);
129
129
  }, 0) / t;
130
130
  return {
131
131
  tracks: i,
@@ -139,87 +139,87 @@ function Nn(i, t = 44100, e) {
139
139
  function ee() {
140
140
  return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
141
141
  }
142
- function On(i, t, e) {
143
- return i.clips.filter((n) => {
144
- const r = n.startSample + n.durationSamples;
145
- return n.startSample < e && r > t;
142
+ function Ns(i, t, e) {
143
+ return i.clips.filter((s) => {
144
+ const r = s.startSample + s.durationSamples;
145
+ return s.startSample < e && r > t;
146
146
  });
147
147
  }
148
- function Un(i, t) {
148
+ function Os(i, t) {
149
149
  return i.clips.filter((e) => {
150
- const n = e.startSample + e.durationSamples;
151
- return t >= e.startSample && t < n;
150
+ const s = e.startSample + e.durationSamples;
151
+ return t >= e.startSample && t < s;
152
152
  });
153
153
  }
154
- function Bn(i, t) {
155
- const e = i.startSample + i.durationSamples, n = t.startSample + t.durationSamples;
156
- return i.startSample < n && e > t.startSample;
154
+ function Gs(i, t) {
155
+ const e = i.startSample + i.durationSamples, s = t.startSample + t.durationSamples;
156
+ return i.startSample < s && e > t.startSample;
157
157
  }
158
158
  function at(i) {
159
159
  return [...i].sort((t, e) => t.startSample - e.startSample);
160
160
  }
161
- function Dn(i) {
161
+ function Us(i) {
162
162
  if (i.clips.length === 0) return [];
163
163
  const t = at(i.clips), e = [];
164
- for (let n = 0; n < t.length - 1; n++) {
165
- const r = t[n].startSample + t[n].durationSamples, s = t[n + 1].startSample;
166
- s > r && e.push({
164
+ for (let s = 0; s < t.length - 1; s++) {
165
+ const r = t[s].startSample + t[s].durationSamples, n = t[s + 1].startSample;
166
+ n > r && e.push({
167
167
  startSample: r,
168
- endSample: s,
169
- durationSamples: s - r
168
+ endSample: n,
169
+ durationSamples: n - r
170
170
  });
171
171
  }
172
172
  return e;
173
173
  }
174
174
  var be = /* @__PURE__ */ ((i) => (i.Cursor = "cursor", i.Select = "select", i.Shift = "shift", i.FadeIn = "fadein", i.FadeOut = "fadeout", i))(be || {});
175
- function Gn(i, t) {
175
+ function Bs(i, t) {
176
176
  return i / t;
177
177
  }
178
- function Rn(i, t) {
178
+ function Ds(i, t) {
179
179
  return Math.ceil(i * t);
180
180
  }
181
- function Vn(i, t) {
181
+ function Rs(i, t) {
182
182
  return Math.floor(i / t);
183
183
  }
184
- function qn(i, t) {
184
+ function Vs(i, t) {
185
185
  return Math.floor(i * t);
186
186
  }
187
- function Ln(i, t, e) {
187
+ function qs(i, t, e) {
188
188
  return i * t / e;
189
189
  }
190
- function zn(i, t, e) {
190
+ function Ls(i, t, e) {
191
191
  return Math.ceil(i * e / t);
192
192
  }
193
193
  const z = 192;
194
- function ne(i, t = z) {
194
+ function se(i, t = z) {
195
195
  const [, e] = i;
196
196
  return t * (4 / e);
197
197
  }
198
198
  function Se(i, t = z) {
199
199
  const [e] = i;
200
- return e * ne(i, t);
200
+ return e * se(i, t);
201
201
  }
202
- function $n(i, t, e, n = z) {
203
- return Math.round(i * 60 * e / (t * n));
202
+ function zs(i, t, e, s = z) {
203
+ return Math.round(i * 60 * e / (t * s));
204
204
  }
205
- function jn(i, t, e, n = z) {
206
- return Math.round(i * n * t / (60 * e));
205
+ function $s(i, t, e, s = z) {
206
+ return Math.round(i * s * t / (60 * e));
207
207
  }
208
- function Hn(i, t) {
208
+ function js(i, t) {
209
209
  return Math.round(i / t) * t;
210
210
  }
211
- function Wn(i, t, e = z) {
212
- const n = Se(t, e), r = ne(t, e), s = Math.floor(i / n) + 1, a = Math.floor(i % n / r) + 1;
213
- return a === 1 ? `${s}` : `${s}.${a}`;
211
+ function Hs(i, t, e = z) {
212
+ const s = Se(t, e), r = se(t, e), n = Math.floor(i / s) + 1, a = Math.floor(i % s / r) + 1;
213
+ return a === 1 ? `${n}` : `${n}.${a}`;
214
214
  }
215
215
  const K = -100;
216
216
  function we(i, t = K) {
217
217
  return Number.isNaN(i) ? (console.warn("[songram-daw] dBToNormalized received NaN"), 0) : t >= 0 ? (console.warn("[songram-daw] dBToNormalized floor must be negative, got:", t), 0) : !isFinite(i) || i <= t ? 0 : (i - t) / -t;
218
218
  }
219
- function Jn(i, t = K) {
219
+ function Ws(i, t = K) {
220
220
  return isFinite(i) ? t >= 0 ? (console.warn("[songram-daw] normalizedToDb floor must be negative, got:", t), K) : Math.max(0, i) * -t + t : t;
221
221
  }
222
- function Kn(i, t = K) {
222
+ function Js(i, t = K) {
223
223
  if (i <= 0) return 0;
224
224
  const e = 20 * Math.log10(i);
225
225
  return we(e, t);
@@ -236,41 +236,41 @@ function mt(i) {
236
236
  function gt(i) {
237
237
  return i.durationSamples / i.sampleRate;
238
238
  }
239
- function Xn(i, t, e) {
239
+ function Ks(i, t, e) {
240
240
  return Math.floor((i + t) / e) - Math.floor(i / e);
241
241
  }
242
- function ke(i, t, e, n) {
242
+ function ke(i, t, e, s) {
243
243
  let r = t;
244
- const s = -i.startSample;
245
- if (r = Math.max(r, s), n > 0) {
246
- const a = e[n - 1], u = a.startSample + a.durationSamples - i.startSample;
244
+ const n = -i.startSample;
245
+ if (r = Math.max(r, n), s > 0) {
246
+ const a = e[s - 1], u = a.startSample + a.durationSamples - i.startSample;
247
247
  r = Math.max(r, u);
248
248
  }
249
- if (n < e.length - 1) {
250
- const o = e[n + 1].startSample - (i.startSample + i.durationSamples);
249
+ if (s < e.length - 1) {
250
+ const o = e[s + 1].startSample - (i.startSample + i.durationSamples);
251
251
  r = Math.min(r, o);
252
252
  }
253
253
  return r;
254
254
  }
255
- function Te(i, t, e, n, r, s) {
255
+ function Te(i, t, e, s, r, n) {
256
256
  let a = t;
257
257
  if (e === "left") {
258
258
  if (a = Math.max(a, -i.startSample), a = Math.max(a, -i.offsetSamples), r > 0) {
259
- const o = n[r - 1], u = o.startSample + o.durationSamples;
259
+ const o = s[r - 1], u = o.startSample + o.durationSamples;
260
260
  a = Math.max(a, u - i.startSample);
261
261
  }
262
- a = Math.min(a, i.durationSamples - s);
263
- } else if (a = Math.max(a, s - i.durationSamples), a = Math.min(a, i.sourceDurationSamples - i.offsetSamples - i.durationSamples), r < n.length - 1) {
264
- const o = n[r + 1];
262
+ a = Math.min(a, i.durationSamples - n);
263
+ } else if (a = Math.max(a, n - i.durationSamples), a = Math.min(a, i.sourceDurationSamples - i.offsetSamples - i.durationSamples), r < s.length - 1) {
264
+ const o = s[r + 1];
265
265
  a = Math.min(a, o.startSample - i.startSample - i.durationSamples);
266
266
  }
267
267
  return a;
268
268
  }
269
- function Zn(i, t) {
269
+ function Xs(i, t) {
270
270
  return Math.floor(i / t) * t;
271
271
  }
272
272
  function Ce(i, t) {
273
- const e = t - i.startSample, n = i.durationSamples - e, r = i.name ? `${i.name} (1)` : void 0, s = i.name ? `${i.name} (2)` : void 0, a = it({
273
+ const e = t - i.startSample, s = i.durationSamples - e, r = i.name ? `${i.name} (1)` : void 0, n = i.name ? `${i.name} (2)` : void 0, a = it({
274
274
  startSample: i.startSample,
275
275
  durationSamples: e,
276
276
  offsetSamples: i.offsetSamples,
@@ -284,12 +284,12 @@ function Ce(i, t) {
284
284
  waveformData: i.waveformData
285
285
  }), o = it({
286
286
  startSample: t,
287
- durationSamples: n,
287
+ durationSamples: s,
288
288
  offsetSamples: i.offsetSamples + e,
289
289
  sampleRate: i.sampleRate,
290
290
  sourceDurationSamples: i.sourceDurationSamples,
291
291
  gain: i.gain,
292
- name: s,
292
+ name: n,
293
293
  color: i.color,
294
294
  fadeOut: i.fadeOut,
295
295
  audioBuffer: i.audioBuffer,
@@ -297,51 +297,51 @@ function Ce(i, t) {
297
297
  });
298
298
  return { left: a, right: o };
299
299
  }
300
- function Me(i, t, e) {
301
- const n = i.startSample + i.durationSamples;
302
- if (t <= i.startSample || t >= n)
300
+ function _e(i, t, e) {
301
+ const s = i.startSample + i.durationSamples;
302
+ if (t <= i.startSample || t >= s)
303
303
  return !1;
304
- const r = t - i.startSample, s = n - t;
305
- return r >= e && s >= e;
304
+ const r = t - i.startSample, n = s - t;
305
+ return r >= e && n >= e;
306
306
  }
307
- function Qn(i, t, e = 1.5) {
308
- const n = t * e;
307
+ function Zs(i, t, e = 1.5) {
308
+ const s = t * e;
309
309
  return {
310
- visibleStart: Math.max(0, i - n),
311
- visibleEnd: i + t + n
310
+ visibleStart: Math.max(0, i - s),
311
+ visibleEnd: i + t + s
312
312
  };
313
313
  }
314
- function Yn(i, t, e, n) {
315
- const r = Math.ceil(i / t), s = [];
314
+ function Qs(i, t, e, s) {
315
+ const r = Math.ceil(i / t), n = [];
316
316
  for (let a = 0; a < r; a++) {
317
317
  const o = a * t, u = Math.min(i - o, t);
318
- o + u <= e || o >= n || s.push(a);
318
+ o + u <= e || o >= s || n.push(a);
319
319
  }
320
- return s;
320
+ return n;
321
321
  }
322
- function ts(i, t, e = 100) {
322
+ function Ys(i, t, e = 100) {
323
323
  return Math.abs(i - t) >= e;
324
324
  }
325
325
  function Q(i) {
326
326
  let t = 0;
327
327
  for (const e of i)
328
- for (const n of e.clips) {
329
- const s = (n.startSample + n.durationSamples) / n.sampleRate;
330
- t = Math.max(t, s);
328
+ for (const s of e.clips) {
329
+ const n = (s.startSample + s.durationSamples) / s.sampleRate;
330
+ t = Math.max(t, n);
331
331
  }
332
332
  return t;
333
333
  }
334
- function _e(i, t) {
334
+ function Me(i, t) {
335
335
  if (t.length === 0) return 0;
336
- let e = 0, n = Math.abs(t[0] - i);
336
+ let e = 0, s = Math.abs(t[0] - i);
337
337
  for (let r = 1; r < t.length; r++) {
338
- const s = Math.abs(t[r] - i);
339
- s < n && (n = s, e = r);
338
+ const n = Math.abs(t[r] - i);
339
+ n < s && (s = n, e = r);
340
340
  }
341
341
  return e;
342
342
  }
343
- function es(i, t, e, n, r, s = 0) {
344
- const l = (e + n / 2 - s) * i / r * r / t + s - n / 2;
343
+ function tn(i, t, e, s, r, n = 0) {
344
+ const l = (e + s / 2 - n) * i / r * r / t + n - s / 2;
345
345
  return Math.max(0, l);
346
346
  }
347
347
  function yt(i, t) {
@@ -352,12 +352,12 @@ class Pe {
352
352
  constructor(t = {}) {
353
353
  if (this._tracks = [], this._currentTime = 0, this._playStartPosition = 0, this._isPlaying = !1, this._selectedTrackId = null, this._selectionStart = 0, this._selectionEnd = 0, this._masterVolume = 1, this._loopStart = 0, this._loopEnd = 0, this._isLoopEnabled = !1, this._tracksVersion = 0, this._animFrameId = null, this._disposed = !1, this._listeners = /* @__PURE__ */ new Map(), this._sampleRate = t.sampleRate ?? Ie, this._zoomLevels = [...t.zoomLevels ?? Ee], this._adapter = t.adapter ?? null, this._zoomLevels.length === 0)
354
354
  throw new Error("PlaylistEngine: zoomLevels must not be empty");
355
- const e = t.samplesPerPixel ?? xe, n = this._zoomLevels.indexOf(e);
356
- if (n === -1)
355
+ const e = t.samplesPerPixel ?? xe, s = this._zoomLevels.indexOf(e);
356
+ if (s === -1)
357
357
  throw new Error(
358
358
  `PlaylistEngine: samplesPerPixel ${e} is not in zoomLevels [${this._zoomLevels.join(", ")}]. Either pass a samplesPerPixel value that exists in zoomLevels, or include ${e} in your zoomLevels array.`
359
359
  );
360
- this._zoomIndex = n;
360
+ this._zoomIndex = s;
361
361
  }
362
362
  // ---------------------------------------------------------------------------
363
363
  // State snapshot
@@ -401,24 +401,24 @@ class Pe {
401
401
  // ---------------------------------------------------------------------------
402
402
  // Clip Editing (delegates to operations/)
403
403
  // ---------------------------------------------------------------------------
404
- moveClip(t, e, n) {
404
+ moveClip(t, e, s) {
405
405
  const r = this._tracks.find((c) => c.id === t);
406
406
  if (!r) {
407
407
  console.warn(`[songram-daw/engine] moveClip: track "${t}" not found`);
408
408
  return;
409
409
  }
410
- const s = r.clips.findIndex((c) => c.id === e);
411
- if (s === -1) {
410
+ const n = r.clips.findIndex((c) => c.id === e);
411
+ if (n === -1) {
412
412
  console.warn(
413
413
  `[songram-daw/engine] moveClip: clip "${e}" not found in track "${t}"`
414
414
  );
415
415
  return;
416
416
  }
417
- const a = r.clips[s], o = at(r.clips), u = o.findIndex((c) => c.id === e), l = ke(a, n, o, u);
417
+ const a = r.clips[n], o = at(r.clips), u = o.findIndex((c) => c.id === e), l = ke(a, s, o, u);
418
418
  l !== 0 && (this._tracks = this._tracks.map((c) => {
419
419
  if (c.id !== t) return c;
420
420
  const h = c.clips.map(
421
- (d, f) => f === s ? {
421
+ (d, f) => f === n ? {
422
422
  ...d,
423
423
  startSample: Math.floor(d.startSample + l)
424
424
  } : d
@@ -426,57 +426,57 @@ class Pe {
426
426
  return { ...c, clips: h };
427
427
  }), this._tracksVersion++, this._adapter?.setTracks(this._tracks), this._emitStateChange());
428
428
  }
429
- splitClip(t, e, n) {
429
+ splitClip(t, e, s) {
430
430
  const r = this._tracks.find((c) => c.id === t);
431
431
  if (!r) {
432
432
  console.warn(`[songram-daw/engine] splitClip: track "${t}" not found`);
433
433
  return;
434
434
  }
435
- const s = r.clips.findIndex((c) => c.id === e);
436
- if (s === -1) {
435
+ const n = r.clips.findIndex((c) => c.id === e);
436
+ if (n === -1) {
437
437
  console.warn(
438
438
  `[songram-daw/engine] splitClip: clip "${e}" not found in track "${t}"`
439
439
  );
440
440
  return;
441
441
  }
442
- const a = r.clips[s], o = Math.floor(vt * this._sampleRate);
443
- if (!Me(a, n, o)) {
442
+ const a = r.clips[n], o = Math.floor(vt * this._sampleRate);
443
+ if (!_e(a, s, o)) {
444
444
  console.warn(
445
- `[songram-daw/engine] splitClip: cannot split clip "${e}" at sample ${n} (clip range: ${a.startSample}–${a.startSample + a.durationSamples}, minDuration: ${o})`
445
+ `[songram-daw/engine] splitClip: cannot split clip "${e}" at sample ${s} (clip range: ${a.startSample}–${a.startSample + a.durationSamples}, minDuration: ${o})`
446
446
  );
447
447
  return;
448
448
  }
449
- const { left: u, right: l } = Ce(a, n);
449
+ const { left: u, right: l } = Ce(a, s);
450
450
  this._tracks = this._tracks.map((c) => {
451
451
  if (c.id !== t) return c;
452
452
  const h = [...c.clips];
453
- return h.splice(s, 1, u, l), { ...c, clips: h };
453
+ return h.splice(n, 1, u, l), { ...c, clips: h };
454
454
  }), this._tracksVersion++, this._adapter?.setTracks(this._tracks), this._emitStateChange();
455
455
  }
456
- trimClip(t, e, n, r) {
457
- const s = this._tracks.find((d) => d.id === t);
458
- if (!s) {
456
+ trimClip(t, e, s, r) {
457
+ const n = this._tracks.find((d) => d.id === t);
458
+ if (!n) {
459
459
  console.warn(`[songram-daw/engine] trimClip: track "${t}" not found`);
460
460
  return;
461
461
  }
462
- const a = s.clips.findIndex((d) => d.id === e);
462
+ const a = n.clips.findIndex((d) => d.id === e);
463
463
  if (a === -1) {
464
464
  console.warn(
465
465
  `[songram-daw/engine] trimClip: clip "${e}" not found in track "${t}"`
466
466
  );
467
467
  return;
468
468
  }
469
- const o = s.clips[a], u = at(s.clips), l = u.findIndex((d) => d.id === e), c = Math.floor(vt * this._sampleRate), h = Te(
469
+ const o = n.clips[a], u = at(n.clips), l = u.findIndex((d) => d.id === e), c = Math.floor(vt * this._sampleRate), h = Te(
470
470
  o,
471
471
  r,
472
- n,
472
+ s,
473
473
  u,
474
474
  l,
475
475
  c
476
476
  );
477
477
  h !== 0 && (this._tracks = this._tracks.map((d) => {
478
478
  if (d.id !== t) return d;
479
- const f = d.clips.map((y, v) => v !== a ? y : n === "left" ? {
479
+ const f = d.clips.map((y, v) => v !== a ? y : s === "left" ? {
480
480
  ...y,
481
481
  startSample: y.startSample + h,
482
482
  offsetSamples: y.offsetSamples + h,
@@ -492,22 +492,22 @@ class Pe {
492
492
  this._adapter && await this._adapter.init();
493
493
  }
494
494
  play(t, e) {
495
- const n = this._currentTime, r = this._playStartPosition;
495
+ const s = this._currentTime, r = this._playStartPosition;
496
496
  if (t !== void 0) {
497
- const s = Q(this._tracks);
498
- this._currentTime = yt(t, s);
497
+ const n = Q(this._tracks);
498
+ this._currentTime = yt(t, n);
499
499
  }
500
500
  if (this._playStartPosition = this._currentTime, this._adapter) {
501
501
  if (e !== void 0)
502
502
  this._adapter.setLoop(!1, this._loopStart, this._loopEnd);
503
503
  else if (this._isLoopEnabled) {
504
- const s = this._currentTime < this._loopEnd;
505
- this._adapter.setLoop(s, this._loopStart, this._loopEnd);
504
+ const n = this._currentTime < this._loopEnd;
505
+ this._adapter.setLoop(n, this._loopStart, this._loopEnd);
506
506
  }
507
507
  try {
508
508
  this._adapter.play(this._currentTime, e);
509
- } catch (s) {
510
- throw this._currentTime = n, this._playStartPosition = r, s;
509
+ } catch (n) {
510
+ throw this._currentTime = s, this._playStartPosition = r, n;
511
511
  }
512
512
  }
513
513
  this._isPlaying = !0, this._startTimeUpdateLoop(), this._emit("play"), this._emitStateChange();
@@ -532,12 +532,12 @@ class Pe {
532
532
  // Selection & Loop
533
533
  // ---------------------------------------------------------------------------
534
534
  setSelection(t, e) {
535
- const n = Math.min(t, e), r = Math.max(t, e);
536
- n === this._selectionStart && r === this._selectionEnd || (this._selectionStart = n, this._selectionEnd = r, this._emitStateChange());
535
+ const s = Math.min(t, e), r = Math.max(t, e);
536
+ s === this._selectionStart && r === this._selectionEnd || (this._selectionStart = s, this._selectionEnd = r, this._emitStateChange());
537
537
  }
538
538
  setLoopRegion(t, e) {
539
- const n = Math.min(t, e), r = Math.max(t, e);
540
- n === this._loopStart && r === this._loopEnd || (this._loopStart = n, this._loopEnd = r, this._adapter?.setLoop(
539
+ const s = Math.min(t, e), r = Math.max(t, e);
540
+ s === this._loopStart && r === this._loopEnd || (this._loopStart = s, this._loopEnd = r, this._adapter?.setLoop(
541
541
  this._isLoopEnabled && this._isBeforeLoopEnd(),
542
542
  this._loopStart,
543
543
  this._loopEnd
@@ -550,20 +550,33 @@ class Pe {
550
550
  // Per-Track Audio (delegates to adapter)
551
551
  // ---------------------------------------------------------------------------
552
552
  setTrackVolume(t, e) {
553
- const n = this._tracks.find((r) => r.id === t);
554
- n && (n.volume = e), this._adapter?.setTrackVolume(t, e);
553
+ const s = this._tracks.find((r) => r.id === t);
554
+ s && (s.volume = e), this._adapter?.setTrackVolume(t, e);
555
555
  }
556
556
  setTrackMute(t, e) {
557
- const n = this._tracks.find((r) => r.id === t);
558
- n && (n.muted = e), this._adapter?.setTrackMute(t, e);
557
+ const s = this._tracks.find((r) => r.id === t);
558
+ s && (s.muted = e), this._adapter?.setTrackMute(t, e);
559
559
  }
560
560
  setTrackSolo(t, e) {
561
- const n = this._tracks.find((r) => r.id === t);
562
- n && (n.soloed = e), this._adapter?.setTrackSolo(t, e);
561
+ const s = this._tracks.find((r) => r.id === t);
562
+ s && (s.soloed = e), this._adapter?.setTrackSolo(t, e);
563
563
  }
564
564
  setTrackPan(t, e) {
565
- const n = this._tracks.find((r) => r.id === t);
566
- n && (n.pan = e), this._adapter?.setTrackPan(t, e);
565
+ const s = this._tracks.find((r) => r.id === t);
566
+ s && (s.pan = e), this._adapter?.setTrackPan(t, e);
567
+ }
568
+ /**
569
+ * Hot-swap a track's effects chain without stopping playback or rebuilding.
570
+ * The effects function is called with the track's audio graph end node and
571
+ * the master volume destination. Returns an optional cleanup function.
572
+ */
573
+ setTrackEffects(t, e) {
574
+ const s = this._tracks.find((r) => r.id === t);
575
+ if (!s) {
576
+ console.warn(`[songram-daw/engine] setTrackEffects: track "${t}" not found`);
577
+ return;
578
+ }
579
+ s.effects = e, this._adapter?.setTrackEffects?.(t, e);
567
580
  }
568
581
  // ---------------------------------------------------------------------------
569
582
  // Zoom
@@ -575,7 +588,7 @@ class Pe {
575
588
  this._zoomIndex < this._zoomLevels.length - 1 && (this._zoomIndex++, this._emitStateChange());
576
589
  }
577
590
  setZoomLevel(t) {
578
- const e = _e(t, this._zoomLevels);
591
+ const e = Me(t, this._zoomLevels);
579
592
  e !== this._zoomIndex && (this._zoomIndex = e, this._emitStateChange());
580
593
  }
581
594
  // ---------------------------------------------------------------------------
@@ -605,13 +618,13 @@ class Pe {
605
618
  // Private helpers
606
619
  // ---------------------------------------------------------------------------
607
620
  _emit(t, ...e) {
608
- const n = this._listeners.get(t);
609
- if (n)
610
- for (const r of n)
621
+ const s = this._listeners.get(t);
622
+ if (s)
623
+ for (const r of s)
611
624
  try {
612
625
  r(...e);
613
- } catch (s) {
614
- console.warn("[songram-daw/engine] Error in event listener:", s);
626
+ } catch (n) {
627
+ console.warn("[songram-daw/engine] Error in event listener:", n);
615
628
  }
616
629
  }
617
630
  /**
@@ -648,36 +661,36 @@ function Z(i) {
648
661
  )), t;
649
662
  }
650
663
  function St(i, t) {
651
- const e = new Float32Array(i), n = i - 1;
664
+ const e = new Float32Array(i), s = i - 1;
652
665
  for (let r = 0; r < i; r++) {
653
- const s = r / n;
654
- e[r] = t ? s : 1 - s;
666
+ const n = r / s;
667
+ e[r] = t ? n : 1 - n;
655
668
  }
656
669
  return e;
657
670
  }
658
671
  function Fe(i, t) {
659
- const e = new Float32Array(i), n = i - 1;
672
+ const e = new Float32Array(i), s = i - 1;
660
673
  for (let r = 0; r < i; r++) {
661
- const s = r / n, a = t ? r : i - 1 - r;
662
- e[a] = Math.exp(2 * s - 1) / Math.E;
674
+ const n = r / s, a = t ? r : i - 1 - r;
675
+ e[a] = Math.exp(2 * n - 1) / Math.E;
663
676
  }
664
677
  return e;
665
678
  }
666
679
  function Ae(i, t) {
667
- const e = new Float32Array(i), n = t ? Math.PI / 2 : -Math.PI / 2;
680
+ const e = new Float32Array(i), s = t ? Math.PI / 2 : -Math.PI / 2;
668
681
  for (let r = 0; r < i; r++)
669
- e[r] = Math.sin(Math.PI * r / i - n) / 2 + 0.5;
682
+ e[r] = Math.sin(Math.PI * r / i - s) / 2 + 0.5;
670
683
  return e;
671
684
  }
672
685
  function Ne(i, t, e = 10) {
673
- const n = new Float32Array(i);
686
+ const s = new Float32Array(i);
674
687
  for (let r = 0; r < i; r++) {
675
- const s = t ? r : i - 1 - r, a = r / i;
676
- n[s] = Math.log(1 + e * a) / Math.log(1 + e);
688
+ const n = t ? r : i - 1 - r, a = r / i;
689
+ s[n] = Math.log(1 + e * a) / Math.log(1 + e);
677
690
  }
678
- return n;
691
+ return s;
679
692
  }
680
- function se(i, t, e) {
693
+ function ne(i, t, e) {
681
694
  switch (i) {
682
695
  case "linear":
683
696
  return St(t, e);
@@ -691,29 +704,29 @@ function se(i, t, e) {
691
704
  return St(t, e);
692
705
  }
693
706
  }
694
- function wt(i, t, e, n = "linear", r = 0, s = 1) {
707
+ function wt(i, t, e, s = "linear", r = 0, n = 1) {
695
708
  if (!(e <= 0))
696
- if (n === "linear")
697
- i.setValueAtTime(r, t), i.linearRampToValueAtTime(s, t + e);
698
- else if (n === "exponential")
699
- i.setValueAtTime(Math.max(r, 1e-3), t), i.exponentialRampToValueAtTime(Math.max(s, 1e-3), t + e);
709
+ if (s === "linear")
710
+ i.setValueAtTime(r, t), i.linearRampToValueAtTime(n, t + e);
711
+ else if (s === "exponential")
712
+ i.setValueAtTime(Math.max(r, 1e-3), t), i.exponentialRampToValueAtTime(Math.max(n, 1e-3), t + e);
700
713
  else {
701
- const a = se(n, 1e4, !0), o = new Float32Array(a.length), u = s - r;
714
+ const a = ne(s, 1e4, !0), o = new Float32Array(a.length), u = n - r;
702
715
  for (let l = 0; l < a.length; l++)
703
716
  o[l] = r + a[l] * u;
704
717
  i.setValueCurveAtTime(o, t, e);
705
718
  }
706
719
  }
707
- function kt(i, t, e, n = "linear", r = 1, s = 0) {
720
+ function kt(i, t, e, s = "linear", r = 1, n = 0) {
708
721
  if (!(e <= 0))
709
- if (n === "linear")
710
- i.setValueAtTime(r, t), i.linearRampToValueAtTime(s, t + e);
711
- else if (n === "exponential")
712
- i.setValueAtTime(Math.max(r, 1e-3), t), i.exponentialRampToValueAtTime(Math.max(s, 1e-3), t + e);
722
+ if (s === "linear")
723
+ i.setValueAtTime(r, t), i.linearRampToValueAtTime(n, t + e);
724
+ else if (s === "exponential")
725
+ i.setValueAtTime(Math.max(r, 1e-3), t), i.exponentialRampToValueAtTime(Math.max(n, 1e-3), t + e);
713
726
  else {
714
- const a = se(n, 1e4, !1), o = new Float32Array(a.length), u = r - s;
727
+ const a = ne(s, 1e4, !1), o = new Float32Array(a.length), u = r - n;
715
728
  for (let l = 0; l < a.length; l++)
716
- o[l] = s + a[l] * u;
729
+ o[l] = n + a[l] * u;
717
730
  i.setValueCurveAtTime(o, t, e);
718
731
  }
719
732
  }
@@ -721,12 +734,12 @@ class Oe {
721
734
  constructor(t) {
722
735
  this.activeSources = /* @__PURE__ */ new Set(), this._scheduleGuardOffset = 0, this.track = t.track, this.volumeNode = new L(this.gainToDb(t.track.gain)), this.panNode = new X({ pan: t.track.stereoPan, channelCount: 2 }), this.muteGain = new C(t.track.muted ? 0 : 1), this.volumeNode.chain(this.panNode, this.muteGain);
723
736
  const e = t.destination || O();
724
- if (t.effects) {
737
+ if (this._destination = e, t.effects) {
725
738
  const o = t.effects(this.muteGain, e, !1);
726
739
  o && (this.effectsCleanup = o);
727
740
  } else
728
741
  this.muteGain.connect(e);
729
- const n = t.clips || (t.buffer ? [
742
+ const s = t.clips || (t.buffer ? [
730
743
  {
731
744
  buffer: t.buffer,
732
745
  startTime: 0,
@@ -736,9 +749,9 @@ class Oe {
736
749
  fadeOut: t.track.fadeOut,
737
750
  gain: 1
738
751
  }
739
- ] : []), r = w(), s = N().rawContext, a = this.volumeNode.input.input;
740
- this.scheduledClips = n.map((o) => {
741
- const u = s.createGain();
752
+ ] : []), r = w(), n = N().rawContext, a = this.volumeNode.input.input;
753
+ this.scheduledClips = s.map((o) => {
754
+ const u = n.createGain();
742
755
  u.gain.value = o.gain, u.connect(a);
743
756
  const l = this.track.startTime + o.startTime, c = r.schedule((h) => {
744
757
  l < this._scheduleGuardOffset || this.startClipSource(o, u, h);
@@ -750,15 +763,15 @@ class Oe {
750
763
  * Create and start an AudioBufferSourceNode for a clip.
751
764
  * Sources are one-shot: each play or loop iteration creates a fresh one.
752
765
  */
753
- startClipSource(t, e, n, r, s) {
766
+ startClipSource(t, e, s, r, n) {
754
767
  const o = N().rawContext.createBufferSource();
755
768
  o.buffer = t.buffer, o.connect(e);
756
- const u = r ?? t.offset, l = s ?? t.duration;
769
+ const u = r ?? t.offset, l = n ?? t.duration;
757
770
  try {
758
- o.start(n, u, l);
771
+ o.start(s, u, l);
759
772
  } catch (c) {
760
773
  console.warn(
761
- `[songram-daw] Failed to start source on track "${this.id}" (time=${n}, offset=${u}, duration=${l}):`,
774
+ `[songram-daw] Failed to start source on track "${this.id}" (time=${s}, offset=${u}, duration=${l}):`,
762
775
  c
763
776
  ), o.disconnect();
764
777
  return;
@@ -784,12 +797,12 @@ class Oe {
784
797
  * schedule callbacks at exact Transport position (e.g., loopStart).
785
798
  */
786
799
  startMidClipSources(t, e) {
787
- for (const { clipInfo: n, fadeGainNode: r } of this.scheduledClips) {
788
- const s = this.track.startTime + n.startTime, a = s + n.duration;
789
- if (s < t && a > t) {
790
- const o = t - s, u = n.offset + o, l = n.duration - o;
800
+ for (const { clipInfo: s, fadeGainNode: r } of this.scheduledClips) {
801
+ const n = this.track.startTime + s.startTime, a = n + s.duration;
802
+ if (n < t && a > t) {
803
+ const o = t - n, u = s.offset + o, l = s.duration - o;
791
804
  this.startClipSource(
792
- n,
805
+ s,
793
806
  r,
794
807
  e,
795
808
  u,
@@ -816,10 +829,10 @@ class Oe {
816
829
  * Schedule fade envelopes for a clip at the given AudioContext time.
817
830
  * Uses native GainNode.gain (AudioParam) directly — no _param workaround needed.
818
831
  */
819
- scheduleFades(t, e, n = 0) {
820
- const { clipInfo: r, fadeGainNode: s } = t, a = s.gain;
832
+ scheduleFades(t, e, s = 0) {
833
+ const { clipInfo: r, fadeGainNode: n } = t, a = n.gain;
821
834
  a.cancelScheduledValues(0);
822
- const o = n - r.offset;
835
+ const o = s - r.offset;
823
836
  if (r.fadeIn && o < r.fadeIn.duration) {
824
837
  const u = r.fadeIn.duration;
825
838
  if (o <= 0)
@@ -874,15 +887,15 @@ class Oe {
874
887
  * Called before Transport.start() to schedule fades at correct AudioContext times.
875
888
  */
876
889
  prepareFades(t, e) {
877
- this.scheduledClips.forEach((n) => {
878
- const r = this.track.startTime + n.clipInfo.startTime, s = r + n.clipInfo.duration;
879
- if (!(e >= s))
890
+ this.scheduledClips.forEach((s) => {
891
+ const r = this.track.startTime + s.clipInfo.startTime, n = r + s.clipInfo.duration;
892
+ if (!(e >= n))
880
893
  if (e >= r) {
881
- const a = e - r + n.clipInfo.offset;
882
- this.scheduleFades(n, t, a);
894
+ const a = e - r + s.clipInfo.offset;
895
+ this.scheduleFades(s, t, a);
883
896
  } else {
884
897
  const a = r - e;
885
- this.scheduleFades(n, t + a, n.clipInfo.offset);
898
+ this.scheduleFades(s, t + a, s.clipInfo.offset);
886
899
  }
887
900
  });
888
901
  }
@@ -892,8 +905,8 @@ class Oe {
892
905
  */
893
906
  cancelFades() {
894
907
  this.scheduledClips.forEach(({ fadeGainNode: t, clipInfo: e }) => {
895
- const n = t.gain;
896
- n.cancelScheduledValues(0), n.setValueAtTime(e.gain, 0);
908
+ const s = t.gain;
909
+ s.cancelScheduledValues(0), s.setValueAtTime(e.gain, 0);
897
910
  });
898
911
  }
899
912
  gainToDb(t) {
@@ -913,6 +926,30 @@ class Oe {
913
926
  setSolo(t) {
914
927
  this.track.soloed = t;
915
928
  }
929
+ /**
930
+ * Hot-swap the effects chain without stopping playback.
931
+ * Disconnects the old effects (if any), runs the new effects function,
932
+ * and reconnects the audio graph. Active sources keep playing.
933
+ */
934
+ setEffects(t) {
935
+ if (this.effectsCleanup) {
936
+ try {
937
+ this.effectsCleanup();
938
+ } catch (e) {
939
+ console.warn(`[songram-daw] Error during track "${this.id}" effects cleanup:`, e);
940
+ }
941
+ this.effectsCleanup = void 0;
942
+ } else
943
+ try {
944
+ this.muteGain.disconnect(this._destination);
945
+ } catch {
946
+ }
947
+ if (t) {
948
+ const e = t(this.muteGain, this._destination, !1);
949
+ e && (this.effectsCleanup = e);
950
+ } else
951
+ this.muteGain.connect(this._destination);
952
+ }
916
953
  dispose() {
917
954
  const t = w();
918
955
  if (this.effectsCleanup)
@@ -921,12 +958,12 @@ class Oe {
921
958
  } catch (e) {
922
959
  console.warn(`[songram-daw] Error during track "${this.id}" effects cleanup:`, e);
923
960
  }
924
- this.stopAllSources(), this.scheduledClips.forEach((e, n) => {
961
+ this.stopAllSources(), this.scheduledClips.forEach((e, s) => {
925
962
  try {
926
963
  t.clear(e.scheduleId);
927
964
  } catch (r) {
928
965
  console.warn(
929
- `[songram-daw] Error clearing schedule ${n} on track "${this.id}":`,
966
+ `[songram-daw] Error clearing schedule ${s} on track "${this.id}":`,
930
967
  r
931
968
  );
932
969
  }
@@ -934,7 +971,7 @@ class Oe {
934
971
  e.fadeGainNode.disconnect();
935
972
  } catch (r) {
936
973
  console.warn(
937
- `[songram-daw] Error disconnecting fadeGain ${n} on track "${this.id}":`,
974
+ `[songram-daw] Error disconnecting fadeGain ${s} on track "${this.id}":`,
938
975
  r
939
976
  );
940
977
  }
@@ -973,13 +1010,13 @@ class Oe {
973
1010
  return this.track.startTime;
974
1011
  }
975
1012
  }
976
- function Ue(i) {
1013
+ function Ge(i) {
977
1014
  return i === 35 || i === 36 ? "kick" : i >= 37 && i <= 40 ? "snare" : i === 41 || i === 43 || i === 45 || i === 47 || i === 48 || i === 50 ? "tom" : "cymbal";
978
1015
  }
979
- class Be {
1016
+ class Ue {
980
1017
  constructor(t) {
981
1018
  this.track = t.track;
982
- const e = t.clips.reduce((r, s) => r + s.notes.length, 0);
1019
+ const e = t.clips.reduce((r, n) => r + n.notes.length, 0);
983
1020
  console.log(`[songram-daw:MidiToneTrack] Creating track "${t.track.id}" with ${t.clips.length} clips, ${e} total notes`), this.volumeNode = new L(this.gainToDb(t.track.gain)), this.panNode = new X(t.track.stereoPan), this.muteGain = new C(t.track.muted ? 0 : 1), this.volumeNode.chain(this.panNode, this.muteGain), this.synth = new $(ce, t.synthOptions), this.synth.connect(this.volumeNode), this.kickSynth = new $(j, {
984
1021
  voice: j,
985
1022
  options: {
@@ -1007,17 +1044,17 @@ class Be {
1007
1044
  envelope: { attack: 1e-3, decay: 0.3, sustain: 0, release: 0.1 }
1008
1045
  }
1009
1046
  }), this.kickSynth.connect(this.volumeNode), this.snareSynth.connect(this.volumeNode), this.cymbalSynth.connect(this.volumeNode), this.tomSynth.connect(this.volumeNode);
1010
- const n = t.destination || O();
1011
- if (t.effects) {
1012
- const r = t.effects(this.muteGain, n, !1);
1047
+ const s = t.destination || O();
1048
+ if (this._destination = s, t.effects) {
1049
+ const r = t.effects(this.muteGain, s, !1);
1013
1050
  r && (this.effectsCleanup = r);
1014
1051
  } else
1015
- this.muteGain.connect(n);
1052
+ this.muteGain.connect(s);
1016
1053
  this.scheduledClips = t.clips.map((r) => {
1017
- const s = r.notes.filter((l) => {
1054
+ const n = r.notes.filter((l) => {
1018
1055
  const c = l.time + l.duration;
1019
1056
  return l.time < r.offset + r.duration && c > r.offset;
1020
- }), a = this.track.startTime + r.startTime, o = s.map((l) => {
1057
+ }), a = this.track.startTime + r.startTime, o = n.map((l) => {
1021
1058
  const c = l.time - r.offset, h = Math.max(0, c), d = Math.min(
1022
1059
  l.duration - Math.max(0, r.offset - l.time),
1023
1060
  r.duration - h
@@ -1047,15 +1084,15 @@ class Be {
1047
1084
  * Trigger a note using the appropriate synth.
1048
1085
  * Routes per-note: channel 9 → percussion synths, others → melodic PolySynth.
1049
1086
  */
1050
- triggerNote(t, e, n, r, s, a) {
1087
+ triggerNote(t, e, s, r, n, a) {
1051
1088
  if (a === 9)
1052
- switch (Ue(t)) {
1089
+ switch (Ge(t)) {
1053
1090
  case "kick":
1054
- this.kickSynth.triggerAttackRelease("C1", n, r, s);
1091
+ this.kickSynth.triggerAttackRelease("C1", s, r, n);
1055
1092
  break;
1056
1093
  case "snare":
1057
1094
  try {
1058
- this.snareSynth.triggerAttackRelease(n, r, s);
1095
+ this.snareSynth.triggerAttackRelease(s, r, n);
1059
1096
  } catch (u) {
1060
1097
  console.warn(
1061
1098
  "[songram-daw] Snare overlap — previous hit still decaying, skipped:",
@@ -1074,18 +1111,18 @@ class Be {
1074
1111
  };
1075
1112
  this.tomSynth.triggerAttackRelease(
1076
1113
  u[t] || "C2",
1077
- n,
1114
+ s,
1078
1115
  r,
1079
- s
1116
+ n
1080
1117
  );
1081
1118
  break;
1082
1119
  }
1083
1120
  case "cymbal":
1084
- this.cymbalSynth.triggerAttackRelease("C4", n, r, s);
1121
+ this.cymbalSynth.triggerAttackRelease("C4", s, r, n);
1085
1122
  break;
1086
1123
  }
1087
1124
  else
1088
- this.synth.triggerAttackRelease(e, n, r, s);
1125
+ this.synth.triggerAttackRelease(e, s, r, n);
1089
1126
  }
1090
1127
  gainToDb(t) {
1091
1128
  return 20 * Math.log10(t);
@@ -1101,11 +1138,11 @@ class Be {
1101
1138
  * We trigger them with their remaining duration.
1102
1139
  */
1103
1140
  startMidClipSources(t, e) {
1104
- for (const { clipInfo: n } of this.scheduledClips) {
1105
- const r = this.track.startTime + n.startTime, s = r + n.duration;
1106
- if (r < t && s > t)
1107
- for (const a of n.notes) {
1108
- const o = a.time - n.offset, u = r + Math.max(0, o), l = u + a.duration;
1141
+ for (const { clipInfo: s } of this.scheduledClips) {
1142
+ const r = this.track.startTime + s.startTime, n = r + s.duration;
1143
+ if (r < t && n > t)
1144
+ for (const a of s.notes) {
1145
+ const o = a.time - s.offset, u = r + Math.max(0, o), l = u + a.duration;
1109
1146
  if (u < t && l > t) {
1110
1147
  const c = l - t;
1111
1148
  try {
@@ -1162,6 +1199,28 @@ class Be {
1162
1199
  setSolo(t) {
1163
1200
  this.track.soloed = t;
1164
1201
  }
1202
+ /**
1203
+ * Hot-swap the effects chain without stopping playback.
1204
+ */
1205
+ setEffects(t) {
1206
+ if (this.effectsCleanup) {
1207
+ try {
1208
+ this.effectsCleanup();
1209
+ } catch (e) {
1210
+ console.warn(`[songram-daw] Error during MIDI track "${this.id}" effects cleanup:`, e);
1211
+ }
1212
+ this.effectsCleanup = void 0;
1213
+ } else
1214
+ try {
1215
+ this.muteGain.disconnect(this._destination);
1216
+ } catch {
1217
+ }
1218
+ if (t) {
1219
+ const e = t(this.muteGain, this._destination, !1);
1220
+ e && (this.effectsCleanup = e);
1221
+ } else
1222
+ this.muteGain.connect(this._destination);
1223
+ }
1165
1224
  dispose() {
1166
1225
  if (this.effectsCleanup)
1167
1226
  try {
@@ -1172,12 +1231,12 @@ class Be {
1172
1231
  e
1173
1232
  );
1174
1233
  }
1175
- this.stopAllSources(), this.scheduledClips.forEach(({ part: e }, n) => {
1234
+ this.stopAllSources(), this.scheduledClips.forEach(({ part: e }, s) => {
1176
1235
  try {
1177
1236
  e.dispose();
1178
1237
  } catch (r) {
1179
1238
  console.warn(
1180
- `[songram-daw] Error disposing Part ${n} on MIDI track "${this.id}":`,
1239
+ `[songram-daw] Error disposing Part ${s} on MIDI track "${this.id}":`,
1181
1240
  r
1182
1241
  );
1183
1242
  }
@@ -1192,8 +1251,8 @@ class Be {
1192
1251
  for (const e of t)
1193
1252
  try {
1194
1253
  e?.dispose();
1195
- } catch (n) {
1196
- console.warn(`[songram-daw] Error disposing synth on MIDI track "${this.id}":`, n);
1254
+ } catch (s) {
1255
+ console.warn(`[songram-daw] Error disposing synth on MIDI track "${this.id}":`, s);
1197
1256
  }
1198
1257
  try {
1199
1258
  this.volumeNode.dispose();
@@ -1233,22 +1292,22 @@ const q = class q {
1233
1292
  constructor(t) {
1234
1293
  this.activeSources = /* @__PURE__ */ new Set(), this.track = t.track, this.soundFontCache = t.soundFontCache, this.programNumber = t.programNumber ?? 0, this.bankNumber = t.isPercussion ? 128 : 0, this.volumeNode = new L(this.gainToDb(t.track.gain)), this.panNode = new X(t.track.stereoPan), this.muteGain = new C(t.track.muted ? 0 : 1), this.volumeNode.chain(this.panNode, this.muteGain);
1235
1294
  const e = t.destination || O();
1236
- if (t.effects) {
1237
- const n = t.effects(this.muteGain, e, !1);
1238
- n && (this.effectsCleanup = n);
1295
+ if (this._destination = e, t.effects) {
1296
+ const s = t.effects(this.muteGain, e, !1);
1297
+ s && (this.effectsCleanup = s);
1239
1298
  } else
1240
1299
  this.muteGain.connect(e);
1241
- this.scheduledClips = t.clips.map((n) => {
1242
- const r = n.notes.filter((u) => {
1300
+ this.scheduledClips = t.clips.map((s) => {
1301
+ const r = s.notes.filter((u) => {
1243
1302
  const l = u.time + u.duration;
1244
- return u.time < n.offset + n.duration && l > n.offset;
1245
- }), s = this.track.startTime + n.startTime, a = r.map((u) => {
1246
- const l = u.time - n.offset, c = Math.max(0, l), h = Math.min(
1247
- u.duration - Math.max(0, n.offset - u.time),
1248
- n.duration - c
1303
+ return u.time < s.offset + s.duration && l > s.offset;
1304
+ }), n = this.track.startTime + s.startTime, a = r.map((u) => {
1305
+ const l = u.time - s.offset, c = Math.max(0, l), h = Math.min(
1306
+ u.duration - Math.max(0, s.offset - u.time),
1307
+ s.duration - c
1249
1308
  );
1250
1309
  return {
1251
- time: s + c,
1310
+ time: n + c,
1252
1311
  note: u.name,
1253
1312
  midi: u.midi,
1254
1313
  duration: Math.max(0, h),
@@ -1258,7 +1317,7 @@ const q = class q {
1258
1317
  }), o = new lt((u, l) => {
1259
1318
  l.duration > 0 && this.triggerNote(l.midi, l.duration, u, l.velocity, l.channel);
1260
1319
  }, a);
1261
- return o.start(0), { clipInfo: n, part: o };
1320
+ return o.start(0), { clipInfo: s, part: o };
1262
1321
  });
1263
1322
  }
1264
1323
  /**
@@ -1266,8 +1325,8 @@ const q = class q {
1266
1325
  *
1267
1326
  * Per-note routing: channel 9 → bank 128 (drums), others → bank 0 with programNumber.
1268
1327
  */
1269
- triggerNote(t, e, n, r, s) {
1270
- const a = s === 9 ? 128 : this.bankNumber, o = s === 9 ? 0 : this.programNumber, u = this.soundFontCache.getAudioBuffer(t, a, o);
1328
+ triggerNote(t, e, s, r, n) {
1329
+ const a = n === 9 ? 128 : this.bankNumber, o = n === 9 ? 0 : this.programNumber, u = this.soundFontCache.getAudioBuffer(t, a, o);
1271
1330
  if (!u) {
1272
1331
  q._missingSampleWarned || (console.warn(
1273
1332
  `[songram-daw] SoundFont sample not found for MIDI note ${t} (bank ${a}, preset ${o}). Subsequent missing samples will be silent.`
@@ -1277,16 +1336,16 @@ const q = class q {
1277
1336
  const l = N().rawContext, c = l.createBufferSource();
1278
1337
  c.buffer = u.buffer, c.playbackRate.value = u.playbackRate, (u.loopMode === 1 || u.loopMode === 3) && (c.loop = !0, c.loopStart = u.loopStart, c.loopEnd = u.loopEnd);
1279
1338
  const h = u.buffer.duration / u.playbackRate, d = u.loopMode === 0 ? Math.max(e, h) : e, f = r * r, y = l.createGain(), { attackVolEnv: v, holdVolEnv: g, decayVolEnv: m, sustainVolEnv: S, releaseVolEnv: b } = u, p = f * S;
1280
- y.gain.setValueAtTime(0, n), y.gain.linearRampToValueAtTime(f, n + v), g > 1e-3 && y.gain.setValueAtTime(f, n + v + g);
1281
- const k = n + v + g;
1282
- y.gain.linearRampToValueAtTime(p, k + m), y.gain.setValueAtTime(p, n + d), y.gain.linearRampToValueAtTime(0, n + d + b), c.connect(y), y.connect(this.volumeNode.input.input), this.activeSources.add(c), c.onended = () => {
1339
+ y.gain.setValueAtTime(0, s), y.gain.linearRampToValueAtTime(f, s + v), g > 1e-3 && y.gain.setValueAtTime(f, s + v + g);
1340
+ const k = s + v + g;
1341
+ y.gain.linearRampToValueAtTime(p, k + m), y.gain.setValueAtTime(p, s + d), y.gain.linearRampToValueAtTime(0, s + d + b), c.connect(y), y.connect(this.volumeNode.input.input), this.activeSources.add(c), c.onended = () => {
1283
1342
  this.activeSources.delete(c);
1284
1343
  try {
1285
1344
  y.disconnect();
1286
1345
  } catch (T) {
1287
1346
  console.warn("[songram-daw] GainNode already disconnected:", T);
1288
1347
  }
1289
- }, c.start(n), c.stop(n + d + b);
1348
+ }, c.start(s), c.stop(s + d + b);
1290
1349
  }
1291
1350
  gainToDb(t) {
1292
1351
  return 20 * Math.log10(t);
@@ -1300,11 +1359,11 @@ const q = class q {
1300
1359
  * Start notes that should already be sounding at the current transport offset.
1301
1360
  */
1302
1361
  startMidClipSources(t, e) {
1303
- for (const { clipInfo: n } of this.scheduledClips) {
1304
- const r = this.track.startTime + n.startTime, s = r + n.duration;
1305
- if (r < t && s > t)
1306
- for (const a of n.notes) {
1307
- const o = a.time - n.offset, u = r + Math.max(0, o), l = u + a.duration;
1362
+ for (const { clipInfo: s } of this.scheduledClips) {
1363
+ const r = this.track.startTime + s.startTime, n = r + s.duration;
1364
+ if (r < t && n > t)
1365
+ for (const a of s.notes) {
1366
+ const o = a.time - s.offset, u = r + Math.max(0, o), l = u + a.duration;
1308
1367
  if (u < t && l > t) {
1309
1368
  const c = l - t;
1310
1369
  try {
@@ -1357,6 +1416,28 @@ const q = class q {
1357
1416
  setSolo(t) {
1358
1417
  this.track.soloed = t;
1359
1418
  }
1419
+ /**
1420
+ * Hot-swap the effects chain without stopping playback.
1421
+ */
1422
+ setEffects(t) {
1423
+ if (this.effectsCleanup) {
1424
+ try {
1425
+ this.effectsCleanup();
1426
+ } catch (e) {
1427
+ console.warn(`[songram-daw] Error during SoundFont track "${this.id}" effects cleanup:`, e);
1428
+ }
1429
+ this.effectsCleanup = void 0;
1430
+ } else
1431
+ try {
1432
+ this.muteGain.disconnect(this._destination);
1433
+ } catch {
1434
+ }
1435
+ if (t) {
1436
+ const e = t(this.muteGain, this._destination, !1);
1437
+ e && (this.effectsCleanup = e);
1438
+ } else
1439
+ this.muteGain.connect(this._destination);
1440
+ }
1360
1441
  dispose() {
1361
1442
  if (this.effectsCleanup)
1362
1443
  try {
@@ -1370,10 +1451,10 @@ const q = class q {
1370
1451
  this.stopAllSources(), this.scheduledClips.forEach(({ part: t }, e) => {
1371
1452
  try {
1372
1453
  t.dispose();
1373
- } catch (n) {
1454
+ } catch (s) {
1374
1455
  console.warn(
1375
1456
  `[songram-daw] Error disposing Part ${e} on SoundFont track "${this.id}":`,
1376
- n
1457
+ s
1377
1458
  );
1378
1459
  }
1379
1460
  });
@@ -1419,7 +1500,7 @@ const q = class q {
1419
1500
  };
1420
1501
  q._missingSampleWarned = !1;
1421
1502
  let ot = q;
1422
- class De {
1503
+ class Be {
1423
1504
  constructor(t = {}) {
1424
1505
  if (this.tracks = /* @__PURE__ */ new Map(), this.isInitialized = !1, this.soloedTracks = /* @__PURE__ */ new Set(), this.manualMuteState = /* @__PURE__ */ new Map(), this._completionEventId = null, this._loopHandler = null, this._loopEnabled = !1, this._loopStart = 0, this._loopEnd = 0, this.masterVolume = new L(this.gainToDb(t.masterGain ?? 1)), t.effects) {
1425
1506
  const e = t.effects(this.masterVolume, O(), !1);
@@ -1450,22 +1531,22 @@ class De {
1450
1531
  const e = {
1451
1532
  ...t,
1452
1533
  destination: this.masterVolume
1453
- }, n = new Oe(e);
1454
- return this.tracks.set(n.id, n), this.manualMuteState.set(n.id, t.track.muted ?? !1), t.track.soloed && this.soloedTracks.add(n.id), n;
1534
+ }, s = new Oe(e);
1535
+ return this.tracks.set(s.id, s), this.manualMuteState.set(s.id, t.track.muted ?? !1), t.track.soloed && this.soloedTracks.add(s.id), s;
1455
1536
  }
1456
1537
  addMidiTrack(t) {
1457
1538
  const e = {
1458
1539
  ...t,
1459
1540
  destination: this.masterVolume
1460
- }, n = new Be(e);
1461
- return this.tracks.set(n.id, n), this.manualMuteState.set(n.id, t.track.muted ?? !1), t.track.soloed && this.soloedTracks.add(n.id), n;
1541
+ }, s = new Ue(e);
1542
+ return this.tracks.set(s.id, s), this.manualMuteState.set(s.id, t.track.muted ?? !1), t.track.soloed && this.soloedTracks.add(s.id), s;
1462
1543
  }
1463
1544
  addSoundFontTrack(t) {
1464
1545
  const e = {
1465
1546
  ...t,
1466
1547
  destination: this.masterVolume
1467
- }, n = new ot(e);
1468
- return this.tracks.set(n.id, n), this.manualMuteState.set(n.id, t.track.muted ?? !1), t.track.soloed && this.soloedTracks.add(n.id), n;
1548
+ }, s = new ot(e);
1549
+ return this.tracks.set(s.id, s), this.manualMuteState.set(s.id, t.track.muted ?? !1), t.track.soloed && this.soloedTracks.add(s.id), s;
1469
1550
  }
1470
1551
  /**
1471
1552
  * Apply solo muting after all tracks have been added.
@@ -1481,24 +1562,24 @@ class De {
1481
1562
  getTrack(t) {
1482
1563
  return this.tracks.get(t);
1483
1564
  }
1484
- play(t, e, n) {
1565
+ play(t, e, s) {
1485
1566
  if (!this.isInitialized)
1486
1567
  throw new Error("[songram-daw] TonePlayout not initialized. Call init() first.");
1487
- const r = t ?? rt(), s = w();
1568
+ const r = t ?? rt(), n = w();
1488
1569
  this.clearCompletionEvent();
1489
1570
  const a = e ?? 0;
1490
1571
  this.tracks.forEach((o) => {
1491
1572
  o.cancelFades(), o.prepareFades(r, a);
1492
- }), n !== void 0 && (this._completionEventId = s.scheduleOnce(() => {
1573
+ }), s !== void 0 && (this._completionEventId = n.scheduleOnce(() => {
1493
1574
  this._completionEventId = null;
1494
1575
  try {
1495
1576
  this.onPlaybackCompleteCallback?.();
1496
1577
  } catch (o) {
1497
1578
  console.warn("[songram-daw] Error in playback completion callback:", o);
1498
1579
  }
1499
- }, a + n));
1580
+ }, a + s));
1500
1581
  try {
1501
- s.state !== "stopped" && s.stop(), this.tracks.forEach((o) => o.stopAllSources()), s.loopStart = this._loopStart, s.loopEnd = this._loopEnd, s.loop = this._loopEnabled, this.tracks.forEach((o) => o.setScheduleGuardOffset(a)), e !== void 0 ? s.start(r, e) : s.start(r), s._clock._lastUpdate = r, this.tracks.forEach((o) => {
1582
+ n.state !== "stopped" && n.stop(), this.tracks.forEach((o) => o.stopAllSources()), n.loopStart = this._loopStart, n.loopEnd = this._loopEnd, n.loop = this._loopEnabled, this.tracks.forEach((o) => o.setScheduleGuardOffset(a)), e !== void 0 ? n.start(r, e) : n.start(r), n._clock._lastUpdate = r, this.tracks.forEach((o) => {
1502
1583
  o.startMidClipSources(a, r);
1503
1584
  });
1504
1585
  } catch (o) {
@@ -1535,14 +1616,14 @@ class De {
1535
1616
  this.tracks.forEach((e) => {
1536
1617
  try {
1537
1618
  e.stopAllSources();
1538
- } catch (n) {
1539
- console.warn(`[songram-daw] Error stopping sources for track "${e.id}":`, n);
1619
+ } catch (s) {
1620
+ console.warn(`[songram-daw] Error stopping sources for track "${e.id}":`, s);
1540
1621
  }
1541
1622
  }), this.tracks.forEach((e) => {
1542
1623
  try {
1543
1624
  e.cancelFades();
1544
- } catch (n) {
1545
- console.warn(`[songram-daw] Error canceling fades for track "${e.id}":`, n);
1625
+ } catch (s) {
1626
+ console.warn(`[songram-daw] Error canceling fades for track "${e.id}":`, s);
1546
1627
  }
1547
1628
  }), this.clearCompletionEvent();
1548
1629
  }
@@ -1550,43 +1631,43 @@ class De {
1550
1631
  this.masterVolume.volume.value = this.gainToDb(t);
1551
1632
  }
1552
1633
  setSolo(t, e) {
1553
- const n = this.tracks.get(t);
1554
- n && (n.setSolo(e), e ? this.soloedTracks.add(t) : this.soloedTracks.delete(t), this.updateSoloMuting());
1634
+ const s = this.tracks.get(t);
1635
+ s && (s.setSolo(e), e ? this.soloedTracks.add(t) : this.soloedTracks.delete(t), this.updateSoloMuting());
1555
1636
  }
1556
1637
  updateSoloMuting() {
1557
1638
  const t = this.soloedTracks.size > 0;
1558
- this.tracks.forEach((e, n) => {
1639
+ this.tracks.forEach((e, s) => {
1559
1640
  if (t)
1560
- if (!this.soloedTracks.has(n))
1641
+ if (!this.soloedTracks.has(s))
1561
1642
  e.setMute(!0);
1562
1643
  else {
1563
- const r = this.manualMuteState.get(n) ?? !1;
1644
+ const r = this.manualMuteState.get(s) ?? !1;
1564
1645
  e.setMute(r);
1565
1646
  }
1566
1647
  else {
1567
- const r = this.manualMuteState.get(n) ?? !1;
1648
+ const r = this.manualMuteState.get(s) ?? !1;
1568
1649
  e.setMute(r);
1569
1650
  }
1570
1651
  });
1571
1652
  }
1572
1653
  setMute(t, e) {
1573
- const n = this.tracks.get(t);
1574
- n && (this.manualMuteState.set(t, e), n.setMute(e));
1654
+ const s = this.tracks.get(t);
1655
+ s && (this.manualMuteState.set(t, e), s.setMute(e));
1575
1656
  }
1576
- setLoop(t, e, n) {
1577
- this._loopEnabled = t, this._loopStart = e, this._loopEnd = n;
1657
+ setLoop(t, e, s) {
1658
+ this._loopEnabled = t, this._loopStart = e, this._loopEnd = s;
1578
1659
  const r = w();
1579
1660
  try {
1580
- r.loopStart = e, r.loopEnd = n, r.loop = t;
1581
- } catch (s) {
1582
- console.warn("[songram-daw] Error configuring Transport loop:", s);
1661
+ r.loopStart = e, r.loopEnd = s, r.loop = t;
1662
+ } catch (n) {
1663
+ console.warn("[songram-daw] Error configuring Transport loop:", n);
1583
1664
  return;
1584
1665
  }
1585
1666
  t && !this._loopHandler ? (this._loopHandler = () => {
1586
- const s = rt();
1667
+ const n = rt();
1587
1668
  this.tracks.forEach((a) => {
1588
1669
  try {
1589
- a.stopAllSources(), a.cancelFades(), a.setScheduleGuardOffset(this._loopStart), a.startMidClipSources(this._loopStart, s), a.prepareFades(s, this._loopStart);
1670
+ a.stopAllSources(), a.cancelFades(), a.setScheduleGuardOffset(this._loopStart), a.startMidClipSources(this._loopStart, n), a.prepareFades(n, this._loopStart);
1590
1671
  } catch (o) {
1591
1672
  console.warn(
1592
1673
  `[songram-daw] Error re-scheduling track "${a.id}" on loop:`,
@@ -1639,8 +1720,8 @@ class De {
1639
1720
  function W(i) {
1640
1721
  return Math.pow(2, i / 1200);
1641
1722
  }
1642
- const Ge = 5;
1643
- function _(i, t) {
1723
+ const De = 5;
1724
+ function M(i, t) {
1644
1725
  return i[t]?.value;
1645
1726
  }
1646
1727
  function Re(i) {
@@ -1650,22 +1731,22 @@ function Re(i) {
1650
1731
  return t;
1651
1732
  }
1652
1733
  function Ve(i) {
1653
- const { midiNote: t, overrideRootKey: e, originalPitch: n, coarseTune: r, fineTune: s, pitchCorrection: a } = i, u = t - (e !== void 0 ? e : n !== 255 ? n : 60) + r + (s + a) / 100;
1734
+ const { midiNote: t, overrideRootKey: e, originalPitch: s, coarseTune: r, fineTune: n, pitchCorrection: a } = i, u = t - (e !== void 0 ? e : s !== 255 ? s : 60) + r + (n + a) / 100;
1654
1735
  return Math.pow(2, u / 12);
1655
1736
  }
1656
1737
  function qe(i) {
1657
- const { generators: t, header: e } = i, n = _(t, M.SampleModes) ?? 0, r = e.startLoop + (_(t, M.StartLoopAddrsOffset) ?? 0) + (_(t, M.StartLoopAddrsCoarseOffset) ?? 0) * 32768, s = e.endLoop + (_(t, M.EndLoopAddrsOffset) ?? 0) + (_(t, M.EndLoopAddrsCoarseOffset) ?? 0) * 32768, a = r / e.sampleRate, o = s / e.sampleRate, u = W(
1658
- _(t, M.AttackVolEnv) ?? -12e3
1738
+ const { generators: t, header: e } = i, s = M(t, _.SampleModes) ?? 0, r = e.startLoop + (M(t, _.StartLoopAddrsOffset) ?? 0) + (M(t, _.StartLoopAddrsCoarseOffset) ?? 0) * 32768, n = e.endLoop + (M(t, _.EndLoopAddrsOffset) ?? 0) + (M(t, _.EndLoopAddrsCoarseOffset) ?? 0) * 32768, a = r / e.sampleRate, o = n / e.sampleRate, u = W(
1739
+ M(t, _.AttackVolEnv) ?? -12e3
1659
1740
  ), l = W(
1660
- _(t, M.HoldVolEnv) ?? -12e3
1741
+ M(t, _.HoldVolEnv) ?? -12e3
1661
1742
  ), c = W(
1662
- _(t, M.DecayVolEnv) ?? -12e3
1743
+ M(t, _.DecayVolEnv) ?? -12e3
1663
1744
  ), h = Math.min(
1664
- W(_(t, M.ReleaseVolEnv) ?? -12e3),
1665
- Ge
1666
- ), d = _(t, M.SustainVolEnv) ?? 0, f = Math.pow(10, -d / 200);
1745
+ W(M(t, _.ReleaseVolEnv) ?? -12e3),
1746
+ De
1747
+ ), d = M(t, _.SustainVolEnv) ?? 0, f = Math.pow(10, -d / 200);
1667
1748
  return {
1668
- loopMode: n,
1749
+ loopMode: s,
1669
1750
  loopStart: a,
1670
1751
  loopEnd: o,
1671
1752
  attackVolEnv: u,
@@ -1675,7 +1756,7 @@ function qe(i) {
1675
1756
  releaseVolEnv: h
1676
1757
  };
1677
1758
  }
1678
- class ns {
1759
+ class en {
1679
1760
  /**
1680
1761
  * @param context Optional AudioContext for createBuffer(). If omitted, uses
1681
1762
  * an OfflineAudioContext which doesn't require user gesture — safe to
@@ -1688,15 +1769,15 @@ class ns {
1688
1769
  * Load and parse an SF2 file from a URL.
1689
1770
  */
1690
1771
  async load(t, e) {
1691
- const n = await fetch(t, { signal: e });
1692
- if (!n.ok)
1693
- throw new Error(`Failed to fetch SoundFont ${t}: ${n.statusText}`);
1694
- const r = await n.arrayBuffer();
1772
+ const s = await fetch(t, { signal: e });
1773
+ if (!s.ok)
1774
+ throw new Error(`Failed to fetch SoundFont ${t}: ${s.statusText}`);
1775
+ const r = await s.arrayBuffer();
1695
1776
  try {
1696
1777
  this.sf2 = new ft(new Uint8Array(r));
1697
- } catch (s) {
1778
+ } catch (n) {
1698
1779
  throw new Error(
1699
- `Failed to parse SoundFont ${t}: ${s instanceof Error ? s.message : String(s)}`
1780
+ `Failed to parse SoundFont ${t}: ${n instanceof Error ? n.message : String(n)}`
1700
1781
  );
1701
1782
  }
1702
1783
  }
@@ -1723,20 +1804,20 @@ class ns {
1723
1804
  * @param presetNumber - GM program number (0-127)
1724
1805
  * @returns SoundFontSample or null if no sample found for this note
1725
1806
  */
1726
- getAudioBuffer(t, e = 0, n = 0) {
1807
+ getAudioBuffer(t, e = 0, s = 0) {
1727
1808
  if (!this.sf2) return null;
1728
- const r = this.sf2.getKeyData(t, e, n);
1809
+ const r = this.sf2.getKeyData(t, e, s);
1729
1810
  if (!r) return null;
1730
- const s = r.sample, a = this.sf2.samples.indexOf(s);
1811
+ const n = r.sample, a = this.sf2.samples.indexOf(n);
1731
1812
  let o = this.audioBufferCache.get(a);
1732
- o || (o = this.int16ToAudioBuffer(s.data, s.header.sampleRate), this.audioBufferCache.set(a, o));
1813
+ o || (o = this.int16ToAudioBuffer(n.data, n.header.sampleRate), this.audioBufferCache.set(a, o));
1733
1814
  const u = Ve({
1734
1815
  midiNote: t,
1735
- overrideRootKey: _(r.generators, M.OverridingRootKey),
1736
- originalPitch: s.header.originalPitch,
1737
- coarseTune: _(r.generators, M.CoarseTune) ?? 0,
1738
- fineTune: _(r.generators, M.FineTune) ?? 0,
1739
- pitchCorrection: s.header.pitchCorrection ?? 0
1816
+ overrideRootKey: M(r.generators, _.OverridingRootKey),
1817
+ originalPitch: n.header.originalPitch,
1818
+ coarseTune: M(r.generators, _.CoarseTune) ?? 0,
1819
+ fineTune: M(r.generators, _.FineTune) ?? 0,
1820
+ pitchCorrection: n.header.pitchCorrection ?? 0
1740
1821
  }), l = qe({
1741
1822
  generators: r.generators,
1742
1823
  header: r.sample.header
@@ -1748,8 +1829,8 @@ class ns {
1748
1829
  * Uses the extracted int16ToFloat32 for the conversion, then copies into an AudioBuffer.
1749
1830
  */
1750
1831
  int16ToAudioBuffer(t, e) {
1751
- const n = Re(t), r = this.context.createBuffer(1, n.length, e);
1752
- return r.getChannelData(0).set(n), r;
1832
+ const s = Re(t), r = this.context.createBuffer(1, s.length, e);
1833
+ return r.getChannelData(0).set(s), r;
1753
1834
  }
1754
1835
  /**
1755
1836
  * Clear all cached AudioBuffers and release the parsed SF2.
@@ -1760,44 +1841,44 @@ class ns {
1760
1841
  }
1761
1842
  let x = null;
1762
1843
  function ht() {
1763
- return x || (x = new he(), de(x)), x;
1844
+ return x || (x = new he({ latencyHint: "playback" }), de(x)), x;
1764
1845
  }
1765
- function ss() {
1846
+ function sn() {
1766
1847
  return ht().rawContext;
1767
1848
  }
1768
- function rs() {
1849
+ function nn() {
1769
1850
  return ht();
1770
1851
  }
1771
- async function is() {
1852
+ async function rn() {
1772
1853
  const i = ht();
1773
1854
  i.state !== "running" && await i.resume();
1774
1855
  }
1775
- function as() {
1856
+ function an() {
1776
1857
  return x?.rawContext.state || "suspended";
1777
1858
  }
1778
- async function os() {
1859
+ async function on() {
1779
1860
  x && x.rawContext.state !== "closed" && (await x.close(), x = null);
1780
1861
  }
1781
1862
  const V = /* @__PURE__ */ new Map(), ct = /* @__PURE__ */ new Map();
1782
- function cs(i) {
1863
+ function cn(i) {
1783
1864
  if (V.has(i))
1784
1865
  return V.get(i);
1785
1866
  const e = N().createMediaStreamSource(i);
1786
1867
  V.set(i, e);
1787
- const n = () => {
1788
- e.disconnect(), V.delete(i), ct.delete(i), i.removeEventListener("ended", n), i.removeEventListener("inactive", n);
1868
+ const s = () => {
1869
+ e.disconnect(), V.delete(i), ct.delete(i), i.removeEventListener("ended", s), i.removeEventListener("inactive", s);
1789
1870
  };
1790
- return ct.set(i, n), i.addEventListener("ended", n), i.addEventListener("inactive", n), e;
1871
+ return ct.set(i, s), i.addEventListener("ended", s), i.addEventListener("inactive", s), e;
1791
1872
  }
1792
- function us(i) {
1873
+ function un(i) {
1793
1874
  const t = ct.get(i);
1794
1875
  t && t();
1795
1876
  }
1796
- function ls(i) {
1877
+ function ln(i) {
1797
1878
  return V.has(i);
1798
1879
  }
1799
1880
  function Le(i) {
1800
- let t = null, e = !1, n = 0, r = !1, s = 0, a = 0, o = !1, u = null;
1881
+ let t = null, e = !1, s = 0, r = !1, n = 0, a = 0, o = !1, u = null;
1801
1882
  function l(h, d) {
1802
1883
  const f = d.clips.filter((v) => v.audioBuffer && !v.midiNotes), y = d.clips.filter((v) => v.midiNotes && v.midiNotes.length > 0);
1803
1884
  if (f.length > 0) {
@@ -1870,9 +1951,9 @@ function Le(i) {
1870
1951
  }
1871
1952
  t = null;
1872
1953
  }
1873
- n++;
1874
- const d = n;
1875
- t = new De({
1954
+ s++;
1955
+ const d = s;
1956
+ t = new Be({
1876
1957
  effects: i?.effects
1877
1958
  }), o ? u = t.init().catch((f) => {
1878
1959
  console.warn(
@@ -1882,8 +1963,8 @@ function Le(i) {
1882
1963
  }) : u = null;
1883
1964
  for (const f of h)
1884
1965
  l(t, f);
1885
- t.applyInitialSoloState(), t.setLoop(r, s, a), t.setOnPlaybackComplete(() => {
1886
- d === n && (e = !1);
1966
+ t.applyInitialSoloState(), t.setLoop(r, n, a), t.setOnPlaybackComplete(() => {
1967
+ d === s && (e = !1);
1887
1968
  });
1888
1969
  }
1889
1970
  return {
@@ -1900,6 +1981,12 @@ function Le(i) {
1900
1981
  );
1901
1982
  l(t, h), t.applyInitialSoloState();
1902
1983
  },
1984
+ setTrackEffects(h, d) {
1985
+ const f = t?.getTrack(h);
1986
+ f ? f.setEffects(d) : console.warn(
1987
+ `[songram-daw] adapter.setTrackEffects() track "${h}" not found in playout.`
1988
+ );
1989
+ },
1903
1990
  play(h, d) {
1904
1991
  if (!t) {
1905
1992
  console.warn(
@@ -1947,7 +2034,7 @@ function Le(i) {
1947
2034
  t?.getTrack(h)?.setPan(d);
1948
2035
  },
1949
2036
  setLoop(h, d, f) {
1950
- r = h, s = d, a = f, t?.setLoop(h, d, f);
2037
+ r = h, n = d, a = f, t?.setLoop(h, d, f);
1951
2038
  },
1952
2039
  dispose() {
1953
2040
  try {
@@ -1963,22 +2050,22 @@ function ze(i) {
1963
2050
  if (Object.prototype.hasOwnProperty.call(i, "__esModule")) return i;
1964
2051
  var t = i.default;
1965
2052
  if (typeof t == "function") {
1966
- var e = function n() {
2053
+ var e = function s() {
1967
2054
  var r = !1;
1968
2055
  try {
1969
- r = this instanceof n;
2056
+ r = this instanceof s;
1970
2057
  } catch {
1971
2058
  }
1972
2059
  return r ? Reflect.construct(t, arguments, this.constructor) : t.apply(this, arguments);
1973
2060
  };
1974
2061
  e.prototype = t.prototype;
1975
2062
  } else e = {};
1976
- return Object.defineProperty(e, "__esModule", { value: !0 }), Object.keys(i).forEach(function(n) {
1977
- var r = Object.getOwnPropertyDescriptor(i, n);
1978
- Object.defineProperty(e, n, r.get ? r : {
2063
+ return Object.defineProperty(e, "__esModule", { value: !0 }), Object.keys(i).forEach(function(s) {
2064
+ var r = Object.getOwnPropertyDescriptor(i, s);
2065
+ Object.defineProperty(e, s, r.get ? r : {
1979
2066
  enumerable: !0,
1980
2067
  get: function() {
1981
- return i[n];
2068
+ return i[s];
1982
2069
  }
1983
2070
  });
1984
2071
  }), e;
@@ -1988,11 +2075,11 @@ function $e() {
1988
2075
  if (Tt) return Y;
1989
2076
  Tt = 1;
1990
2077
  function i(r) {
1991
- var s = new n(r), a = s.readChunk();
2078
+ var n = new s(r), a = n.readChunk();
1992
2079
  if (a.id != "MThd")
1993
2080
  throw "Bad MIDI file. Expected 'MHdr', got: '" + a.id + "'";
1994
- for (var o = t(a.data), u = [], l = 0; !s.eof() && l < o.numTracks; l++) {
1995
- var c = s.readChunk();
2081
+ for (var o = t(a.data), u = [], l = 0; !n.eof() && l < o.numTracks; l++) {
2082
+ var c = n.readChunk();
1996
2083
  if (c.id != "MTrk")
1997
2084
  throw "Bad MIDI file. Expected 'MTrk', got: '" + c.id + "'";
1998
2085
  var h = e(c.data);
@@ -2004,14 +2091,14 @@ function $e() {
2004
2091
  };
2005
2092
  }
2006
2093
  function t(r) {
2007
- var s = new n(r), a = s.readUInt16(), o = s.readUInt16(), u = {
2094
+ var n = new s(r), a = n.readUInt16(), o = n.readUInt16(), u = {
2008
2095
  format: a,
2009
2096
  numTracks: o
2010
- }, l = s.readUInt16();
2097
+ }, l = n.readUInt16();
2011
2098
  return l & 32768 ? (u.framesPerSecond = 256 - (l >> 8), u.ticksPerFrame = l & 255) : u.ticksPerBeat = l, u;
2012
2099
  }
2013
2100
  function e(r) {
2014
- for (var s = new n(r), a = []; !s.eof(); ) {
2101
+ for (var n = new s(r), a = []; !n.eof(); ) {
2015
2102
  var o = l();
2016
2103
  a.push(o);
2017
2104
  }
@@ -2019,65 +2106,65 @@ function $e() {
2019
2106
  var u;
2020
2107
  function l() {
2021
2108
  var c = {};
2022
- c.deltaTime = s.readVarInt();
2023
- var h = s.readUInt8();
2109
+ c.deltaTime = n.readVarInt();
2110
+ var h = n.readUInt8();
2024
2111
  if ((h & 240) === 240)
2025
2112
  if (h === 255) {
2026
2113
  c.meta = !0;
2027
- var d = s.readUInt8(), f = s.readVarInt();
2114
+ var d = n.readUInt8(), f = n.readVarInt();
2028
2115
  switch (d) {
2029
2116
  case 0:
2030
2117
  if (c.type = "sequenceNumber", f !== 2) throw "Expected length for sequenceNumber event is 2, got " + f;
2031
- return c.number = s.readUInt16(), c;
2118
+ return c.number = n.readUInt16(), c;
2032
2119
  case 1:
2033
- return c.type = "text", c.text = s.readString(f), c;
2120
+ return c.type = "text", c.text = n.readString(f), c;
2034
2121
  case 2:
2035
- return c.type = "copyrightNotice", c.text = s.readString(f), c;
2122
+ return c.type = "copyrightNotice", c.text = n.readString(f), c;
2036
2123
  case 3:
2037
- return c.type = "trackName", c.text = s.readString(f), c;
2124
+ return c.type = "trackName", c.text = n.readString(f), c;
2038
2125
  case 4:
2039
- return c.type = "instrumentName", c.text = s.readString(f), c;
2126
+ return c.type = "instrumentName", c.text = n.readString(f), c;
2040
2127
  case 5:
2041
- return c.type = "lyrics", c.text = s.readString(f), c;
2128
+ return c.type = "lyrics", c.text = n.readString(f), c;
2042
2129
  case 6:
2043
- return c.type = "marker", c.text = s.readString(f), c;
2130
+ return c.type = "marker", c.text = n.readString(f), c;
2044
2131
  case 7:
2045
- return c.type = "cuePoint", c.text = s.readString(f), c;
2132
+ return c.type = "cuePoint", c.text = n.readString(f), c;
2046
2133
  case 32:
2047
2134
  if (c.type = "channelPrefix", f != 1) throw "Expected length for channelPrefix event is 1, got " + f;
2048
- return c.channel = s.readUInt8(), c;
2135
+ return c.channel = n.readUInt8(), c;
2049
2136
  case 33:
2050
2137
  if (c.type = "portPrefix", f != 1) throw "Expected length for portPrefix event is 1, got " + f;
2051
- return c.port = s.readUInt8(), c;
2138
+ return c.port = n.readUInt8(), c;
2052
2139
  case 47:
2053
2140
  if (c.type = "endOfTrack", f != 0) throw "Expected length for endOfTrack event is 0, got " + f;
2054
2141
  return c;
2055
2142
  case 81:
2056
2143
  if (c.type = "setTempo", f != 3) throw "Expected length for setTempo event is 3, got " + f;
2057
- return c.microsecondsPerBeat = s.readUInt24(), c;
2144
+ return c.microsecondsPerBeat = n.readUInt24(), c;
2058
2145
  case 84:
2059
2146
  if (c.type = "smpteOffset", f != 5) throw "Expected length for smpteOffset event is 5, got " + f;
2060
- var y = s.readUInt8(), v = { 0: 24, 32: 25, 64: 29, 96: 30 };
2061
- return c.frameRate = v[y & 96], c.hour = y & 31, c.min = s.readUInt8(), c.sec = s.readUInt8(), c.frame = s.readUInt8(), c.subFrame = s.readUInt8(), c;
2147
+ var y = n.readUInt8(), v = { 0: 24, 32: 25, 64: 29, 96: 30 };
2148
+ return c.frameRate = v[y & 96], c.hour = y & 31, c.min = n.readUInt8(), c.sec = n.readUInt8(), c.frame = n.readUInt8(), c.subFrame = n.readUInt8(), c;
2062
2149
  case 88:
2063
2150
  if (c.type = "timeSignature", f != 2 && f != 4) throw "Expected length for timeSignature event is 4 or 2, got " + f;
2064
- return c.numerator = s.readUInt8(), c.denominator = 1 << s.readUInt8(), f === 4 ? (c.metronome = s.readUInt8(), c.thirtyseconds = s.readUInt8()) : (c.metronome = 36, c.thirtyseconds = 8), c;
2151
+ return c.numerator = n.readUInt8(), c.denominator = 1 << n.readUInt8(), f === 4 ? (c.metronome = n.readUInt8(), c.thirtyseconds = n.readUInt8()) : (c.metronome = 36, c.thirtyseconds = 8), c;
2065
2152
  case 89:
2066
2153
  if (c.type = "keySignature", f != 2) throw "Expected length for keySignature event is 2, got " + f;
2067
- return c.key = s.readInt8(), c.scale = s.readUInt8(), c;
2154
+ return c.key = n.readInt8(), c.scale = n.readUInt8(), c;
2068
2155
  case 127:
2069
- return c.type = "sequencerSpecific", c.data = s.readBytes(f), c;
2156
+ return c.type = "sequencerSpecific", c.data = n.readBytes(f), c;
2070
2157
  default:
2071
- return c.type = "unknownMeta", c.data = s.readBytes(f), c.metatypeByte = d, c;
2158
+ return c.type = "unknownMeta", c.data = n.readBytes(f), c.metatypeByte = d, c;
2072
2159
  }
2073
2160
  } else if (h == 240) {
2074
2161
  c.type = "sysEx";
2075
- var f = s.readVarInt();
2076
- return c.data = s.readBytes(f), c;
2162
+ var f = n.readVarInt();
2163
+ return c.data = n.readBytes(f), c;
2077
2164
  } else if (h == 247) {
2078
2165
  c.type = "endSysEx";
2079
- var f = s.readVarInt();
2080
- return c.data = s.readBytes(f), c;
2166
+ var f = n.readVarInt();
2167
+ return c.data = n.readBytes(f), c;
2081
2168
  } else
2082
2169
  throw "Unrecognised MIDI event type byte: " + h;
2083
2170
  else {
@@ -2087,76 +2174,76 @@ function $e() {
2087
2174
  throw "Running status byte encountered before status byte";
2088
2175
  g = h, h = u, c.running = !0;
2089
2176
  } else
2090
- g = s.readUInt8(), u = h;
2177
+ g = n.readUInt8(), u = h;
2091
2178
  var m = h >> 4;
2092
2179
  switch (c.channel = h & 15, m) {
2093
2180
  case 8:
2094
- return c.type = "noteOff", c.noteNumber = g, c.velocity = s.readUInt8(), c;
2181
+ return c.type = "noteOff", c.noteNumber = g, c.velocity = n.readUInt8(), c;
2095
2182
  case 9:
2096
- var S = s.readUInt8();
2183
+ var S = n.readUInt8();
2097
2184
  return c.type = S === 0 ? "noteOff" : "noteOn", c.noteNumber = g, c.velocity = S, S === 0 && (c.byte9 = !0), c;
2098
2185
  case 10:
2099
- return c.type = "noteAftertouch", c.noteNumber = g, c.amount = s.readUInt8(), c;
2186
+ return c.type = "noteAftertouch", c.noteNumber = g, c.amount = n.readUInt8(), c;
2100
2187
  case 11:
2101
- return c.type = "controller", c.controllerType = g, c.value = s.readUInt8(), c;
2188
+ return c.type = "controller", c.controllerType = g, c.value = n.readUInt8(), c;
2102
2189
  case 12:
2103
2190
  return c.type = "programChange", c.programNumber = g, c;
2104
2191
  case 13:
2105
2192
  return c.type = "channelAftertouch", c.amount = g, c;
2106
2193
  case 14:
2107
- return c.type = "pitchBend", c.value = g + (s.readUInt8() << 7) - 8192, c;
2194
+ return c.type = "pitchBend", c.value = g + (n.readUInt8() << 7) - 8192, c;
2108
2195
  default:
2109
2196
  throw "Unrecognised MIDI event type: " + m;
2110
2197
  }
2111
2198
  }
2112
2199
  }
2113
2200
  }
2114
- function n(r) {
2201
+ function s(r) {
2115
2202
  this.buffer = r, this.bufferLen = this.buffer.length, this.pos = 0;
2116
2203
  }
2117
- return n.prototype.eof = function() {
2204
+ return s.prototype.eof = function() {
2118
2205
  return this.pos >= this.bufferLen;
2119
- }, n.prototype.readUInt8 = function() {
2206
+ }, s.prototype.readUInt8 = function() {
2120
2207
  var r = this.buffer[this.pos];
2121
2208
  return this.pos += 1, r;
2122
- }, n.prototype.readInt8 = function() {
2209
+ }, s.prototype.readInt8 = function() {
2123
2210
  var r = this.readUInt8();
2124
2211
  return r & 128 ? r - 256 : r;
2125
- }, n.prototype.readUInt16 = function() {
2126
- var r = this.readUInt8(), s = this.readUInt8();
2127
- return (r << 8) + s;
2128
- }, n.prototype.readInt16 = function() {
2212
+ }, s.prototype.readUInt16 = function() {
2213
+ var r = this.readUInt8(), n = this.readUInt8();
2214
+ return (r << 8) + n;
2215
+ }, s.prototype.readInt16 = function() {
2129
2216
  var r = this.readUInt16();
2130
2217
  return r & 32768 ? r - 65536 : r;
2131
- }, n.prototype.readUInt24 = function() {
2132
- var r = this.readUInt8(), s = this.readUInt8(), a = this.readUInt8();
2133
- return (r << 16) + (s << 8) + a;
2134
- }, n.prototype.readInt24 = function() {
2218
+ }, s.prototype.readUInt24 = function() {
2219
+ var r = this.readUInt8(), n = this.readUInt8(), a = this.readUInt8();
2220
+ return (r << 16) + (n << 8) + a;
2221
+ }, s.prototype.readInt24 = function() {
2135
2222
  var r = this.readUInt24();
2136
2223
  return r & 8388608 ? r - 16777216 : r;
2137
- }, n.prototype.readUInt32 = function() {
2138
- var r = this.readUInt8(), s = this.readUInt8(), a = this.readUInt8(), o = this.readUInt8();
2139
- return (r << 24) + (s << 16) + (a << 8) + o;
2140
- }, n.prototype.readBytes = function(r) {
2141
- var s = this.buffer.slice(this.pos, this.pos + r);
2142
- return this.pos += r, s;
2143
- }, n.prototype.readString = function(r) {
2144
- var s = this.readBytes(r);
2145
- return String.fromCharCode.apply(null, s);
2146
- }, n.prototype.readVarInt = function() {
2224
+ }, s.prototype.readUInt32 = function() {
2225
+ var r = this.readUInt8(), n = this.readUInt8(), a = this.readUInt8(), o = this.readUInt8();
2226
+ return (r << 24) + (n << 16) + (a << 8) + o;
2227
+ }, s.prototype.readBytes = function(r) {
2228
+ var n = this.buffer.slice(this.pos, this.pos + r);
2229
+ return this.pos += r, n;
2230
+ }, s.prototype.readString = function(r) {
2231
+ var n = this.readBytes(r);
2232
+ return String.fromCharCode.apply(null, n);
2233
+ }, s.prototype.readVarInt = function() {
2147
2234
  for (var r = 0; !this.eof(); ) {
2148
- var s = this.readUInt8();
2149
- if (s & 128)
2150
- r += s & 127, r <<= 7;
2235
+ var n = this.readUInt8();
2236
+ if (n & 128)
2237
+ r += n & 127, r <<= 7;
2151
2238
  else
2152
- return r + s;
2239
+ return r + n;
2153
2240
  }
2154
2241
  return r;
2155
- }, n.prototype.readChunk = function() {
2156
- var r = this.readString(4), s = this.readUInt32(), a = this.readBytes(s);
2242
+ }, s.prototype.readChunk = function() {
2243
+ var r = this.readString(4), n = this.readUInt32(), a = this.readBytes(n);
2157
2244
  return {
2158
2245
  id: r,
2159
- length: s,
2246
+ length: n,
2160
2247
  data: a
2161
2248
  };
2162
2249
  }, Y = i, Y;
@@ -2165,117 +2252,117 @@ var tt, Ct;
2165
2252
  function je() {
2166
2253
  if (Ct) return tt;
2167
2254
  Ct = 1;
2168
- function i(s, a) {
2169
- if (typeof s != "object")
2255
+ function i(n, a) {
2256
+ if (typeof n != "object")
2170
2257
  throw "Invalid MIDI data";
2171
2258
  a = a || {};
2172
- var o = s.header || {}, u = s.tracks || [], l, c = u.length, h = new r();
2259
+ var o = n.header || {}, u = n.tracks || [], l, c = u.length, h = new r();
2173
2260
  for (t(h, o, c), l = 0; l < c; l++)
2174
2261
  e(h, u[l], a);
2175
2262
  return h.buffer;
2176
2263
  }
2177
- function t(s, a, o) {
2264
+ function t(n, a, o) {
2178
2265
  var u = a.format == null ? 1 : a.format, l = 128;
2179
2266
  a.timeDivision ? l = a.timeDivision : a.ticksPerFrame && a.framesPerSecond ? l = -(a.framesPerSecond & 255) << 8 | a.ticksPerFrame & 255 : a.ticksPerBeat && (l = a.ticksPerBeat & 32767);
2180
2267
  var c = new r();
2181
- c.writeUInt16(u), c.writeUInt16(o), c.writeUInt16(l), s.writeChunk("MThd", c.buffer);
2268
+ c.writeUInt16(u), c.writeUInt16(o), c.writeUInt16(l), n.writeChunk("MThd", c.buffer);
2182
2269
  }
2183
- function e(s, a, o) {
2270
+ function e(n, a, o) {
2184
2271
  var u = new r(), l, c = a.length, h = null;
2185
2272
  for (l = 0; l < c; l++)
2186
- (o.running === !1 || !o.running && !a[l].running) && (h = null), h = n(u, a[l], h, o.useByte9ForNoteOff);
2187
- s.writeChunk("MTrk", u.buffer);
2273
+ (o.running === !1 || !o.running && !a[l].running) && (h = null), h = s(u, a[l], h, o.useByte9ForNoteOff);
2274
+ n.writeChunk("MTrk", u.buffer);
2188
2275
  }
2189
- function n(s, a, o, u) {
2276
+ function s(n, a, o, u) {
2190
2277
  var l = a.type, c = a.deltaTime, h = a.text || "", d = a.data || [], f = null;
2191
- switch (s.writeVarInt(c), l) {
2278
+ switch (n.writeVarInt(c), l) {
2192
2279
  // meta events
2193
2280
  case "sequenceNumber":
2194
- s.writeUInt8(255), s.writeUInt8(0), s.writeVarInt(2), s.writeUInt16(a.number);
2281
+ n.writeUInt8(255), n.writeUInt8(0), n.writeVarInt(2), n.writeUInt16(a.number);
2195
2282
  break;
2196
2283
  case "text":
2197
- s.writeUInt8(255), s.writeUInt8(1), s.writeVarInt(h.length), s.writeString(h);
2284
+ n.writeUInt8(255), n.writeUInt8(1), n.writeVarInt(h.length), n.writeString(h);
2198
2285
  break;
2199
2286
  case "copyrightNotice":
2200
- s.writeUInt8(255), s.writeUInt8(2), s.writeVarInt(h.length), s.writeString(h);
2287
+ n.writeUInt8(255), n.writeUInt8(2), n.writeVarInt(h.length), n.writeString(h);
2201
2288
  break;
2202
2289
  case "trackName":
2203
- s.writeUInt8(255), s.writeUInt8(3), s.writeVarInt(h.length), s.writeString(h);
2290
+ n.writeUInt8(255), n.writeUInt8(3), n.writeVarInt(h.length), n.writeString(h);
2204
2291
  break;
2205
2292
  case "instrumentName":
2206
- s.writeUInt8(255), s.writeUInt8(4), s.writeVarInt(h.length), s.writeString(h);
2293
+ n.writeUInt8(255), n.writeUInt8(4), n.writeVarInt(h.length), n.writeString(h);
2207
2294
  break;
2208
2295
  case "lyrics":
2209
- s.writeUInt8(255), s.writeUInt8(5), s.writeVarInt(h.length), s.writeString(h);
2296
+ n.writeUInt8(255), n.writeUInt8(5), n.writeVarInt(h.length), n.writeString(h);
2210
2297
  break;
2211
2298
  case "marker":
2212
- s.writeUInt8(255), s.writeUInt8(6), s.writeVarInt(h.length), s.writeString(h);
2299
+ n.writeUInt8(255), n.writeUInt8(6), n.writeVarInt(h.length), n.writeString(h);
2213
2300
  break;
2214
2301
  case "cuePoint":
2215
- s.writeUInt8(255), s.writeUInt8(7), s.writeVarInt(h.length), s.writeString(h);
2302
+ n.writeUInt8(255), n.writeUInt8(7), n.writeVarInt(h.length), n.writeString(h);
2216
2303
  break;
2217
2304
  case "channelPrefix":
2218
- s.writeUInt8(255), s.writeUInt8(32), s.writeVarInt(1), s.writeUInt8(a.channel);
2305
+ n.writeUInt8(255), n.writeUInt8(32), n.writeVarInt(1), n.writeUInt8(a.channel);
2219
2306
  break;
2220
2307
  case "portPrefix":
2221
- s.writeUInt8(255), s.writeUInt8(33), s.writeVarInt(1), s.writeUInt8(a.port);
2308
+ n.writeUInt8(255), n.writeUInt8(33), n.writeVarInt(1), n.writeUInt8(a.port);
2222
2309
  break;
2223
2310
  case "endOfTrack":
2224
- s.writeUInt8(255), s.writeUInt8(47), s.writeVarInt(0);
2311
+ n.writeUInt8(255), n.writeUInt8(47), n.writeVarInt(0);
2225
2312
  break;
2226
2313
  case "setTempo":
2227
- s.writeUInt8(255), s.writeUInt8(81), s.writeVarInt(3), s.writeUInt24(a.microsecondsPerBeat);
2314
+ n.writeUInt8(255), n.writeUInt8(81), n.writeVarInt(3), n.writeUInt24(a.microsecondsPerBeat);
2228
2315
  break;
2229
2316
  case "smpteOffset":
2230
- s.writeUInt8(255), s.writeUInt8(84), s.writeVarInt(5);
2317
+ n.writeUInt8(255), n.writeUInt8(84), n.writeVarInt(5);
2231
2318
  var y = { 24: 0, 25: 32, 29: 64, 30: 96 }, v = a.hour & 31 | y[a.frameRate];
2232
- s.writeUInt8(v), s.writeUInt8(a.min), s.writeUInt8(a.sec), s.writeUInt8(a.frame), s.writeUInt8(a.subFrame);
2319
+ n.writeUInt8(v), n.writeUInt8(a.min), n.writeUInt8(a.sec), n.writeUInt8(a.frame), n.writeUInt8(a.subFrame);
2233
2320
  break;
2234
2321
  case "timeSignature":
2235
- s.writeUInt8(255), s.writeUInt8(88), s.writeVarInt(4), s.writeUInt8(a.numerator);
2322
+ n.writeUInt8(255), n.writeUInt8(88), n.writeVarInt(4), n.writeUInt8(a.numerator);
2236
2323
  var g = Math.floor(Math.log(a.denominator) / Math.LN2) & 255;
2237
- s.writeUInt8(g), s.writeUInt8(a.metronome), s.writeUInt8(a.thirtyseconds || 8);
2324
+ n.writeUInt8(g), n.writeUInt8(a.metronome), n.writeUInt8(a.thirtyseconds || 8);
2238
2325
  break;
2239
2326
  case "keySignature":
2240
- s.writeUInt8(255), s.writeUInt8(89), s.writeVarInt(2), s.writeInt8(a.key), s.writeUInt8(a.scale);
2327
+ n.writeUInt8(255), n.writeUInt8(89), n.writeVarInt(2), n.writeInt8(a.key), n.writeUInt8(a.scale);
2241
2328
  break;
2242
2329
  case "sequencerSpecific":
2243
- s.writeUInt8(255), s.writeUInt8(127), s.writeVarInt(d.length), s.writeBytes(d);
2330
+ n.writeUInt8(255), n.writeUInt8(127), n.writeVarInt(d.length), n.writeBytes(d);
2244
2331
  break;
2245
2332
  case "unknownMeta":
2246
- a.metatypeByte != null && (s.writeUInt8(255), s.writeUInt8(a.metatypeByte), s.writeVarInt(d.length), s.writeBytes(d));
2333
+ a.metatypeByte != null && (n.writeUInt8(255), n.writeUInt8(a.metatypeByte), n.writeVarInt(d.length), n.writeBytes(d));
2247
2334
  break;
2248
2335
  // system-exclusive
2249
2336
  case "sysEx":
2250
- s.writeUInt8(240), s.writeVarInt(d.length), s.writeBytes(d);
2337
+ n.writeUInt8(240), n.writeVarInt(d.length), n.writeBytes(d);
2251
2338
  break;
2252
2339
  case "endSysEx":
2253
- s.writeUInt8(247), s.writeVarInt(d.length), s.writeBytes(d);
2340
+ n.writeUInt8(247), n.writeVarInt(d.length), n.writeBytes(d);
2254
2341
  break;
2255
2342
  // channel events
2256
2343
  case "noteOff":
2257
2344
  var m = u !== !1 && a.byte9 || u && a.velocity == 0 ? 144 : 128;
2258
- f = m | a.channel, f !== o && s.writeUInt8(f), s.writeUInt8(a.noteNumber), s.writeUInt8(a.velocity);
2345
+ f = m | a.channel, f !== o && n.writeUInt8(f), n.writeUInt8(a.noteNumber), n.writeUInt8(a.velocity);
2259
2346
  break;
2260
2347
  case "noteOn":
2261
- f = 144 | a.channel, f !== o && s.writeUInt8(f), s.writeUInt8(a.noteNumber), s.writeUInt8(a.velocity);
2348
+ f = 144 | a.channel, f !== o && n.writeUInt8(f), n.writeUInt8(a.noteNumber), n.writeUInt8(a.velocity);
2262
2349
  break;
2263
2350
  case "noteAftertouch":
2264
- f = 160 | a.channel, f !== o && s.writeUInt8(f), s.writeUInt8(a.noteNumber), s.writeUInt8(a.amount);
2351
+ f = 160 | a.channel, f !== o && n.writeUInt8(f), n.writeUInt8(a.noteNumber), n.writeUInt8(a.amount);
2265
2352
  break;
2266
2353
  case "controller":
2267
- f = 176 | a.channel, f !== o && s.writeUInt8(f), s.writeUInt8(a.controllerType), s.writeUInt8(a.value);
2354
+ f = 176 | a.channel, f !== o && n.writeUInt8(f), n.writeUInt8(a.controllerType), n.writeUInt8(a.value);
2268
2355
  break;
2269
2356
  case "programChange":
2270
- f = 192 | a.channel, f !== o && s.writeUInt8(f), s.writeUInt8(a.programNumber);
2357
+ f = 192 | a.channel, f !== o && n.writeUInt8(f), n.writeUInt8(a.programNumber);
2271
2358
  break;
2272
2359
  case "channelAftertouch":
2273
- f = 208 | a.channel, f !== o && s.writeUInt8(f), s.writeUInt8(a.amount);
2360
+ f = 208 | a.channel, f !== o && n.writeUInt8(f), n.writeUInt8(a.amount);
2274
2361
  break;
2275
2362
  case "pitchBend":
2276
- f = 224 | a.channel, f !== o && s.writeUInt8(f);
2363
+ f = 224 | a.channel, f !== o && n.writeUInt8(f);
2277
2364
  var S = 8192 + a.value, b = S & 127, p = S >> 7 & 127;
2278
- s.writeUInt8(b), s.writeUInt8(p);
2365
+ n.writeUInt8(b), n.writeUInt8(p);
2279
2366
  break;
2280
2367
  default:
2281
2368
  throw "Unrecognized event type: " + l;
@@ -2285,76 +2372,76 @@ function je() {
2285
2372
  function r() {
2286
2373
  this.buffer = [];
2287
2374
  }
2288
- return r.prototype.writeUInt8 = function(s) {
2289
- this.buffer.push(s & 255);
2290
- }, r.prototype.writeInt8 = r.prototype.writeUInt8, r.prototype.writeUInt16 = function(s) {
2291
- var a = s >> 8 & 255, o = s & 255;
2375
+ return r.prototype.writeUInt8 = function(n) {
2376
+ this.buffer.push(n & 255);
2377
+ }, r.prototype.writeInt8 = r.prototype.writeUInt8, r.prototype.writeUInt16 = function(n) {
2378
+ var a = n >> 8 & 255, o = n & 255;
2292
2379
  this.writeUInt8(a), this.writeUInt8(o);
2293
- }, r.prototype.writeInt16 = r.prototype.writeUInt16, r.prototype.writeUInt24 = function(s) {
2294
- var a = s >> 16 & 255, o = s >> 8 & 255, u = s & 255;
2380
+ }, r.prototype.writeInt16 = r.prototype.writeUInt16, r.prototype.writeUInt24 = function(n) {
2381
+ var a = n >> 16 & 255, o = n >> 8 & 255, u = n & 255;
2295
2382
  this.writeUInt8(a), this.writeUInt8(o), this.writeUInt8(u);
2296
- }, r.prototype.writeInt24 = r.prototype.writeUInt24, r.prototype.writeUInt32 = function(s) {
2297
- var a = s >> 24 & 255, o = s >> 16 & 255, u = s >> 8 & 255, l = s & 255;
2383
+ }, r.prototype.writeInt24 = r.prototype.writeUInt24, r.prototype.writeUInt32 = function(n) {
2384
+ var a = n >> 24 & 255, o = n >> 16 & 255, u = n >> 8 & 255, l = n & 255;
2298
2385
  this.writeUInt8(a), this.writeUInt8(o), this.writeUInt8(u), this.writeUInt8(l);
2299
- }, r.prototype.writeInt32 = r.prototype.writeUInt32, r.prototype.writeBytes = function(s) {
2300
- this.buffer = this.buffer.concat(Array.prototype.slice.call(s, 0));
2301
- }, r.prototype.writeString = function(s) {
2302
- var a, o = s.length, u = [];
2386
+ }, r.prototype.writeInt32 = r.prototype.writeUInt32, r.prototype.writeBytes = function(n) {
2387
+ this.buffer = this.buffer.concat(Array.prototype.slice.call(n, 0));
2388
+ }, r.prototype.writeString = function(n) {
2389
+ var a, o = n.length, u = [];
2303
2390
  for (a = 0; a < o; a++)
2304
- u.push(s.codePointAt(a));
2391
+ u.push(n.codePointAt(a));
2305
2392
  this.writeBytes(u);
2306
- }, r.prototype.writeVarInt = function(s) {
2307
- if (s < 0) throw "Cannot write negative variable-length integer";
2308
- if (s <= 127)
2309
- this.writeUInt8(s);
2393
+ }, r.prototype.writeVarInt = function(n) {
2394
+ if (n < 0) throw "Cannot write negative variable-length integer";
2395
+ if (n <= 127)
2396
+ this.writeUInt8(n);
2310
2397
  else {
2311
- var a = s, o = [];
2398
+ var a = n, o = [];
2312
2399
  for (o.push(a & 127), a >>= 7; a; ) {
2313
2400
  var u = a & 127 | 128;
2314
2401
  o.push(u), a >>= 7;
2315
2402
  }
2316
2403
  this.writeBytes(o.reverse());
2317
2404
  }
2318
- }, r.prototype.writeChunk = function(s, a) {
2319
- this.writeString(s), this.writeUInt32(a.length), this.writeBytes(a);
2405
+ }, r.prototype.writeChunk = function(n, a) {
2406
+ this.writeString(n), this.writeUInt32(a.length), this.writeBytes(a);
2320
2407
  }, tt = i, tt;
2321
2408
  }
2322
- var Mt;
2409
+ var _t;
2323
2410
  function re() {
2324
- return Mt || (Mt = 1, J.parseMidi = $e(), J.writeMidi = je()), J;
2411
+ return _t || (_t = 1, J.parseMidi = $e(), J.writeMidi = je()), J;
2325
2412
  }
2326
- var et = {}, F = {}, _t;
2413
+ var et = {}, F = {}, Mt;
2327
2414
  function ie() {
2328
- if (_t) return F;
2329
- _t = 1, Object.defineProperty(F, "__esModule", { value: !0 }), F.insert = F.search = void 0;
2330
- function i(e, n, r) {
2415
+ if (Mt) return F;
2416
+ Mt = 1, Object.defineProperty(F, "__esModule", { value: !0 }), F.insert = F.search = void 0;
2417
+ function i(e, s, r) {
2331
2418
  r === void 0 && (r = "ticks");
2332
- var s = 0, a = e.length, o = a;
2333
- if (a > 0 && e[a - 1][r] <= n)
2419
+ var n = 0, a = e.length, o = a;
2420
+ if (a > 0 && e[a - 1][r] <= s)
2334
2421
  return a - 1;
2335
- for (; s < o; ) {
2336
- var u = Math.floor(s + (o - s) / 2), l = e[u], c = e[u + 1];
2337
- if (l[r] === n) {
2422
+ for (; n < o; ) {
2423
+ var u = Math.floor(n + (o - n) / 2), l = e[u], c = e[u + 1];
2424
+ if (l[r] === s) {
2338
2425
  for (var h = u; h < e.length; h++) {
2339
2426
  var d = e[h];
2340
- d[r] === n && (u = h);
2427
+ d[r] === s && (u = h);
2341
2428
  }
2342
2429
  return u;
2343
2430
  } else {
2344
- if (l[r] < n && c[r] > n)
2431
+ if (l[r] < s && c[r] > s)
2345
2432
  return u;
2346
- l[r] > n ? o = u : l[r] < n && (s = u + 1);
2433
+ l[r] > s ? o = u : l[r] < s && (n = u + 1);
2347
2434
  }
2348
2435
  }
2349
2436
  return -1;
2350
2437
  }
2351
2438
  F.search = i;
2352
- function t(e, n, r) {
2439
+ function t(e, s, r) {
2353
2440
  if (r === void 0 && (r = "ticks"), e.length) {
2354
- var s = i(e, n[r], r);
2355
- e.splice(s + 1, 0, n);
2441
+ var n = i(e, s[r], r);
2442
+ e.splice(n + 1, 0, s);
2356
2443
  } else
2357
- e.push(n);
2444
+ e.push(s);
2358
2445
  }
2359
2446
  return F.insert = t, F;
2360
2447
  }
@@ -2380,13 +2467,13 @@ function ut() {
2380
2467
  "F#",
2381
2468
  "C#"
2382
2469
  ];
2383
- var n = (
2470
+ var s = (
2384
2471
  /** @class */
2385
2472
  (function() {
2386
- function r(s) {
2473
+ function r(n) {
2387
2474
  var a = this;
2388
- if (this.tempos = [], this.timeSignatures = [], this.keySignatures = [], this.meta = [], this.name = "", e.set(this, 480), s) {
2389
- e.set(this, s.header.ticksPerBeat), s.tracks.forEach(function(u) {
2475
+ if (this.tempos = [], this.timeSignatures = [], this.keySignatures = [], this.meta = [], this.name = "", e.set(this, 480), n) {
2476
+ e.set(this, n.header.ticksPerBeat), n.tracks.forEach(function(u) {
2390
2477
  u.forEach(function(l) {
2391
2478
  l.meta && (l.type === "timeSignature" ? a.timeSignatures.push({
2392
2479
  ticks: l.absoluteTime,
@@ -2405,7 +2492,7 @@ function ut() {
2405
2492
  });
2406
2493
  });
2407
2494
  var o = 0;
2408
- s.tracks[0].forEach(function(u) {
2495
+ n.tracks[0].forEach(function(u) {
2409
2496
  o += u.deltaTime, u.meta && (u.type === "trackName" ? a.name = u.text : (u.type === "text" || u.type === "cuePoint" || u.type === "marker" || u.type === "lyrics") && a.meta.push({
2410
2497
  text: u.text,
2411
2498
  ticks: o,
@@ -2415,34 +2502,34 @@ function ut() {
2415
2502
  }
2416
2503
  }
2417
2504
  return r.prototype.update = function() {
2418
- var s = this, a = 0, o = 0;
2505
+ var n = this, a = 0, o = 0;
2419
2506
  this.tempos.sort(function(u, l) {
2420
2507
  return u.ticks - l.ticks;
2421
2508
  }), this.tempos.forEach(function(u, l) {
2422
- var c = l > 0 ? s.tempos[l - 1].bpm : s.tempos[0].bpm, h = u.ticks / s.ppq - o, d = 60 / c * h;
2509
+ var c = l > 0 ? n.tempos[l - 1].bpm : n.tempos[0].bpm, h = u.ticks / n.ppq - o, d = 60 / c * h;
2423
2510
  u.time = d + a, a = u.time, o += h;
2424
2511
  }), this.timeSignatures.sort(function(u, l) {
2425
2512
  return u.ticks - l.ticks;
2426
2513
  }), this.timeSignatures.forEach(function(u, l) {
2427
- var c = l > 0 ? s.timeSignatures[l - 1] : s.timeSignatures[0], h = (u.ticks - c.ticks) / s.ppq, d = h / c.timeSignature[0] / (c.timeSignature[1] / 4);
2514
+ var c = l > 0 ? n.timeSignatures[l - 1] : n.timeSignatures[0], h = (u.ticks - c.ticks) / n.ppq, d = h / c.timeSignature[0] / (c.timeSignature[1] / 4);
2428
2515
  c.measures = c.measures || 0, u.measures = d + c.measures;
2429
2516
  });
2430
- }, r.prototype.ticksToSeconds = function(s) {
2431
- var a = (0, t.search)(this.tempos, s);
2517
+ }, r.prototype.ticksToSeconds = function(n) {
2518
+ var a = (0, t.search)(this.tempos, n);
2432
2519
  if (a !== -1) {
2433
- var o = this.tempos[a], u = o.time, l = (s - o.ticks) / this.ppq;
2520
+ var o = this.tempos[a], u = o.time, l = (n - o.ticks) / this.ppq;
2434
2521
  return u + 60 / o.bpm * l;
2435
2522
  } else {
2436
- var c = s / this.ppq;
2523
+ var c = n / this.ppq;
2437
2524
  return 60 / 120 * c;
2438
2525
  }
2439
- }, r.prototype.ticksToMeasures = function(s) {
2440
- var a = (0, t.search)(this.timeSignatures, s);
2526
+ }, r.prototype.ticksToMeasures = function(n) {
2527
+ var a = (0, t.search)(this.timeSignatures, n);
2441
2528
  if (a !== -1) {
2442
- var o = this.timeSignatures[a], u = (s - o.ticks) / this.ppq;
2529
+ var o = this.timeSignatures[a], u = (n - o.ticks) / this.ppq;
2443
2530
  return o.measures + u / (o.timeSignature[0] / o.timeSignature[1]) / 4;
2444
2531
  } else
2445
- return s / this.ppq / 4;
2532
+ return n / this.ppq / 4;
2446
2533
  }, Object.defineProperty(r.prototype, "ppq", {
2447
2534
  /**
2448
2535
  * The number of ticks per quarter note.
@@ -2452,13 +2539,13 @@ function ut() {
2452
2539
  },
2453
2540
  enumerable: !1,
2454
2541
  configurable: !0
2455
- }), r.prototype.secondsToTicks = function(s) {
2456
- var a = (0, t.search)(this.tempos, s, "time");
2542
+ }), r.prototype.secondsToTicks = function(n) {
2543
+ var a = (0, t.search)(this.tempos, n, "time");
2457
2544
  if (a !== -1) {
2458
- var o = this.tempos[a], u = o.time, l = s - u, c = l / (60 / o.bpm);
2545
+ var o = this.tempos[a], u = o.time, l = n - u, c = l / (60 / o.bpm);
2459
2546
  return Math.round(o.ticks + c * this.ppq);
2460
2547
  } else {
2461
- var h = s / 0.5;
2548
+ var h = n / 0.5;
2462
2549
  return Math.round(h * this.ppq);
2463
2550
  }
2464
2551
  }, r.prototype.toJSON = function() {
@@ -2467,38 +2554,38 @@ function ut() {
2467
2554
  meta: this.meta,
2468
2555
  name: this.name,
2469
2556
  ppq: this.ppq,
2470
- tempos: this.tempos.map(function(s) {
2557
+ tempos: this.tempos.map(function(n) {
2471
2558
  return {
2472
- bpm: s.bpm,
2473
- ticks: s.ticks
2559
+ bpm: n.bpm,
2560
+ ticks: n.ticks
2474
2561
  };
2475
2562
  }),
2476
2563
  timeSignatures: this.timeSignatures
2477
2564
  };
2478
- }, r.prototype.fromJSON = function(s) {
2479
- this.name = s.name, this.tempos = s.tempos.map(function(a) {
2565
+ }, r.prototype.fromJSON = function(n) {
2566
+ this.name = n.name, this.tempos = n.tempos.map(function(a) {
2480
2567
  return Object.assign({}, a);
2481
- }), this.timeSignatures = s.timeSignatures.map(function(a) {
2568
+ }), this.timeSignatures = n.timeSignatures.map(function(a) {
2482
2569
  return Object.assign({}, a);
2483
- }), this.keySignatures = s.keySignatures.map(function(a) {
2570
+ }), this.keySignatures = n.keySignatures.map(function(a) {
2484
2571
  return Object.assign({}, a);
2485
- }), this.meta = s.meta.map(function(a) {
2572
+ }), this.meta = n.meta.map(function(a) {
2486
2573
  return Object.assign({}, a);
2487
- }), e.set(this, s.ppq), this.update();
2488
- }, r.prototype.setTempo = function(s) {
2574
+ }), e.set(this, n.ppq), this.update();
2575
+ }, r.prototype.setTempo = function(n) {
2489
2576
  this.tempos = [
2490
2577
  {
2491
- bpm: s,
2578
+ bpm: n,
2492
2579
  ticks: 0
2493
2580
  }
2494
2581
  ], this.update();
2495
2582
  }, r;
2496
2583
  })()
2497
2584
  );
2498
- i.Header = n;
2585
+ i.Header = s;
2499
2586
  })(et)), et;
2500
2587
  }
2501
- var U = {}, nt = {}, xt;
2588
+ var G = {}, st = {}, xt;
2502
2589
  function ae() {
2503
2590
  return xt || (xt = 1, (function(i) {
2504
2591
  Object.defineProperty(i, "__esModule", { value: !0 }), i.ControlChange = i.controlChangeIds = i.controlChangeNames = void 0, i.controlChangeNames = {
@@ -2515,14 +2602,14 @@ function ae() {
2515
2602
  67: "softPedal",
2516
2603
  68: "legatoFootswitch",
2517
2604
  84: "portamentoControl"
2518
- }, i.controlChangeIds = Object.keys(i.controlChangeNames).reduce(function(r, s) {
2519
- return r[i.controlChangeNames[s]] = s, r;
2605
+ }, i.controlChangeIds = Object.keys(i.controlChangeNames).reduce(function(r, n) {
2606
+ return r[i.controlChangeNames[n]] = n, r;
2520
2607
  }, {});
2521
- var t = /* @__PURE__ */ new WeakMap(), e = /* @__PURE__ */ new WeakMap(), n = (
2608
+ var t = /* @__PURE__ */ new WeakMap(), e = /* @__PURE__ */ new WeakMap(), s = (
2522
2609
  /** @class */
2523
2610
  (function() {
2524
- function r(s, a) {
2525
- t.set(this, a), e.set(this, s.controllerType), this.ticks = s.absoluteTime, this.value = s.value;
2611
+ function r(n, a) {
2612
+ t.set(this, a), e.set(this, n.controllerType), this.ticks = n.absoluteTime, this.value = n.value;
2526
2613
  }
2527
2614
  return Object.defineProperty(r.prototype, "number", {
2528
2615
  /**
@@ -2547,12 +2634,12 @@ function ae() {
2547
2634
  * The time of the event in seconds
2548
2635
  */
2549
2636
  get: function() {
2550
- var s = t.get(this);
2551
- return s.ticksToSeconds(this.ticks);
2637
+ var n = t.get(this);
2638
+ return n.ticksToSeconds(this.ticks);
2552
2639
  },
2553
- set: function(s) {
2640
+ set: function(n) {
2554
2641
  var a = t.get(this);
2555
- this.ticks = a.secondsToTicks(s);
2642
+ this.ticks = a.secondsToTicks(n);
2556
2643
  },
2557
2644
  enumerable: !1,
2558
2645
  configurable: !0
@@ -2566,52 +2653,52 @@ function ae() {
2566
2653
  }, r;
2567
2654
  })()
2568
2655
  );
2569
- i.ControlChange = n;
2570
- })(nt)), nt;
2656
+ i.ControlChange = s;
2657
+ })(st)), st;
2571
2658
  }
2572
- var B = {}, Et;
2659
+ var U = {}, Et;
2573
2660
  function He() {
2574
- if (Et) return B;
2575
- Et = 1, Object.defineProperty(B, "__esModule", { value: !0 }), B.createControlChanges = void 0;
2661
+ if (Et) return U;
2662
+ Et = 1, Object.defineProperty(U, "__esModule", { value: !0 }), U.createControlChanges = void 0;
2576
2663
  var i = ae();
2577
2664
  function t() {
2578
2665
  return new Proxy({}, {
2579
2666
  // tslint:disable-next-line: typedef
2580
- get: function(e, n) {
2581
- if (e[n])
2582
- return e[n];
2583
- if (i.controlChangeIds.hasOwnProperty(n))
2584
- return e[i.controlChangeIds[n]];
2667
+ get: function(e, s) {
2668
+ if (e[s])
2669
+ return e[s];
2670
+ if (i.controlChangeIds.hasOwnProperty(s))
2671
+ return e[i.controlChangeIds[s]];
2585
2672
  },
2586
2673
  // tslint:disable-next-line: typedef
2587
- set: function(e, n, r) {
2588
- return i.controlChangeIds.hasOwnProperty(n) ? e[i.controlChangeIds[n]] = r : e[n] = r, !0;
2674
+ set: function(e, s, r) {
2675
+ return i.controlChangeIds.hasOwnProperty(s) ? e[i.controlChangeIds[s]] = r : e[s] = r, !0;
2589
2676
  }
2590
2677
  });
2591
2678
  }
2592
- return B.createControlChanges = t, B;
2679
+ return U.createControlChanges = t, U;
2593
2680
  }
2594
- var D = {}, Pt;
2681
+ var B = {}, Pt;
2595
2682
  function We() {
2596
- if (Pt) return D;
2597
- Pt = 1, Object.defineProperty(D, "__esModule", { value: !0 }), D.PitchBend = void 0;
2683
+ if (Pt) return B;
2684
+ Pt = 1, Object.defineProperty(B, "__esModule", { value: !0 }), B.PitchBend = void 0;
2598
2685
  var i = /* @__PURE__ */ new WeakMap(), t = (
2599
2686
  /** @class */
2600
2687
  (function() {
2601
- function e(n, r) {
2602
- i.set(this, r), this.ticks = n.absoluteTime, this.value = n.value;
2688
+ function e(s, r) {
2689
+ i.set(this, r), this.ticks = s.absoluteTime, this.value = s.value;
2603
2690
  }
2604
2691
  return Object.defineProperty(e.prototype, "time", {
2605
2692
  /**
2606
2693
  * The time of the event in seconds
2607
2694
  */
2608
2695
  get: function() {
2609
- var n = i.get(this);
2610
- return n.ticksToSeconds(this.ticks);
2696
+ var s = i.get(this);
2697
+ return s.ticksToSeconds(this.ticks);
2611
2698
  },
2612
- set: function(n) {
2699
+ set: function(s) {
2613
2700
  var r = i.get(this);
2614
- this.ticks = r.secondsToTicks(n);
2701
+ this.ticks = r.secondsToTicks(s);
2615
2702
  },
2616
2703
  enumerable: !1,
2617
2704
  configurable: !0
@@ -2624,9 +2711,9 @@ function We() {
2624
2711
  }, e;
2625
2712
  })()
2626
2713
  );
2627
- return D.PitchBend = t, D;
2714
+ return B.PitchBend = t, B;
2628
2715
  }
2629
- var G = {}, I = {}, Ft;
2716
+ var D = {}, I = {}, Ft;
2630
2717
  function Je() {
2631
2718
  return Ft || (Ft = 1, Object.defineProperty(I, "__esModule", { value: !0 }), I.DrumKitByPatchID = I.InstrumentFamilyByID = I.instrumentByPatchID = void 0, I.instrumentByPatchID = [
2632
2719
  "acoustic grand piano",
@@ -2788,20 +2875,20 @@ function Je() {
2788
2875
  }
2789
2876
  var At;
2790
2877
  function Ke() {
2791
- if (At) return G;
2792
- At = 1, Object.defineProperty(G, "__esModule", { value: !0 }), G.Instrument = void 0;
2878
+ if (At) return D;
2879
+ At = 1, Object.defineProperty(D, "__esModule", { value: !0 }), D.Instrument = void 0;
2793
2880
  var i = Je(), t = /* @__PURE__ */ new WeakMap(), e = (
2794
2881
  /** @class */
2795
2882
  (function() {
2796
- function n(r, s) {
2797
- if (this.number = 0, t.set(this, s), this.number = 0, r) {
2883
+ function s(r, n) {
2884
+ if (this.number = 0, t.set(this, n), this.number = 0, r) {
2798
2885
  var a = r.find(function(o) {
2799
2886
  return o.type === "programChange";
2800
2887
  });
2801
2888
  a && (this.number = a.programNumber);
2802
2889
  }
2803
2890
  }
2804
- return Object.defineProperty(n.prototype, "name", {
2891
+ return Object.defineProperty(s.prototype, "name", {
2805
2892
  /**
2806
2893
  * The common name of the instrument.
2807
2894
  */
@@ -2809,12 +2896,12 @@ function Ke() {
2809
2896
  return this.percussion ? i.DrumKitByPatchID[this.number] : i.instrumentByPatchID[this.number];
2810
2897
  },
2811
2898
  set: function(r) {
2812
- var s = i.instrumentByPatchID.indexOf(r);
2813
- s !== -1 && (this.number = s);
2899
+ var n = i.instrumentByPatchID.indexOf(r);
2900
+ n !== -1 && (this.number = n);
2814
2901
  },
2815
2902
  enumerable: !1,
2816
2903
  configurable: !0
2817
- }), Object.defineProperty(n.prototype, "family", {
2904
+ }), Object.defineProperty(s.prototype, "family", {
2818
2905
  /**
2819
2906
  * The instrument family, e.g. "piano".
2820
2907
  */
@@ -2823,7 +2910,7 @@ function Ke() {
2823
2910
  },
2824
2911
  enumerable: !1,
2825
2912
  configurable: !0
2826
- }), Object.defineProperty(n.prototype, "percussion", {
2913
+ }), Object.defineProperty(s.prototype, "percussion", {
2827
2914
  /**
2828
2915
  * If the instrument is a percussion instrument.
2829
2916
  */
@@ -2833,18 +2920,18 @@ function Ke() {
2833
2920
  },
2834
2921
  enumerable: !1,
2835
2922
  configurable: !0
2836
- }), n.prototype.toJSON = function() {
2923
+ }), s.prototype.toJSON = function() {
2837
2924
  return {
2838
2925
  family: this.family,
2839
2926
  number: this.number,
2840
2927
  name: this.name
2841
2928
  };
2842
- }, n.prototype.fromJSON = function(r) {
2929
+ }, s.prototype.fromJSON = function(r) {
2843
2930
  this.number = r.number;
2844
- }, n;
2931
+ }, s;
2845
2932
  })()
2846
2933
  );
2847
- return G.Instrument = e, G;
2934
+ return D.Instrument = e, D;
2848
2935
  }
2849
2936
  var R = {}, Nt;
2850
2937
  function Xe() {
@@ -2862,7 +2949,7 @@ function Xe() {
2862
2949
  var o = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
2863
2950
  return o.indexOf(a);
2864
2951
  }
2865
- var n = /* @__PURE__ */ (function() {
2952
+ var s = /* @__PURE__ */ (function() {
2866
2953
  var a = /^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i, o = {
2867
2954
  // tslint:disable-next-line: object-literal-sort-keys
2868
2955
  cbb: -2,
@@ -2905,7 +2992,7 @@ function Xe() {
2905
2992
  var l = a.exec(u), c = l[1], h = l[2], d = o[c.toLowerCase()];
2906
2993
  return d + (parseInt(h, 10) + 1) * 12;
2907
2994
  };
2908
- })(), r = /* @__PURE__ */ new WeakMap(), s = (
2995
+ })(), r = /* @__PURE__ */ new WeakMap(), n = (
2909
2996
  /** @class */
2910
2997
  (function() {
2911
2998
  function a(o, u, l) {
@@ -2919,7 +3006,7 @@ function Xe() {
2919
3006
  return i(this.midi);
2920
3007
  },
2921
3008
  set: function(o) {
2922
- this.midi = n(o);
3009
+ this.midi = s(o);
2923
3010
  },
2924
3011
  enumerable: !1,
2925
3012
  configurable: !0
@@ -3001,13 +3088,13 @@ function Xe() {
3001
3088
  }, a;
3002
3089
  })()
3003
3090
  );
3004
- return R.Note = s, R;
3091
+ return R.Note = n, R;
3005
3092
  }
3006
3093
  var Ot;
3007
- function Ut() {
3008
- if (Ot) return U;
3009
- Ot = 1, Object.defineProperty(U, "__esModule", { value: !0 }), U.Track = void 0;
3010
- var i = ie(), t = ae(), e = He(), n = We(), r = Ke(), s = Xe(), a = /* @__PURE__ */ new WeakMap(), o = (
3094
+ function Gt() {
3095
+ if (Ot) return G;
3096
+ Ot = 1, Object.defineProperty(G, "__esModule", { value: !0 }), G.Track = void 0;
3097
+ var i = ie(), t = ae(), e = He(), s = We(), r = Ke(), n = Xe(), a = /* @__PURE__ */ new WeakMap(), o = (
3011
3098
  /** @class */
3012
3099
  (function() {
3013
3100
  function u(l, c) {
@@ -3068,7 +3155,7 @@ function Ut() {
3068
3155
  }
3069
3156
  }
3070
3157
  return u.prototype.addNote = function(l) {
3071
- var c = a.get(this), h = new s.Note({
3158
+ var c = a.get(this), h = new n.Note({
3072
3159
  midi: 0,
3073
3160
  ticks: 0,
3074
3161
  velocity: 1
@@ -3083,7 +3170,7 @@ function Ut() {
3083
3170
  }, c);
3084
3171
  return delete l.number, Object.assign(h, l), Array.isArray(this.controlChanges[h.number]) || (this.controlChanges[h.number] = []), (0, i.insert)(this.controlChanges[h.number], h, "ticks"), this;
3085
3172
  }, u.prototype.addPitchBend = function(l) {
3086
- var c = a.get(this), h = new n.PitchBend({}, c);
3173
+ var c = a.get(this), h = new s.PitchBend({}, c);
3087
3174
  return Object.assign(h, l), (0, i.insert)(this.pitchBends, h, "ticks"), this;
3088
3175
  }, Object.defineProperty(u.prototype, "duration", {
3089
3176
  /**
@@ -3155,7 +3242,7 @@ function Ut() {
3155
3242
  }, u;
3156
3243
  })()
3157
3244
  );
3158
- return U.Track = o, U;
3245
+ return G.Track = o, G;
3159
3246
  }
3160
3247
  var A = {};
3161
3248
  function Ze(i) {
@@ -3164,25 +3251,25 @@ function Ze(i) {
3164
3251
  }
3165
3252
  function oe(i, t) {
3166
3253
  for (var e = 0; e < i.length; e++) {
3167
- var n = i[e];
3168
- Array.isArray(n) ? oe(n, t) : t.push(n);
3254
+ var s = i[e];
3255
+ Array.isArray(s) ? oe(s, t) : t.push(s);
3169
3256
  }
3170
3257
  }
3171
3258
  const Qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3172
3259
  __proto__: null,
3173
3260
  flatten: Ze
3174
3261
  }, Symbol.toStringTag, { value: "Module" })), Ye = /* @__PURE__ */ ze(Qe);
3175
- var Bt;
3176
- function tn() {
3177
- if (Bt) return A;
3178
- Bt = 1;
3262
+ var Ut;
3263
+ function ts() {
3264
+ if (Ut) return A;
3265
+ Ut = 1;
3179
3266
  var i = A && A.__spreadArray || function(m, S, b) {
3180
3267
  if (b || arguments.length === 2) for (var p = 0, k = S.length, T; p < k; p++)
3181
3268
  (T || !(p in S)) && (T || (T = Array.prototype.slice.call(S, 0, p)), T[p] = S[p]);
3182
3269
  return m.concat(T || Array.prototype.slice.call(S));
3183
3270
  };
3184
3271
  Object.defineProperty(A, "__esModule", { value: !0 }), A.encode = void 0;
3185
- var t = re(), e = ut(), n = Ye;
3272
+ var t = re(), e = ut(), s = Ye;
3186
3273
  function r(m, S) {
3187
3274
  return [
3188
3275
  {
@@ -3203,8 +3290,8 @@ function tn() {
3203
3290
  }
3204
3291
  ];
3205
3292
  }
3206
- function s(m) {
3207
- return (0, n.flatten)(m.notes.map(function(S) {
3293
+ function n(m) {
3294
+ return (0, s.flatten)(m.notes.map(function(S) {
3208
3295
  return r(S, m.channel);
3209
3296
  }));
3210
3297
  }
@@ -3331,7 +3418,7 @@ function tn() {
3331
3418
  h(b.name),
3332
3419
  // the instrument
3333
3420
  c(b)
3334
- ], s(b), !0), o(b), !0), l(b), !0);
3421
+ ], n(b), !0), o(b), !0), l(b), !0);
3335
3422
  }), !0)
3336
3423
  };
3337
3424
  return S.tracks = S.tracks.map(function(b) {
@@ -3350,9 +3437,9 @@ function tn() {
3350
3437
  }
3351
3438
  return A.encode = g, A;
3352
3439
  }
3353
- var Dt;
3354
- function en() {
3355
- return Dt || (Dt = 1, (function(i) {
3440
+ var Bt;
3441
+ function es() {
3442
+ return Bt || (Bt = 1, (function(i) {
3356
3443
  var t = P && P.__awaiter || function(h, d, f, y) {
3357
3444
  function v(g) {
3358
3445
  return g instanceof f ? g : new f(function(m) {
@@ -3440,14 +3527,14 @@ function en() {
3440
3527
  }
3441
3528
  };
3442
3529
  Object.defineProperty(i, "__esModule", { value: !0 }), i.Header = i.Track = i.Midi = void 0;
3443
- var n = re(), r = ut(), s = Ut(), a = tn(), o = (
3530
+ var s = re(), r = ut(), n = Gt(), a = ts(), o = (
3444
3531
  /** @class */
3445
3532
  (function() {
3446
3533
  function h(d) {
3447
3534
  var f = this, y = null;
3448
3535
  if (d) {
3449
3536
  var v = d instanceof ArrayBuffer ? new Uint8Array(d) : d;
3450
- y = (0, n.parseMidi)(v), y.tracks.forEach(function(g) {
3537
+ y = (0, s.parseMidi)(v), y.tracks.forEach(function(g) {
3451
3538
  var m = 0;
3452
3539
  g.forEach(function(S) {
3453
3540
  m += S.deltaTime, S.absoluteTime = m;
@@ -3455,7 +3542,7 @@ function en() {
3455
3542
  }), y.tracks = c(y.tracks);
3456
3543
  }
3457
3544
  this.header = new r.Header(y), this.tracks = [], d && (this.tracks = y.tracks.map(function(g) {
3458
- return new s.Track(g, f.header);
3545
+ return new n.Track(g, f.header);
3459
3546
  }), y.header.format === 1 && this.tracks[0].duration === 0 && this.tracks.shift());
3460
3547
  }
3461
3548
  return h.fromUrl = function(d) {
@@ -3511,7 +3598,7 @@ function en() {
3511
3598
  enumerable: !1,
3512
3599
  configurable: !0
3513
3600
  }), h.prototype.addTrack = function() {
3514
- var d = new s.Track(void 0, this.header);
3601
+ var d = new n.Track(void 0, this.header);
3515
3602
  return this.tracks.push(d), d;
3516
3603
  }, h.prototype.toArray = function() {
3517
3604
  return (0, a.encode)(this);
@@ -3525,7 +3612,7 @@ function en() {
3525
3612
  }, h.prototype.fromJSON = function(d) {
3526
3613
  var f = this;
3527
3614
  this.header = new r.Header(), this.header.fromJSON(d.header), this.tracks = d.tracks.map(function(y) {
3528
- var v = new s.Track(void 0, f.header);
3615
+ var v = new n.Track(void 0, f.header);
3529
3616
  return v.fromJSON(y), v;
3530
3617
  });
3531
3618
  }, h.prototype.clone = function() {
@@ -3535,7 +3622,7 @@ function en() {
3535
3622
  })()
3536
3623
  );
3537
3624
  i.Midi = o;
3538
- var u = Ut();
3625
+ var u = Gt();
3539
3626
  Object.defineProperty(i, "Track", { enumerable: !0, get: function() {
3540
3627
  return u.Track;
3541
3628
  } });
@@ -3558,8 +3645,8 @@ function en() {
3558
3645
  }
3559
3646
  })(P)), P;
3560
3647
  }
3561
- var nn = en();
3562
- const sn = [
3648
+ var ss = es();
3649
+ const ns = [
3563
3650
  // Piano (0-7)
3564
3651
  "Acoustic Grand Piano",
3565
3652
  "Bright Acoustic Piano",
@@ -3705,13 +3792,13 @@ const sn = [
3705
3792
  "Applause",
3706
3793
  "Gunshot"
3707
3794
  ];
3708
- function Gt(i) {
3709
- return sn[i] ?? `Program ${i}`;
3795
+ function Dt(i) {
3796
+ return ns[i] ?? `Program ${i}`;
3710
3797
  }
3711
- function rn(i, t = {}) {
3712
- const { flatten: e = !1 } = t, n = new nn.Midi(i), r = n.header.tempos[0]?.bpm ?? 120, s = n.header.timeSignatures[0], a = s ? [s.timeSignature[0], s.timeSignature[1]] : [4, 4], o = n.name || "Untitled", u = /* @__PURE__ */ new Map();
3713
- for (const h of n.tracks) {
3714
- const d = h.channel, f = h.instrument.number, y = h.name || Gt(f);
3798
+ function rs(i, t = {}) {
3799
+ const { flatten: e = !1 } = t, s = new ss.Midi(i), r = s.header.tempos[0]?.bpm ?? 120, n = s.header.timeSignatures[0], a = n ? [n.timeSignature[0], n.timeSignature[1]] : [4, 4], o = s.name || "Untitled", u = /* @__PURE__ */ new Map();
3800
+ for (const h of s.tracks) {
3801
+ const d = h.channel, f = h.instrument.number, y = h.name || Dt(f);
3715
3802
  u.has(d) || u.set(d, { notes: [], programNumber: f, name: y });
3716
3803
  const v = u.get(d);
3717
3804
  h.name && !v.name.startsWith(h.name) && (v.name = h.name);
@@ -3764,7 +3851,7 @@ function rn(i, t = {}) {
3764
3851
  notes: h,
3765
3852
  duration: v,
3766
3853
  channel: y,
3767
- instrument: y === 9 ? "Percussion" : Gt(d),
3854
+ instrument: y === 9 ? "Percussion" : Dt(d),
3768
3855
  programNumber: d
3769
3856
  });
3770
3857
  }), {
@@ -3775,25 +3862,25 @@ function rn(i, t = {}) {
3775
3862
  timeSignature: a
3776
3863
  };
3777
3864
  }
3778
- async function hs(i, t = {}, e) {
3779
- const n = await fetch(i, { signal: e });
3780
- if (!n.ok)
3781
- throw new Error(`Failed to fetch MIDI file: ${n.status} ${n.statusText}`);
3782
- const r = await n.arrayBuffer();
3783
- return rn(r, t);
3865
+ async function hn(i, t = {}, e) {
3866
+ const s = await fetch(i, { signal: e });
3867
+ if (!s.ok)
3868
+ throw new Error(`Failed to fetch MIDI file: ${s.status} ${s.statusText}`);
3869
+ const r = await s.arrayBuffer();
3870
+ return rs(r, t);
3784
3871
  }
3785
- function ds(i) {
3872
+ function dn(i) {
3786
3873
  const t = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"], e = Math.floor(i / 12) - 1;
3787
3874
  return `${t[i % 12]}${e}`;
3788
3875
  }
3789
- function fs(i) {
3876
+ function fn(i) {
3790
3877
  const t = i.match(/^([A-Ga-g])([#b]?)(-?\d+)$/);
3791
3878
  if (!t) throw new Error(`Invalid note name: ${i}`);
3792
- const [, e, n, r] = t;
3879
+ const [, e, s, r] = t;
3793
3880
  let a = { C: 0, D: 2, E: 4, F: 5, G: 7, A: 9, B: 11 }[e.toUpperCase()];
3794
- return n === "#" && (a += 1), n === "b" && (a -= 1), (parseInt(r, 10) + 1) * 12 + a;
3881
+ return s === "#" && (a += 1), s === "b" && (a -= 1), (parseInt(r, 10) + 1) * 12 + a;
3795
3882
  }
3796
- const ps = {
3883
+ const pn = {
3797
3884
  NOTE_OFF: 8,
3798
3885
  NOTE_ON: 9,
3799
3886
  POLY_AFTERTOUCH: 10,
@@ -3801,7 +3888,7 @@ const ps = {
3801
3888
  PROGRAM_CHANGE: 12,
3802
3889
  CHANNEL_AFTERTOUCH: 13,
3803
3890
  PITCH_BEND: 14
3804
- }, ms = {
3891
+ }, mn = {
3805
3892
  MODULATION: 1,
3806
3893
  BREATH: 2,
3807
3894
  VOLUME: 7,
@@ -3815,10 +3902,10 @@ const ps = {
3815
3902
  RESET_ALL: 121,
3816
3903
  ALL_NOTES_OFF: 123
3817
3904
  };
3818
- function an(i, t) {
3819
- const e = i[0], n = e >> 4 & 15, r = e & 15;
3905
+ function is(i, t) {
3906
+ const e = i[0], s = e >> 4 & 15, r = e & 15;
3820
3907
  return {
3821
- command: n,
3908
+ command: s,
3822
3909
  channel: r,
3823
3910
  data1: i[1] ?? 0,
3824
3911
  data2: i[2] ?? 0,
@@ -3826,11 +3913,11 @@ function an(i, t) {
3826
3913
  timestamp: t
3827
3914
  };
3828
3915
  }
3829
- function on() {
3916
+ function as() {
3830
3917
  return typeof navigator < "u" && "requestMIDIAccess" in navigator;
3831
3918
  }
3832
- async function cn(i = !1) {
3833
- if (!on())
3919
+ async function os(i = !1) {
3920
+ if (!as())
3834
3921
  return console.warn("[MIDI] Web MIDI API not supported in this browser"), null;
3835
3922
  try {
3836
3923
  return await navigator.requestMIDIAccess({ sysex: i });
@@ -3838,7 +3925,7 @@ async function cn(i = !1) {
3838
3925
  return console.error("[MIDI] Failed to request MIDI access:", t), null;
3839
3926
  }
3840
3927
  }
3841
- function un(i) {
3928
+ function cs(i) {
3842
3929
  const t = [];
3843
3930
  return i.inputs.forEach((e) => {
3844
3931
  t.push({
@@ -3849,7 +3936,7 @@ function un(i) {
3849
3936
  });
3850
3937
  }), t;
3851
3938
  }
3852
- function ln(i) {
3939
+ function us(i) {
3853
3940
  const t = [];
3854
3941
  return i.outputs.forEach((e) => {
3855
3942
  t.push({
@@ -3860,7 +3947,7 @@ function ln(i) {
3860
3947
  });
3861
3948
  }), t;
3862
3949
  }
3863
- class gs {
3950
+ class gn {
3864
3951
  constructor() {
3865
3952
  this.access = null, this.activeInputId = null, this.messageCallbacks = /* @__PURE__ */ new Set(), this.stateChangeCallbacks = /* @__PURE__ */ new Set();
3866
3953
  }
@@ -3868,7 +3955,7 @@ class gs {
3868
3955
  * Initialize MIDI access
3869
3956
  */
3870
3957
  async init(t = !1) {
3871
- return this.access = await cn(t), this.access ? (this.access.onstatechange = () => {
3958
+ return this.access = await os(t), this.access ? (this.access.onstatechange = () => {
3872
3959
  this.stateChangeCallbacks.forEach((e) => e());
3873
3960
  }, !0) : !1;
3874
3961
  }
@@ -3882,13 +3969,13 @@ class gs {
3882
3969
  * Get available input devices
3883
3970
  */
3884
3971
  getInputs() {
3885
- return this.access ? un(this.access) : [];
3972
+ return this.access ? cs(this.access) : [];
3886
3973
  }
3887
3974
  /**
3888
3975
  * Get available output devices
3889
3976
  */
3890
3977
  getOutputs() {
3891
- return this.access ? ln(this.access) : [];
3978
+ return this.access ? us(this.access) : [];
3892
3979
  }
3893
3980
  /**
3894
3981
  * Connect to a specific MIDI input
@@ -3897,10 +3984,10 @@ class gs {
3897
3984
  if (!this.access) return !1;
3898
3985
  this.disconnectInput();
3899
3986
  const e = this.access.inputs.get(t);
3900
- return e ? (this.activeInputId = t, e.onmidimessage = (n) => {
3901
- if (!n.data) return;
3902
- const r = an(n.data, n.timeStamp);
3903
- this.messageCallbacks.forEach((s) => s(r));
3987
+ return e ? (this.activeInputId = t, e.onmidimessage = (s) => {
3988
+ if (!s.data) return;
3989
+ const r = is(s.data, s.timeStamp);
3990
+ this.messageCallbacks.forEach((n) => n(r));
3904
3991
  }, console.log(`[MIDI] Connected to input: ${e.name}`), !0) : (console.warn(`[MIDI] Input device not found: ${t}`), !1);
3905
3992
  }
3906
3993
  /**
@@ -3941,8 +4028,8 @@ class gs {
3941
4028
  */
3942
4029
  sendMessage(t, e) {
3943
4030
  if (!this.access) return !1;
3944
- const n = this.access.outputs.get(t);
3945
- return n ? (n.send(e), !0) : !1;
4031
+ const s = this.access.outputs.get(t);
4032
+ return s ? (s.send(e), !0) : !1;
3946
4033
  }
3947
4034
  /**
3948
4035
  * Clean up resources
@@ -3951,16 +4038,16 @@ class gs {
3951
4038
  this.disconnectInput(), this.messageCallbacks.clear(), this.stateChangeCallbacks.clear(), this.access = null;
3952
4039
  }
3953
4040
  }
3954
- function ys(i, t, e) {
4041
+ function yn(i, t, e) {
3955
4042
  return [144 | i & 15, t & 127, e & 127];
3956
4043
  }
3957
- function vs(i, t, e = 0) {
4044
+ function vn(i, t, e = 0) {
3958
4045
  return [128 | i & 15, t & 127, e & 127];
3959
4046
  }
3960
- function bs(i, t, e) {
4047
+ function bn(i, t, e) {
3961
4048
  return [176 | i & 15, t & 127, e & 127];
3962
4049
  }
3963
- class hn {
4050
+ class ls {
3964
4051
  constructor() {
3965
4052
  this.emitter = new ve();
3966
4053
  }
@@ -3980,7 +4067,7 @@ class hn {
3980
4067
  this.emitter.removeAllListeners();
3981
4068
  }
3982
4069
  }
3983
- class dn {
4070
+ class hs {
3984
4071
  constructor(t) {
3985
4072
  this.plugins = /* @__PURE__ */ new Map(), this.disposers = /* @__PURE__ */ new Map(), this.context = t;
3986
4073
  }
@@ -4006,9 +4093,9 @@ class dn {
4006
4093
  await this.unregister(e);
4007
4094
  }
4008
4095
  }
4009
- class fn {
4096
+ class ds {
4010
4097
  constructor(t = {}) {
4011
- this.events = new hn(), this.plugins = new dn({
4098
+ this.events = new ls(), this.plugins = new hs({
4012
4099
  events: this.events,
4013
4100
  requestAssistant: (o, u, l) => {
4014
4101
  this.events.emit("assistant:request", { assistantId: o, action: u, payload: l });
@@ -4048,9 +4135,9 @@ class fn {
4048
4135
  }, this.handleStop = () => {
4049
4136
  this.events.emit("stop");
4050
4137
  };
4051
- const { adapter: e, audio: n, plugins: r = [], ...s } = t, a = e ?? Le(n);
4138
+ const { adapter: e, audio: s, plugins: r = [], ...n } = t, a = e ?? Le(s);
4052
4139
  this.playlist = new Pe({
4053
- ...s,
4140
+ ...n,
4054
4141
  adapter: a
4055
4142
  }), this.initialPlugins = r, this.playlist.on("statechange", this.handleStateChange), this.playlist.on("timeupdate", this.handleTimeUpdate), this.playlist.on("play", this.handlePlay), this.playlist.on("pause", this.handlePause), this.playlist.on("stop", this.handleStop);
4056
4143
  }
@@ -4070,21 +4157,21 @@ class fn {
4070
4157
  this.playlist.off("statechange", this.handleStateChange), this.playlist.off("timeupdate", this.handleTimeUpdate), this.playlist.off("play", this.handlePlay), this.playlist.off("pause", this.handlePause), this.playlist.off("stop", this.handleStop), this.playlist.dispose(), await this.plugins.dispose(), this.events.emit("dispose"), this.events.removeAllListeners();
4071
4158
  }
4072
4159
  }
4073
- function Ss(i = {}) {
4074
- return new fn(i);
4160
+ function Sn(i = {}) {
4161
+ return new ds(i);
4075
4162
  }
4076
- class pn {
4163
+ class fs {
4077
4164
  constructor(t) {
4078
4165
  this._loaded = !1;
4079
- const { samples: e, baseUrl: n, release: r = 0.1, attack: s = 0, onload: a, volume: o = 0, destination: u } = t;
4166
+ const { samples: e, baseUrl: s, release: r = 0.1, attack: n = 0, onload: a, volume: o = 0, destination: u } = t;
4080
4167
  let l;
4081
4168
  this._loadPromise = new Promise((c) => {
4082
4169
  l = c;
4083
4170
  }), this.sampler = new fe({
4084
4171
  urls: e,
4085
- baseUrl: n,
4172
+ baseUrl: s,
4086
4173
  release: r,
4087
- attack: s,
4174
+ attack: n,
4088
4175
  volume: o,
4089
4176
  onload: () => {
4090
4177
  this._loaded = !0, l(), a?.();
@@ -4125,8 +4212,8 @@ class pn {
4125
4212
  * @param time - When to trigger (default: now)
4126
4213
  * @param velocity - The velocity 0-1 (default: 1)
4127
4214
  */
4128
- triggerAttack(t, e, n) {
4129
- return this._loaded ? (this.sampler.triggerAttack(t, e, n), this) : (console.warn("[SamplerInstrument] Samples not loaded yet"), this);
4215
+ triggerAttack(t, e, s) {
4216
+ return this._loaded ? (this.sampler.triggerAttack(t, e, s), this) : (console.warn("[SamplerInstrument] Samples not loaded yet"), this);
4130
4217
  }
4131
4218
  /**
4132
4219
  * Trigger the release of a note
@@ -4145,8 +4232,8 @@ class pn {
4145
4232
  * @param time - When to start (default: now)
4146
4233
  * @param velocity - The velocity 0-1 (default: 1)
4147
4234
  */
4148
- triggerAttackRelease(t, e, n, r) {
4149
- return this._loaded ? (this.sampler.triggerAttackRelease(t, e, n, r), this) : (console.warn("[SamplerInstrument] Samples not loaded yet"), this);
4235
+ triggerAttackRelease(t, e, s, r) {
4236
+ return this._loaded ? (this.sampler.triggerAttackRelease(t, e, s, r), this) : (console.warn("[SamplerInstrument] Samples not loaded yet"), this);
4150
4237
  }
4151
4238
  /**
4152
4239
  * Release all currently held notes
@@ -4175,11 +4262,11 @@ class pn {
4175
4262
  this.sampler.dispose();
4176
4263
  }
4177
4264
  }
4178
- async function ws(i, t = {}) {
4179
- const e = new pn({ samples: i, ...t });
4265
+ async function wn(i, t = {}) {
4266
+ const e = new fs({ samples: i, ...t });
4180
4267
  return await e.load(), e;
4181
4268
  }
4182
- class ks {
4269
+ class kn {
4183
4270
  get muted() {
4184
4271
  return this._muted;
4185
4272
  }
@@ -4187,15 +4274,15 @@ class ks {
4187
4274
  return this._duration;
4188
4275
  }
4189
4276
  constructor(t) {
4190
- const { instrument: e, clips: n, track: r, effects: s, destination: a } = t;
4277
+ const { instrument: e, clips: s, track: r, effects: n, destination: a } = t;
4191
4278
  this.id = r.id, this.startTime = r.startTime ?? 0, this.instrument = e, this._muted = r.muted, this.volumeNode = new L(this.gainToDb(r.gain)), this.panNode = new X(r.stereoPan), this.muteGain = new C(r.muted ? 0 : 1), this.volumeNode.chain(this.panNode, this.muteGain), this.instrument.connect(this.volumeNode);
4192
4279
  const o = a ?? O();
4193
- if (s) {
4194
- const u = s(this.muteGain, o);
4280
+ if (n) {
4281
+ const u = n(this.muteGain, o);
4195
4282
  u && (this.effectsCleanup = u);
4196
4283
  } else
4197
4284
  this.muteGain.connect(o);
4198
- this._duration = this.calculateDuration(n), this.scheduledClips = this.scheduleClips(n);
4285
+ this._duration = this.calculateDuration(s), this.scheduledClips = this.scheduleClips(s);
4199
4286
  }
4200
4287
  gainToDb(t) {
4201
4288
  return t > 0 ? 20 * Math.log10(t) : -1 / 0;
@@ -4204,15 +4291,15 @@ class ks {
4204
4291
  return t.length === 0 ? 0 : Math.max(...t.map((e) => e.startTime + e.duration));
4205
4292
  }
4206
4293
  midiToNoteName(t) {
4207
- const e = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"], n = Math.floor(t / 12) - 1, r = t % 12;
4208
- return `${e[r]}${n}`;
4294
+ const e = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"], s = Math.floor(t / 12) - 1, r = t % 12;
4295
+ return `${e[r]}${s}`;
4209
4296
  }
4210
4297
  scheduleClips(t) {
4211
4298
  return t.map((e) => {
4212
- const n = e.notes.filter((o) => {
4299
+ const s = e.notes.filter((o) => {
4213
4300
  const u = o.time + o.duration;
4214
4301
  return o.time < e.offset + e.duration && u > e.offset;
4215
- }), r = this.startTime + e.startTime, s = n.map((o) => {
4302
+ }), r = this.startTime + e.startTime, n = s.map((o) => {
4216
4303
  const u = o.time - e.offset, l = Math.max(0, u), c = Math.min(
4217
4304
  o.duration - Math.max(0, e.offset - o.time),
4218
4305
  e.duration - l
@@ -4231,7 +4318,7 @@ class ks {
4231
4318
  o,
4232
4319
  u.velocity
4233
4320
  );
4234
- }, s);
4321
+ }, n);
4235
4322
  return a.start(0), a.loop = !1, { clipData: e, part: a };
4236
4323
  });
4237
4324
  }
@@ -4285,7 +4372,7 @@ class ks {
4285
4372
  cancelFades() {
4286
4373
  }
4287
4374
  }
4288
- function mn(i) {
4375
+ function ps(i) {
4289
4376
  const t = i.params || {};
4290
4377
  switch (i.type) {
4291
4378
  case "eq":
@@ -4370,12 +4457,12 @@ function mn(i) {
4370
4457
  throw new Error(`Unknown effect type: ${i.type}`);
4371
4458
  }
4372
4459
  }
4373
- class gn {
4460
+ class ms {
4374
4461
  constructor(t) {
4375
4462
  this.effects = [];
4376
- const { effects: e, mix: n = 1 } = t;
4377
- this.inputGain = new C(1), this.outputGain = new C(1), this.dryGain = new C(1 - n), this.wetGain = new C(n), e.forEach((r, s) => {
4378
- const a = r.id ?? `${r.type}-${s}`, o = mn(r), u = new C(r.bypassed ? 0 : 1);
4463
+ const { effects: e, mix: s = 1 } = t;
4464
+ this.inputGain = new C(1), this.outputGain = new C(1), this.dryGain = new C(1 - s), this.wetGain = new C(s), e.forEach((r, n) => {
4465
+ const a = r.id ?? `${r.type}-${n}`, o = ps(r), u = new C(r.bypassed ? 0 : 1);
4379
4466
  this.effects.push({
4380
4467
  id: a,
4381
4468
  type: r.type,
@@ -4436,36 +4523,36 @@ class gn {
4436
4523
  * @param params - Parameters to update
4437
4524
  */
4438
4525
  setEffectParams(t, e) {
4439
- const n = this.effects.find((s) => s.id === t || s.type === t);
4440
- if (!n) {
4526
+ const s = this.effects.find((n) => n.id === t || n.type === t);
4527
+ if (!s) {
4441
4528
  console.warn(`[EffectChain] Effect not found: ${t}`);
4442
4529
  return;
4443
4530
  }
4444
- const r = n.node;
4445
- for (const [s, a] of Object.entries(e))
4446
- if (s in r) {
4447
- const o = r[s];
4448
- o && typeof o == "object" && "value" in o ? o.value = a : r[s] = a;
4531
+ const r = s.node;
4532
+ for (const [n, a] of Object.entries(e))
4533
+ if (n in r) {
4534
+ const o = r[n];
4535
+ o && typeof o == "object" && "value" in o ? o.value = a : r[n] = a;
4449
4536
  }
4450
4537
  }
4451
4538
  /**
4452
4539
  * Bypass or enable an effect
4453
4540
  */
4454
4541
  setBypass(t, e) {
4455
- const n = this.effects.find((s) => s.id === t || s.type === t);
4456
- if (!n) {
4542
+ const s = this.effects.find((n) => n.id === t || n.type === t);
4543
+ if (!s) {
4457
4544
  console.warn(`[EffectChain] Effect not found: ${t}`);
4458
4545
  return;
4459
4546
  }
4460
- n.bypassed = e;
4461
- const r = n.node;
4547
+ s.bypassed = e;
4548
+ const r = s.node;
4462
4549
  r.wet && (r.wet.value = e ? 0 : 1);
4463
4550
  }
4464
4551
  /**
4465
4552
  * Get an effect node by ID
4466
4553
  */
4467
4554
  getEffect(t) {
4468
- return this.effects.find((n) => n.id === t || n.type === t)?.node;
4555
+ return this.effects.find((s) => s.id === t || s.type === t)?.node;
4469
4556
  }
4470
4557
  /**
4471
4558
  * Dispose of all effects
@@ -4476,10 +4563,10 @@ class gn {
4476
4563
  }), this.effects = [];
4477
4564
  }
4478
4565
  }
4479
- function Ts(i) {
4480
- return new gn(i);
4566
+ function Tn(i) {
4567
+ return new ms(i);
4481
4568
  }
4482
- function st(i, t = {}) {
4569
+ function nt(i, t = {}) {
4483
4570
  switch (i) {
4484
4571
  case "eq":
4485
4572
  return new Yt({
@@ -4566,7 +4653,7 @@ function st(i, t = {}) {
4566
4653
  }
4567
4654
  }
4568
4655
  let Rt = 0;
4569
- class yn {
4656
+ class gs {
4570
4657
  constructor(t = {}) {
4571
4658
  this.slots = [], this.destination = null, this.maxSlots = t.maxSlots ?? 16, this.inputGain = new C(1), this.outputGain = new C(1), this.inputGain.connect(this.outputGain);
4572
4659
  }
@@ -4598,21 +4685,21 @@ class yn {
4598
4685
  * Rebuild the effect chain after changes
4599
4686
  */
4600
4687
  rebuildChain() {
4601
- this.inputGain.disconnect(), this.slots.forEach((n) => {
4602
- n.node.disconnect();
4688
+ this.inputGain.disconnect(), this.slots.forEach((s) => {
4689
+ s.node.disconnect();
4603
4690
  });
4604
- const t = this.slots.filter((n) => !n.bypassed);
4691
+ const t = this.slots.filter((s) => !s.bypassed);
4605
4692
  if (t.length === 0)
4606
4693
  this.inputGain.connect(this.outputGain);
4607
4694
  else {
4608
- let n = this.inputGain;
4695
+ let s = this.inputGain;
4609
4696
  for (const r of t)
4610
- n.connect(r.node), n = r.node;
4611
- n.connect(this.outputGain);
4697
+ s.connect(r.node), s = r.node;
4698
+ s.connect(this.outputGain);
4612
4699
  }
4613
- const e = this.slots.filter((n) => n.bypassed);
4614
- for (const n of e) {
4615
- const r = n.node;
4700
+ const e = this.slots.filter((s) => s.bypassed);
4701
+ for (const s of e) {
4702
+ const r = s.node;
4616
4703
  r.wet && (r.wet.value = 0);
4617
4704
  }
4618
4705
  }
@@ -4623,29 +4710,29 @@ class yn {
4623
4710
  insert(t, e = {}) {
4624
4711
  if (this.slots.length >= this.maxSlots)
4625
4712
  throw new Error(`Maximum number of effect slots (${this.maxSlots}) reached`);
4626
- const n = `slot-${++Rt}`, r = st(t, e);
4713
+ const s = `slot-${++Rt}`, r = nt(t, e);
4627
4714
  return this.slots.push({
4628
- id: n,
4715
+ id: s,
4629
4716
  type: t,
4630
4717
  node: r,
4631
4718
  bypassed: !1,
4632
4719
  params: e
4633
- }), this.rebuildChain(), n;
4720
+ }), this.rebuildChain(), s;
4634
4721
  }
4635
4722
  /**
4636
4723
  * Insert an effect at a specific position
4637
4724
  * @returns The slot ID
4638
4725
  */
4639
- insertAt(t, e, n = {}) {
4726
+ insertAt(t, e, s = {}) {
4640
4727
  if (this.slots.length >= this.maxSlots)
4641
4728
  throw new Error(`Maximum number of effect slots (${this.maxSlots}) reached`);
4642
- const r = `slot-${++Rt}`, s = st(e, n), a = Math.max(0, Math.min(t, this.slots.length));
4729
+ const r = `slot-${++Rt}`, n = nt(e, s), a = Math.max(0, Math.min(t, this.slots.length));
4643
4730
  return this.slots.splice(a, 0, {
4644
4731
  id: r,
4645
4732
  type: e,
4646
- node: s,
4733
+ node: n,
4647
4734
  bypassed: !1,
4648
- params: n
4735
+ params: s
4649
4736
  }), this.rebuildChain(), r;
4650
4737
  }
4651
4738
  /**
@@ -4655,8 +4742,8 @@ class yn {
4655
4742
  let e;
4656
4743
  if (typeof t == "number" ? e = t : e = this.slots.findIndex((r) => r.id === t), e < 0 || e >= this.slots.length)
4657
4744
  return !1;
4658
- const [n] = this.slots.splice(e, 1);
4659
- return n.node.dispose(), this.rebuildChain(), !0;
4745
+ const [s] = this.slots.splice(e, 1);
4746
+ return s.node.dispose(), this.rebuildChain(), !0;
4660
4747
  }
4661
4748
  /**
4662
4749
  * Move an effect to a new position
@@ -4664,35 +4751,35 @@ class yn {
4664
4751
  move(t, e) {
4665
4752
  if (t < 0 || t >= this.slots.length || e < 0 || e >= this.slots.length) return !1;
4666
4753
  if (t === e) return !0;
4667
- const [n] = this.slots.splice(t, 1);
4668
- return this.slots.splice(e, 0, n), this.rebuildChain(), !0;
4754
+ const [s] = this.slots.splice(t, 1);
4755
+ return this.slots.splice(e, 0, s), this.rebuildChain(), !0;
4669
4756
  }
4670
4757
  /**
4671
4758
  * Bypass or enable an effect
4672
4759
  */
4673
4760
  bypass(t, e) {
4674
- let n;
4675
- return typeof t == "number" ? n = this.slots[t] : n = this.slots.find((r) => r.id === t), n ? (n.bypassed = e, this.rebuildChain(), !0) : !1;
4761
+ let s;
4762
+ return typeof t == "number" ? s = this.slots[t] : s = this.slots.find((r) => r.id === t), s ? (s.bypassed = e, this.rebuildChain(), !0) : !1;
4676
4763
  }
4677
4764
  /**
4678
4765
  * Toggle bypass state
4679
4766
  */
4680
4767
  toggleBypass(t) {
4681
4768
  let e;
4682
- return typeof t == "number" ? e = this.slots[t] : e = this.slots.find((n) => n.id === t), e ? (e.bypassed = !e.bypassed, this.rebuildChain(), !0) : !1;
4769
+ return typeof t == "number" ? e = this.slots[t] : e = this.slots.find((s) => s.id === t), e ? (e.bypassed = !e.bypassed, this.rebuildChain(), !0) : !1;
4683
4770
  }
4684
4771
  /**
4685
4772
  * Update effect parameters
4686
4773
  */
4687
4774
  setParams(t, e) {
4688
- let n;
4689
- if (typeof t == "number" ? n = this.slots[t] : n = this.slots.find((s) => s.id === t), !n) return !1;
4690
- Object.assign(n.params, e);
4691
- const r = n.node;
4692
- for (const [s, a] of Object.entries(e))
4693
- if (s in r) {
4694
- const o = r[s];
4695
- o && typeof o == "object" && "value" in o ? o.value = a : r[s] = a;
4775
+ let s;
4776
+ if (typeof t == "number" ? s = this.slots[t] : s = this.slots.find((n) => n.id === t), !s) return !1;
4777
+ Object.assign(s.params, e);
4778
+ const r = s.node;
4779
+ for (const [n, a] of Object.entries(e))
4780
+ if (n in r) {
4781
+ const o = r[n];
4782
+ o && typeof o == "object" && "value" in o ? o.value = a : r[n] = a;
4696
4783
  }
4697
4784
  return !0;
4698
4785
  }
@@ -4705,18 +4792,18 @@ class yn {
4705
4792
  /**
4706
4793
  * Replace an effect with a new one
4707
4794
  */
4708
- replace(t, e, n = {}) {
4795
+ replace(t, e, s = {}) {
4709
4796
  let r;
4710
4797
  if (typeof t == "number" ? r = t : r = this.slots.findIndex((o) => o.id === t), r < 0 || r >= this.slots.length) return !1;
4711
- const s = this.slots[r];
4712
- s.node.dispose();
4713
- const a = st(e, n);
4798
+ const n = this.slots[r];
4799
+ n.node.dispose();
4800
+ const a = nt(e, s);
4714
4801
  return this.slots[r] = {
4715
- id: s.id,
4802
+ id: n.id,
4716
4803
  type: e,
4717
4804
  node: a,
4718
- bypassed: s.bypassed,
4719
- params: n
4805
+ bypassed: n.bypassed,
4806
+ params: s
4720
4807
  }, this.rebuildChain(), !0;
4721
4808
  }
4722
4809
  /**
@@ -4760,26 +4847,26 @@ class yn {
4760
4847
  fromJSON(t) {
4761
4848
  this.clear();
4762
4849
  for (const e of t) {
4763
- const n = this.insert(e.type, e.params);
4764
- e.bypassed && this.bypass(n, !0);
4850
+ const s = this.insert(e.type, e.params);
4851
+ e.bypassed && this.bypass(s, !0);
4765
4852
  }
4766
4853
  }
4767
4854
  }
4768
- function Cs(i = {}) {
4769
- return new yn(i);
4855
+ function Cn(i = {}) {
4856
+ return new gs(i);
4770
4857
  }
4771
- class vn {
4858
+ class ys {
4772
4859
  constructor(t = {}) {
4773
4860
  this.tracks = /* @__PURE__ */ new Map(), this._currentStep = 0, this._isPlaying = !1;
4774
4861
  const {
4775
4862
  steps: e = 16,
4776
- subdivision: n = "16n",
4863
+ subdivision: s = "16n",
4777
4864
  tracks: r = [],
4778
- loop: s = !0,
4865
+ loop: n = !0,
4779
4866
  swing: a = 0,
4780
4867
  onStep: o
4781
4868
  } = t;
4782
- this.numSteps = e, this.subdivision = n, this._loop = s, this._swing = a, this.onStep = o, r.forEach((u) => this.addTrack(u));
4869
+ this.numSteps = e, this.subdivision = s, this._loop = n, this._swing = a, this.onStep = o, r.forEach((u) => this.addTrack(u));
4783
4870
  }
4784
4871
  /**
4785
4872
  * Current step index (0-based)
@@ -4816,13 +4903,13 @@ class vn {
4816
4903
  addTrack(t) {
4817
4904
  const {
4818
4905
  id: e,
4819
- instrument: n,
4906
+ instrument: s,
4820
4907
  note: r = "C2",
4821
- steps: s = this.createEmptySteps(),
4908
+ steps: n = this.createEmptySteps(),
4822
4909
  muted: a = !1,
4823
4910
  soloed: o = !1,
4824
4911
  volume: u = 1
4825
- } = t, l = this.normalizeSteps(s), c = new pe(
4912
+ } = t, l = this.normalizeSteps(n), c = new pe(
4826
4913
  (d, f) => {
4827
4914
  this._currentStep = f, this.triggerStep(e, f, d);
4828
4915
  },
@@ -4832,7 +4919,7 @@ class vn {
4832
4919
  c.loop = this._loop, this._swing > 0 && (c.humanize = this._swing * 0.05);
4833
4920
  const h = {
4834
4921
  id: e,
4835
- instrument: n,
4922
+ instrument: s,
4836
4923
  note: r,
4837
4924
  steps: l,
4838
4925
  muted: a,
@@ -4863,9 +4950,9 @@ class vn {
4863
4950
  */
4864
4951
  normalizeSteps(t) {
4865
4952
  const e = [];
4866
- for (let n = 0; n < this.numSteps; n++)
4953
+ for (let s = 0; s < this.numSteps; s++)
4867
4954
  e.push(
4868
- t[n] ?? {
4955
+ t[s] ?? {
4869
4956
  active: !1,
4870
4957
  velocity: 1
4871
4958
  }
@@ -4881,36 +4968,36 @@ class vn {
4881
4968
  /**
4882
4969
  * Trigger a step
4883
4970
  */
4884
- triggerStep(t, e, n) {
4971
+ triggerStep(t, e, s) {
4885
4972
  const r = this.tracks.get(t);
4886
4973
  if (!r || r.muted || this.hasAnySolo() && !r.soloed) return;
4887
4974
  const a = r.steps[e];
4888
4975
  if (!a || !a.active || a.probability !== void 0 && Math.random() > a.probability)
4889
4976
  return;
4890
4977
  const o = a.velocity * r.volume, u = a.note ?? r.note;
4891
- r.instrument.triggerAttackRelease(u, this.subdivision, n, o), this.onStep?.(t, e, n);
4978
+ r.instrument.triggerAttackRelease(u, this.subdivision, s, o), this.onStep?.(t, e, s);
4892
4979
  }
4893
4980
  /**
4894
4981
  * Set a step's state
4895
4982
  */
4896
- setStep(t, e, n) {
4983
+ setStep(t, e, s) {
4897
4984
  const r = this.tracks.get(t);
4898
- return !r || e < 0 || e >= this.numSteps ? !1 : (Object.assign(r.steps[e], n), !0);
4985
+ return !r || e < 0 || e >= this.numSteps ? !1 : (Object.assign(r.steps[e], s), !0);
4899
4986
  }
4900
4987
  /**
4901
4988
  * Toggle a step's active state
4902
4989
  */
4903
4990
  toggleStep(t, e) {
4904
- const n = this.tracks.get(t);
4905
- return !n || e < 0 || e >= this.numSteps ? !1 : (n.steps[e].active = !n.steps[e].active, n.steps[e].active);
4991
+ const s = this.tracks.get(t);
4992
+ return !s || e < 0 || e >= this.numSteps ? !1 : (s.steps[e].active = !s.steps[e].active, s.steps[e].active);
4906
4993
  }
4907
4994
  /**
4908
4995
  * Get a step's state
4909
4996
  */
4910
4997
  getStep(t, e) {
4911
- const n = this.tracks.get(t);
4912
- if (!(!n || e < 0 || e >= this.numSteps))
4913
- return { ...n.steps[e] };
4998
+ const s = this.tracks.get(t);
4999
+ if (!(!s || e < 0 || e >= this.numSteps))
5000
+ return { ...s.steps[e] };
4914
5001
  }
4915
5002
  /**
4916
5003
  * Get all steps for a track
@@ -4918,14 +5005,14 @@ class vn {
4918
5005
  getTrackSteps(t) {
4919
5006
  const e = this.tracks.get(t);
4920
5007
  if (e)
4921
- return e.steps.map((n) => ({ ...n }));
5008
+ return e.steps.map((s) => ({ ...s }));
4922
5009
  }
4923
5010
  /**
4924
5011
  * Set all steps for a track
4925
5012
  */
4926
5013
  setTrackSteps(t, e) {
4927
- const n = this.tracks.get(t);
4928
- return n ? (n.steps = this.normalizeSteps(e), !0) : !1;
5014
+ const s = this.tracks.get(t);
5015
+ return s ? (s.steps = this.normalizeSteps(e), !0) : !1;
4929
5016
  }
4930
5017
  /**
4931
5018
  * Clear all steps for a track
@@ -4946,30 +5033,30 @@ class vn {
4946
5033
  * Set track mute state
4947
5034
  */
4948
5035
  setMuted(t, e) {
4949
- const n = this.tracks.get(t);
4950
- return n ? (n.muted = e, !0) : !1;
5036
+ const s = this.tracks.get(t);
5037
+ return s ? (s.muted = e, !0) : !1;
4951
5038
  }
4952
5039
  /**
4953
5040
  * Set track solo state
4954
5041
  */
4955
5042
  setSoloed(t, e) {
4956
- const n = this.tracks.get(t);
4957
- return n ? (n.soloed = e, !0) : !1;
5043
+ const s = this.tracks.get(t);
5044
+ return s ? (s.soloed = e, !0) : !1;
4958
5045
  }
4959
5046
  /**
4960
5047
  * Set track volume
4961
5048
  */
4962
5049
  setVolume(t, e) {
4963
- const n = this.tracks.get(t);
4964
- return n ? (n.volume = Math.max(0, Math.min(1, e)), !0) : !1;
5050
+ const s = this.tracks.get(t);
5051
+ return s ? (s.volume = Math.max(0, Math.min(1, e)), !0) : !1;
4965
5052
  }
4966
5053
  /**
4967
5054
  * Start the sequencer (synced to transport)
4968
5055
  */
4969
5056
  start(t) {
4970
5057
  if (this._isPlaying) return;
4971
- this.tracks.forEach((n) => {
4972
- n.sequence.start(t);
5058
+ this.tracks.forEach((s) => {
5059
+ s.sequence.start(t);
4973
5060
  });
4974
5061
  const e = w();
4975
5062
  e.state !== "started" && e.start(t), this._isPlaying = !0;
@@ -4994,8 +5081,8 @@ class vn {
4994
5081
  * Randomize steps for a track
4995
5082
  */
4996
5083
  randomize(t, e = 0.3) {
4997
- const n = this.tracks.get(t);
4998
- return n ? (n.steps = n.steps.map(() => ({
5084
+ const s = this.tracks.get(t);
5085
+ return s ? (s.steps = s.steps.map(() => ({
4999
5086
  active: Math.random() < e,
5000
5087
  velocity: 0.5 + Math.random() * 0.5
5001
5088
  })), !0) : !1;
@@ -5004,17 +5091,17 @@ class vn {
5004
5091
  * Shift all steps in a track
5005
5092
  */
5006
5093
  shift(t, e) {
5007
- const n = this.tracks.get(t);
5008
- if (!n) return !1;
5009
- const r = n.steps, s = r.length, a = (e % s + s) % s;
5010
- return n.steps = [...r.slice(-a), ...r.slice(0, -a)], !0;
5094
+ const s = this.tracks.get(t);
5095
+ if (!s) return !1;
5096
+ const r = s.steps, n = r.length, a = (e % n + n) % n;
5097
+ return s.steps = [...r.slice(-a), ...r.slice(0, -a)], !0;
5011
5098
  }
5012
5099
  /**
5013
5100
  * Copy steps from one track to another
5014
5101
  */
5015
5102
  copyTrack(t, e) {
5016
- const n = this.tracks.get(t), r = this.tracks.get(e);
5017
- return !n || !r ? !1 : (r.steps = n.steps.map((s) => ({ ...s })), !0);
5103
+ const s = this.tracks.get(t), r = this.tracks.get(e);
5104
+ return !s || !r ? !1 : (r.steps = s.steps.map((n) => ({ ...n })), !0);
5018
5105
  }
5019
5106
  /**
5020
5107
  * Get all track IDs
@@ -5035,30 +5122,30 @@ class vn {
5035
5122
  */
5036
5123
  toJSON() {
5037
5124
  const t = {};
5038
- return this.tracks.forEach((e, n) => {
5039
- t[n] = e.steps.map((r) => ({ ...r }));
5125
+ return this.tracks.forEach((e, s) => {
5126
+ t[s] = e.steps.map((r) => ({ ...r }));
5040
5127
  }), t;
5041
5128
  }
5042
5129
  /**
5043
5130
  * Import state from JSON
5044
5131
  */
5045
5132
  fromJSON(t) {
5046
- Object.entries(t).forEach(([e, n]) => {
5047
- this.setTrackSteps(e, n);
5133
+ Object.entries(t).forEach(([e, s]) => {
5134
+ this.setTrackSteps(e, s);
5048
5135
  });
5049
5136
  }
5050
5137
  }
5051
- function Ms(i = {}) {
5052
- return new vn(i);
5138
+ function _n(i = {}) {
5139
+ return new ys(i);
5053
5140
  }
5054
- class bn {
5141
+ class vs {
5055
5142
  constructor(t = {}) {
5056
5143
  this.beatScheduleId = null, this.barScheduleId = null, this.currentBeat = 0, this.currentBar = 0;
5057
5144
  const {
5058
5145
  bpm: e = 120,
5059
- timeSignature: n = 4,
5146
+ timeSignature: s = 4,
5060
5147
  loop: r = !1,
5061
- loopStart: s,
5148
+ loopStart: n,
5062
5149
  loopEnd: a,
5063
5150
  onStateChange: o,
5064
5151
  onBeat: u,
@@ -5066,7 +5153,7 @@ class bn {
5066
5153
  } = t;
5067
5154
  this.onStateChange = o, this.onBeat = u, this.onBar = l;
5068
5155
  const c = w();
5069
- c.bpm.value = e, c.timeSignature = n, c.loop = r, s !== void 0 && (c.loopStart = s), a !== void 0 && (c.loopEnd = a), u && this.scheduleBeatCallback(), l && this.scheduleBarCallback();
5156
+ c.bpm.value = e, c.timeSignature = s, c.loop = r, n !== void 0 && (c.loopStart = n), a !== void 0 && (c.loopEnd = a), u && this.scheduleBeatCallback(), l && this.scheduleBarCallback();
5070
5157
  }
5071
5158
  scheduleBeatCallback() {
5072
5159
  const t = w();
@@ -5141,8 +5228,8 @@ class bn {
5141
5228
  * Set BPM
5142
5229
  */
5143
5230
  setBpm(t, e) {
5144
- const n = w();
5145
- e ? n.bpm.rampTo(t, e) : n.bpm.value = t, this.notifyStateChange();
5231
+ const s = w();
5232
+ e ? s.bpm.rampTo(t, e) : s.bpm.value = t, this.notifyStateChange();
5146
5233
  }
5147
5234
  /**
5148
5235
  * Set time signature
@@ -5154,9 +5241,9 @@ class bn {
5154
5241
  /**
5155
5242
  * Set loop range
5156
5243
  */
5157
- setLoop(t, e, n) {
5244
+ setLoop(t, e, s) {
5158
5245
  const r = w();
5159
- r.loop = t, e !== void 0 && (r.loopStart = e), n !== void 0 && (r.loopEnd = n), this.notifyStateChange();
5246
+ r.loop = t, e !== void 0 && (r.loopStart = e), s !== void 0 && (r.loopEnd = s), this.notifyStateChange();
5160
5247
  }
5161
5248
  /**
5162
5249
  * Schedule a callback at a specific time
@@ -5167,8 +5254,8 @@ class bn {
5167
5254
  /**
5168
5255
  * Schedule a repeating callback
5169
5256
  */
5170
- scheduleRepeat(t, e, n, r) {
5171
- return w().scheduleRepeat(t, e, n, r);
5257
+ scheduleRepeat(t, e, s, r) {
5258
+ return w().scheduleRepeat(t, e, s, r);
5172
5259
  }
5173
5260
  /**
5174
5261
  * Clear a scheduled callback
@@ -5195,7 +5282,7 @@ class bn {
5195
5282
  * Convert seconds to bars:beats:sixteenths
5196
5283
  */
5197
5284
  toBBS(t) {
5198
- const e = w(), n = e.toSeconds(t), r = e.bpm.value, s = Array.isArray(e.timeSignature) ? e.timeSignature[0] : e.timeSignature, a = r / 60, o = n * a, u = s, l = Math.floor(o / u), c = Math.floor(o % u), h = Math.floor(o * 4 % 4);
5285
+ const e = w(), s = e.toSeconds(t), r = e.bpm.value, n = Array.isArray(e.timeSignature) ? e.timeSignature[0] : e.timeSignature, a = r / 60, o = s * a, u = n, l = Math.floor(o / u), c = Math.floor(o % u), h = Math.floor(o * 4 % 4);
5199
5286
  return `${l}:${c}:${h}`;
5200
5287
  }
5201
5288
  /**
@@ -5206,8 +5293,8 @@ class bn {
5206
5293
  this.beatScheduleId !== null && t.clear(this.beatScheduleId), this.barScheduleId !== null && t.clear(this.barScheduleId);
5207
5294
  }
5208
5295
  }
5209
- function _s(i = {}) {
5210
- return new bn(i);
5296
+ function Mn(i = {}) {
5297
+ return new vs(i);
5211
5298
  }
5212
5299
  function Vt(i) {
5213
5300
  switch (i) {
@@ -5225,18 +5312,18 @@ function Vt(i) {
5225
5312
  return 1;
5226
5313
  }
5227
5314
  }
5228
- class Sn {
5315
+ class bs {
5229
5316
  constructor(t = {}) {
5230
5317
  const {
5231
5318
  subdivision: e = "16n",
5232
- strength: n = 1,
5319
+ strength: s = 1,
5233
5320
  preset: r,
5234
- quantizeStart: s = !0,
5321
+ quantizeStart: n = !0,
5235
5322
  quantizeEnd: a = !0,
5236
5323
  swing: o = 0,
5237
5324
  swingSubdivision: u = "8n"
5238
5325
  } = t;
5239
- this.subdivision = e, this.strength = r ? Vt(r) : Math.max(0, Math.min(1, n)), this.quantizeStart = s, this.quantizeEnd = a, this.swing = Math.max(0, Math.min(1, o)), this.swingSubdivision = u;
5326
+ this.subdivision = e, this.strength = r ? Vt(r) : Math.max(0, Math.min(1, s)), this.quantizeStart = n, this.quantizeEnd = a, this.swing = Math.max(0, Math.min(1, o)), this.swingSubdivision = u;
5240
5327
  }
5241
5328
  /**
5242
5329
  * Get the grid size in seconds for the current subdivision
@@ -5256,15 +5343,15 @@ class Sn {
5256
5343
  quantizeTime(t) {
5257
5344
  if (this.strength === 0) return t;
5258
5345
  const e = this.getGridSize(), r = Math.round(t / e) * e;
5259
- let s = r;
5346
+ let n = r;
5260
5347
  if (this.swing > 0) {
5261
5348
  const a = this.getSwingGridSize();
5262
5349
  if (Math.round(t / a) % 2 === 1) {
5263
5350
  const u = a * this.swing * 0.33;
5264
- s = r + u;
5351
+ n = r + u;
5265
5352
  }
5266
5353
  }
5267
- return t + (s - t) * this.strength;
5354
+ return t + (n - t) * this.strength;
5268
5355
  }
5269
5356
  /**
5270
5357
  * Quantize a single note
@@ -5272,7 +5359,7 @@ class Sn {
5272
5359
  quantizeNote(t) {
5273
5360
  const e = { ...t };
5274
5361
  if (this.quantizeStart && (e.time = this.quantizeTime(t.time)), this.quantizeEnd) {
5275
- const n = t.time + t.duration, r = this.quantizeTime(n);
5362
+ const s = t.time + t.duration, r = this.quantizeTime(s);
5276
5363
  e.duration = Math.max(
5277
5364
  this.getGridSize() * 0.5,
5278
5365
  // Minimum duration = half grid
@@ -5330,18 +5417,18 @@ class Sn {
5330
5417
  * Get all grid lines within a time range
5331
5418
  */
5332
5419
  getGridLines(t, e) {
5333
- const n = this.getGridSize(), r = [];
5334
- let s = this.getPreviousGridLine(t);
5335
- for (; s <= e; )
5336
- s >= t && r.push(s), s += n;
5420
+ const s = this.getGridSize(), r = [];
5421
+ let n = this.getPreviousGridLine(t);
5422
+ for (; n <= e; )
5423
+ n >= t && r.push(n), n += s;
5337
5424
  return r;
5338
5425
  }
5339
5426
  /**
5340
5427
  * Check if a time is on the grid
5341
5428
  */
5342
5429
  isOnGrid(t, e = 1e-3) {
5343
- const n = this.getGridSize(), r = t / n;
5344
- return Math.abs(r - Math.round(r)) < e / n;
5430
+ const s = this.getGridSize(), r = t / s;
5431
+ return Math.abs(r - Math.round(r)) < e / s;
5345
5432
  }
5346
5433
  /**
5347
5434
  * Get current settings
@@ -5357,26 +5444,26 @@ class Sn {
5357
5444
  };
5358
5445
  }
5359
5446
  }
5360
- function Is(i = {}) {
5361
- return new Sn(i);
5447
+ function In(i = {}) {
5448
+ return new bs(i);
5362
5449
  }
5363
- class wn {
5450
+ class Ss {
5364
5451
  constructor(t = {}) {
5365
5452
  const {
5366
5453
  frequency: e = "4n",
5367
- type: n = "sine",
5454
+ type: s = "sine",
5368
5455
  min: r = 0,
5369
- max: s = 1,
5456
+ max: n = 1,
5370
5457
  depth: a = 1,
5371
5458
  phase: o = 0,
5372
5459
  sync: u = !0,
5373
5460
  autostart: l = !1
5374
5461
  } = t;
5375
- this.baseMin = r, this.baseMax = s, this.depth = Math.max(0, Math.min(1, a)), this.targets = /* @__PURE__ */ new Map(), this.isRunning = !1, this.isSynced = u;
5376
- const c = s - r, h = (r + s) / 2, d = c * this.depth;
5462
+ this.baseMin = r, this.baseMax = n, this.depth = Math.max(0, Math.min(1, a)), this.targets = /* @__PURE__ */ new Map(), this.isRunning = !1, this.isSynced = u;
5463
+ const c = n - r, h = (r + n) / 2, d = c * this.depth;
5377
5464
  this.lfo = new me({
5378
5465
  frequency: e,
5379
- type: n,
5466
+ type: s,
5380
5467
  min: h - d / 2,
5381
5468
  max: h + d / 2,
5382
5469
  phase: o
@@ -5438,8 +5525,8 @@ class wn {
5438
5525
  * Update the LFO range based on depth
5439
5526
  */
5440
5527
  updateRange() {
5441
- const t = this.baseMax - this.baseMin, e = (this.baseMin + this.baseMax) / 2, n = t * this.depth;
5442
- this.lfo.min = e - n / 2, this.lfo.max = e + n / 2;
5528
+ const t = this.baseMax - this.baseMin, e = (this.baseMin + this.baseMax) / 2, s = t * this.depth;
5529
+ this.lfo.min = e - s / 2, this.lfo.max = e + s / 2;
5443
5530
  }
5444
5531
  /**
5445
5532
  * Set phase offset in degrees
@@ -5487,10 +5574,10 @@ class wn {
5487
5574
  this.stop(), this.lfo.dispose(), this.targets.clear();
5488
5575
  }
5489
5576
  }
5490
- function xs(i = {}) {
5491
- return new wn(i);
5577
+ function xn(i = {}) {
5578
+ return new Ss(i);
5492
5579
  }
5493
- class kn {
5580
+ class ws {
5494
5581
  constructor(t = {}) {
5495
5582
  const { smoothing: e = 0.8 } = t;
5496
5583
  this.input = new C(), this.meter = new te({ smoothing: e }), this.input.connect(this.meter), this.callbacks = /* @__PURE__ */ new Set(), this.pollInterval = null, this.lastValue = 0;
@@ -5533,7 +5620,7 @@ class kn {
5533
5620
  startPolling(t = 16) {
5534
5621
  return this.pollInterval !== null && this.stopPolling(), this.pollInterval = window.setInterval(() => {
5535
5622
  const e = this.getValue();
5536
- Math.abs(e - this.lastValue) > 1e-3 && (this.lastValue = e, this.callbacks.forEach((n) => n(e)));
5623
+ Math.abs(e - this.lastValue) > 1e-3 && (this.lastValue = e, this.callbacks.forEach((s) => s(e)));
5537
5624
  }, t), this;
5538
5625
  }
5539
5626
  /**
@@ -5561,17 +5648,17 @@ class kn {
5561
5648
  this.stopPolling(), this.callbacks.clear(), this.meter.dispose(), this.input.dispose();
5562
5649
  }
5563
5650
  }
5564
- function Es(i) {
5565
- return new kn(i);
5651
+ function En(i) {
5652
+ return new ws(i);
5566
5653
  }
5567
- class Tn {
5654
+ class ks {
5568
5655
  constructor(t = {}) {
5569
- const { outputs: e = 2, initialGain: n = 1 } = t;
5656
+ const { outputs: e = 2, initialGain: s = 1 } = t;
5570
5657
  this.numOutputs = e, this.input = new C(), this.channels = [];
5571
5658
  for (let r = 0; r < e; r++) {
5572
- const s = new C(n);
5573
- this.input.connect(s), this.channels.push({
5574
- gain: s,
5659
+ const n = new C(s);
5660
+ this.input.connect(n), this.channels.push({
5661
+ gain: n,
5575
5662
  destinations: /* @__PURE__ */ new Set()
5576
5663
  });
5577
5664
  }
@@ -5594,8 +5681,8 @@ class Tn {
5594
5681
  connectOutput(t, e) {
5595
5682
  if (t < 0 || t >= this.numOutputs)
5596
5683
  throw new Error(`Invalid channel index: ${t}`);
5597
- const n = this.channels[t];
5598
- return n.gain.connect(e), n.destinations.add(e), this;
5684
+ const s = this.channels[t];
5685
+ return s.gain.connect(e), s.destinations.add(e), this;
5599
5686
  }
5600
5687
  /**
5601
5688
  * Disconnect an output channel from a destination
@@ -5603,8 +5690,8 @@ class Tn {
5603
5690
  disconnectOutput(t, e) {
5604
5691
  if (t < 0 || t >= this.numOutputs)
5605
5692
  throw new Error(`Invalid channel index: ${t}`);
5606
- const n = this.channels[t];
5607
- return e ? (n.gain.disconnect(e), n.destinations.delete(e)) : (n.gain.disconnect(), n.destinations.clear()), this;
5693
+ const s = this.channels[t];
5694
+ return e ? (s.gain.disconnect(e), s.destinations.delete(e)) : (s.gain.disconnect(), s.destinations.clear()), this;
5608
5695
  }
5609
5696
  /**
5610
5697
  * Set gain for an output channel
@@ -5617,28 +5704,28 @@ class Tn {
5617
5704
  /**
5618
5705
  * Ramp gain for an output channel
5619
5706
  */
5620
- rampGain(t, e, n) {
5707
+ rampGain(t, e, s) {
5621
5708
  if (t < 0 || t >= this.numOutputs)
5622
5709
  throw new Error(`Invalid channel index: ${t}`);
5623
- return this.channels[t].gain.gain.rampTo(e, n), this;
5710
+ return this.channels[t].gain.gain.rampTo(e, s), this;
5624
5711
  }
5625
5712
  /**
5626
5713
  * Set gains for all channels at once
5627
5714
  */
5628
5715
  setGains(t) {
5629
- return t.forEach((e, n) => {
5630
- n < this.numOutputs && (this.channels[n].gain.gain.value = e);
5716
+ return t.forEach((e, s) => {
5717
+ s < this.numOutputs && (this.channels[s].gain.gain.value = e);
5631
5718
  }), this;
5632
5719
  }
5633
5720
  /**
5634
5721
  * Crossfade between two channels
5635
5722
  */
5636
- crossfade(t, e, n, r = 0) {
5723
+ crossfade(t, e, s, r = 0) {
5637
5724
  if (t < 0 || t >= this.numOutputs)
5638
5725
  throw new Error(`Invalid fromChannel: ${t}`);
5639
5726
  if (e < 0 || e >= this.numOutputs)
5640
5727
  throw new Error(`Invalid toChannel: ${e}`);
5641
- const s = Math.max(0, Math.min(1, n)), a = Math.cos(s * Math.PI * 0.5), o = Math.sin(s * Math.PI * 0.5);
5728
+ const n = Math.max(0, Math.min(1, s)), a = Math.cos(n * Math.PI * 0.5), o = Math.sin(n * Math.PI * 0.5);
5642
5729
  return r > 0 ? (this.channels[t].gain.gain.rampTo(a, r), this.channels[e].gain.gain.rampTo(o, r)) : (this.channels[t].gain.gain.value = a, this.channels[e].gain.gain.value = o), this;
5643
5730
  }
5644
5731
  /**
@@ -5711,16 +5798,16 @@ class Tn {
5711
5798
  }), this.channels = [], this.input.disconnect(), this.input.dispose();
5712
5799
  }
5713
5800
  }
5714
- function Ps(i) {
5715
- return new Tn(i);
5801
+ function Pn(i) {
5802
+ return new ks(i);
5716
5803
  }
5717
- class Cn {
5804
+ class Ts {
5718
5805
  constructor(t = {}) {
5719
- const { smoothing: e = 0.8, peakHoldTime: n = 1500, peakDecayTime: r = 3e3, normalRange: s = !0 } = t;
5806
+ const { smoothing: e = 0.8, peakHoldTime: s = 1500, peakDecayTime: r = 3e3, normalRange: n = !0 } = t;
5720
5807
  this.meter = new te({
5721
5808
  smoothing: e,
5722
- normalRange: s
5723
- }), this.peakLevel = -1 / 0, this.peakHoldTime = n, this.peakDecayTime = r, this.peakTimestamp = 0, this.callbacks = /* @__PURE__ */ new Set(), this.pollInterval = null, this.isClipping = !1, this.clipTimeout = null;
5809
+ normalRange: n
5810
+ }), this.peakLevel = -1 / 0, this.peakHoldTime = s, this.peakDecayTime = r, this.peakTimestamp = 0, this.callbacks = /* @__PURE__ */ new Set(), this.pollInterval = null, this.isClipping = !1, this.clipTimeout = null;
5724
5811
  }
5725
5812
  /**
5726
5813
  * Connect an audio source to meter
@@ -5741,22 +5828,22 @@ class Cn {
5741
5828
  const t = this.meter.getValue();
5742
5829
  let e;
5743
5830
  Array.isArray(t) ? e = Math.max(...t) : e = t;
5744
- const n = e, r = Date.now();
5745
- if (n > this.peakLevel)
5746
- this.peakLevel = n, this.peakTimestamp = r;
5831
+ const s = e, r = Date.now();
5832
+ if (s > this.peakLevel)
5833
+ this.peakLevel = s, this.peakTimestamp = r;
5747
5834
  else if (r - this.peakTimestamp > this.peakHoldTime) {
5748
5835
  const a = (r - this.peakTimestamp - this.peakHoldTime) / this.peakDecayTime;
5749
- this.peakLevel = Math.max(n, this.peakLevel - a * 60);
5836
+ this.peakLevel = Math.max(s, this.peakLevel - a * 60);
5750
5837
  }
5751
- n > -0.1 && (this.isClipping = !0, this.clipTimeout && clearTimeout(this.clipTimeout), this.clipTimeout = window.setTimeout(() => {
5838
+ s > -0.1 && (this.isClipping = !0, this.clipTimeout && clearTimeout(this.clipTimeout), this.clipTimeout = window.setTimeout(() => {
5752
5839
  this.isClipping = !1;
5753
5840
  }, 1e3));
5754
- const s = Math.max(0, Math.min(1, (n + 60) / 60));
5841
+ const n = Math.max(0, Math.min(1, (s + 60) / 60));
5755
5842
  return {
5756
- level: n,
5843
+ level: s,
5757
5844
  peak: this.peakLevel,
5758
5845
  clipping: this.isClipping,
5759
- normalized: s
5846
+ normalized: n
5760
5847
  };
5761
5848
  }
5762
5849
  /**
@@ -5784,7 +5871,7 @@ class Cn {
5784
5871
  startPolling(t = 50) {
5785
5872
  return this.pollInterval !== null && this.stopPolling(), this.pollInterval = window.setInterval(() => {
5786
5873
  const e = this.getReading();
5787
- this.callbacks.forEach((n) => n(e));
5874
+ this.callbacks.forEach((s) => s(e));
5788
5875
  }, t), this;
5789
5876
  }
5790
5877
  /**
@@ -5818,15 +5905,15 @@ class Cn {
5818
5905
  this.stopPolling(), this.clipTimeout && clearTimeout(this.clipTimeout), this.callbacks.clear(), this.meter.dispose();
5819
5906
  }
5820
5907
  }
5821
- function Fs(i) {
5822
- return new Cn(i);
5908
+ function Fn(i) {
5909
+ return new Ts(i);
5823
5910
  }
5824
- class Mn {
5911
+ class Cs {
5825
5912
  constructor(t = {}) {
5826
- const { size: e = 1024, smoothing: n = 0.8 } = t;
5913
+ const { size: e = 1024, smoothing: s = 0.8 } = t;
5827
5914
  this.size = e, this.fft = new ge({
5828
5915
  size: e,
5829
- smoothing: n
5916
+ smoothing: s
5830
5917
  }), this.callbacks = /* @__PURE__ */ new Set(), this.pollInterval = null, this.sampleRate = 44100;
5831
5918
  }
5832
5919
  /**
@@ -5853,18 +5940,18 @@ class Mn {
5853
5940
  */
5854
5941
  getNormalizedData() {
5855
5942
  const t = this.fft.getValue(), e = new Float32Array(t.length);
5856
- for (let n = 0; n < t.length; n++)
5857
- e[n] = Math.max(0, Math.min(1, (t[n] + 100) / 100));
5943
+ for (let s = 0; s < t.length; s++)
5944
+ e[s] = Math.max(0, Math.min(1, (t[s] + 100) / 100));
5858
5945
  return e;
5859
5946
  }
5860
5947
  /**
5861
5948
  * Get frequency bands with magnitudes
5862
5949
  */
5863
5950
  getFrequencyBands() {
5864
- const t = this.fft.getValue(), e = [], n = this.sampleRate / this.size;
5951
+ const t = this.fft.getValue(), e = [], s = this.sampleRate / this.size;
5865
5952
  for (let r = 0; r < t.length; r++) {
5866
- const s = r * n, a = t[r], o = Math.max(0, Math.min(1, (a + 100) / 100));
5867
- e.push({ frequency: s, magnitude: a, normalized: o });
5953
+ const n = r * s, a = t[r], o = Math.max(0, Math.min(1, (a + 100) / 100));
5954
+ e.push({ frequency: n, magnitude: a, normalized: o });
5868
5955
  }
5869
5956
  return e;
5870
5957
  }
@@ -5872,19 +5959,19 @@ class Mn {
5872
5959
  * Get the magnitude at a specific frequency
5873
5960
  */
5874
5961
  getMagnitudeAtFrequency(t) {
5875
- const e = this.sampleRate / this.size, n = Math.round(t / e), r = this.fft.getValue();
5876
- return n >= 0 && n < r.length ? r[n] : -1 / 0;
5962
+ const e = this.sampleRate / this.size, s = Math.round(t / e), r = this.fft.getValue();
5963
+ return s >= 0 && s < r.length ? r[s] : -1 / 0;
5877
5964
  }
5878
5965
  /**
5879
5966
  * Get the peak frequency
5880
5967
  */
5881
5968
  getPeakFrequency() {
5882
5969
  const t = this.fft.getValue(), e = this.sampleRate / this.size;
5883
- let n = 0, r = t[0];
5884
- for (let s = 1; s < t.length; s++)
5885
- t[s] > r && (r = t[s], n = s);
5970
+ let s = 0, r = t[0];
5971
+ for (let n = 1; n < t.length; n++)
5972
+ t[n] > r && (r = t[n], s = n);
5886
5973
  return {
5887
- frequency: n * e,
5974
+ frequency: s * e,
5888
5975
  magnitude: r
5889
5976
  };
5890
5977
  }
@@ -5892,12 +5979,12 @@ class Mn {
5892
5979
  * Get average magnitude in a frequency range
5893
5980
  */
5894
5981
  getAverageInRange(t, e) {
5895
- const n = this.fft.getValue(), r = this.sampleRate / this.size, s = Math.max(0, Math.floor(t / r)), a = Math.min(n.length - 1, Math.ceil(e / r));
5896
- if (s >= a) return -1 / 0;
5982
+ const s = this.fft.getValue(), r = this.sampleRate / this.size, n = Math.max(0, Math.floor(t / r)), a = Math.min(s.length - 1, Math.ceil(e / r));
5983
+ if (n >= a) return -1 / 0;
5897
5984
  let o = 0;
5898
- for (let u = s; u <= a; u++)
5899
- o += n[u];
5900
- return o / (a - s + 1);
5985
+ for (let u = n; u <= a; u++)
5986
+ o += s[u];
5987
+ return o / (a - n + 1);
5901
5988
  }
5902
5989
  /**
5903
5990
  * Get common frequency band averages
@@ -5918,7 +6005,7 @@ class Mn {
5918
6005
  startPolling(t = 50) {
5919
6006
  return this.pollInterval !== null && this.stopPolling(), this.pollInterval = window.setInterval(() => {
5920
6007
  const e = this.getFrequencyData();
5921
- this.callbacks.forEach((n) => n(e));
6008
+ this.callbacks.forEach((s) => s(e));
5922
6009
  }, t), this;
5923
6010
  }
5924
6011
  /**
@@ -5952,10 +6039,10 @@ class Mn {
5952
6039
  this.stopPolling(), this.callbacks.clear(), this.fft.dispose();
5953
6040
  }
5954
6041
  }
5955
- function As(i) {
5956
- return new Mn(i);
6042
+ function An(i) {
6043
+ return new Cs(i);
5957
6044
  }
5958
- class _n {
6045
+ class _s {
5959
6046
  constructor(t = {}) {
5960
6047
  const { size: e = 1024 } = t;
5961
6048
  this.size = e, this.waveform = new ye(e), this.callbacks = /* @__PURE__ */ new Set(), this.pollInterval = null;
@@ -5983,8 +6070,8 @@ class _n {
5983
6070
  */
5984
6071
  getNormalizedData() {
5985
6072
  const t = this.waveform.getValue(), e = new Float32Array(t.length);
5986
- for (let n = 0; n < t.length; n++)
5987
- e[n] = (t[n] + 1) / 2;
6073
+ for (let s = 0; s < t.length; s++)
6074
+ e[s] = (t[s] + 1) / 2;
5988
6075
  return e;
5989
6076
  }
5990
6077
  /**
@@ -5992,15 +6079,15 @@ class _n {
5992
6079
  */
5993
6080
  getStats() {
5994
6081
  const t = this.waveform.getValue();
5995
- let e = -1 / 0, n = 1 / 0, r = 0, s = 0, a = t[0] >= 0;
6082
+ let e = -1 / 0, s = 1 / 0, r = 0, n = 0, a = t[0] >= 0;
5996
6083
  for (let u = 0; u < t.length; u++) {
5997
6084
  const l = t[u];
5998
- l > e && (e = l), l < n && (n = l), r += l * l;
6085
+ l > e && (e = l), l < s && (s = l), r += l * l;
5999
6086
  const c = l >= 0;
6000
- c !== a && s++, a = c;
6087
+ c !== a && n++, a = c;
6001
6088
  }
6002
6089
  const o = Math.sqrt(r / t.length);
6003
- return { peak: e, trough: n, rms: o, zeroCrossings: s };
6090
+ return { peak: e, trough: s, rms: o, zeroCrossings: n };
6004
6091
  }
6005
6092
  /**
6006
6093
  * Get downsampled waveform for smaller displays
@@ -6009,29 +6096,29 @@ class _n {
6009
6096
  const e = this.waveform.getValue();
6010
6097
  if (t >= e.length)
6011
6098
  return e;
6012
- const n = new Float32Array(t), r = e.length / t;
6013
- for (let s = 0; s < t; s++) {
6014
- const a = Math.floor(s * r), o = Math.min(Math.floor((s + 1) * r), e.length);
6099
+ const s = new Float32Array(t), r = e.length / t;
6100
+ for (let n = 0; n < t; n++) {
6101
+ const a = Math.floor(n * r), o = Math.min(Math.floor((n + 1) * r), e.length);
6015
6102
  let u = -1 / 0;
6016
6103
  for (let l = a; l < o; l++)
6017
6104
  Math.abs(e[l]) > u && (u = e[l]);
6018
- n[s] = u;
6105
+ s[n] = u;
6019
6106
  }
6020
- return n;
6107
+ return s;
6021
6108
  }
6022
6109
  /**
6023
6110
  * Get min/max pairs for drawing filled waveforms
6024
6111
  */
6025
6112
  getMinMaxPairs(t) {
6026
- const e = this.waveform.getValue(), n = new Float32Array(t), r = new Float32Array(t), s = e.length / t;
6113
+ const e = this.waveform.getValue(), s = new Float32Array(t), r = new Float32Array(t), n = e.length / t;
6027
6114
  for (let a = 0; a < t; a++) {
6028
- const o = Math.floor(a * s), u = Math.min(Math.floor((a + 1) * s), e.length);
6115
+ const o = Math.floor(a * n), u = Math.min(Math.floor((a + 1) * n), e.length);
6029
6116
  let l = 1 / 0, c = -1 / 0;
6030
6117
  for (let h = o; h < u; h++)
6031
6118
  e[h] < l && (l = e[h]), e[h] > c && (c = e[h]);
6032
- n[a] = l, r[a] = c;
6119
+ s[a] = l, r[a] = c;
6033
6120
  }
6034
- return { min: n, max: r };
6121
+ return { min: s, max: r };
6035
6122
  }
6036
6123
  /**
6037
6124
  * Start polling waveform data
@@ -6039,7 +6126,7 @@ class _n {
6039
6126
  startPolling(t = 50) {
6040
6127
  return this.pollInterval !== null && this.stopPolling(), this.pollInterval = window.setInterval(() => {
6041
6128
  const e = this.getWaveformData();
6042
- this.callbacks.forEach((n) => n(e));
6129
+ this.callbacks.forEach((s) => s(e));
6043
6130
  }, t), this;
6044
6131
  }
6045
6132
  /**
@@ -6067,38 +6154,38 @@ class _n {
6067
6154
  this.stopPolling(), this.callbacks.clear(), this.waveform.dispose();
6068
6155
  }
6069
6156
  }
6070
- function Ns(i) {
6071
- return new _n(i);
6157
+ function Nn(i) {
6158
+ return new _s(i);
6072
6159
  }
6073
6160
  export {
6074
- Bs as AMOscillator,
6075
- Ds as AMSynth,
6076
- Gs as Abs,
6077
- Rs as Add,
6078
- Vs as AmplitudeEnvelope,
6079
- qs as Analyser,
6080
- Cn as AudioMeter,
6081
- Ls as AutoFilter,
6082
- zs as AutoPanner,
6083
- $s as AutoWah,
6084
- js as BiquadFilter,
6085
- Hs as BitCrusher,
6086
- Ws as Channel,
6087
- Js as Chebyshev,
6088
- Ks as Chorus,
6089
- Xs as Compressor,
6090
- Zs as Convolver,
6091
- Qs as CrossFade,
6092
- Ys as DCMeter,
6161
+ Un as AMOscillator,
6162
+ Bn as AMSynth,
6163
+ Dn as Abs,
6164
+ Rn as Add,
6165
+ Vn as AmplitudeEnvelope,
6166
+ qn as Analyser,
6167
+ Ts as AudioMeter,
6168
+ Ln as AutoFilter,
6169
+ zn as AutoPanner,
6170
+ $n as AutoWah,
6171
+ jn as BiquadFilter,
6172
+ Hn as BitCrusher,
6173
+ Wn as Channel,
6174
+ Jn as Chebyshev,
6175
+ Kn as Chorus,
6176
+ Xn as Compressor,
6177
+ Zn as Convolver,
6178
+ Qn as CrossFade,
6179
+ Yn as DCMeter,
6093
6180
  tr as Distortion,
6094
6181
  er as Draw,
6095
- nr as DuoSynth,
6096
- sr as EQ3,
6097
- gn as EffectChain,
6098
- yn as EffectRack,
6182
+ sr as DuoSynth,
6183
+ nr as EQ3,
6184
+ ms as EffectChain,
6185
+ gs as EffectRack,
6099
6186
  rr as Envelope,
6100
- kn as EnvelopeFollower,
6101
- hn as EventBus,
6187
+ ws as EnvelopeFollower,
6188
+ ls as EventBus,
6102
6189
  ir as FFT,
6103
6190
  ar as FMOscillator,
6104
6191
  or as FMSynth,
@@ -6114,33 +6201,33 @@ export {
6114
6201
  yr as GrainPlayer,
6115
6202
  vr as GreaterThan,
6116
6203
  br as GreaterThanZero,
6117
- ks as InstrumentTrack,
6204
+ kn as InstrumentTrack,
6118
6205
  be as InteractionState,
6119
6206
  Sr as JCReverb,
6120
6207
  wr as LFO,
6121
- wn as LFOModulator,
6208
+ Ss as LFOModulator,
6122
6209
  kr as Limiter,
6123
6210
  Tr as Loop,
6124
6211
  Cr as LowpassCombFilter,
6125
- Pn as MAX_CANVAS_WIDTH,
6126
- ms as MIDI_CC,
6127
- ps as MIDI_COMMANDS,
6128
- Mr as MembraneSynth,
6129
- _r as Merge,
6212
+ Es as MAX_CANVAS_WIDTH,
6213
+ mn as MIDI_CC,
6214
+ pn as MIDI_COMMANDS,
6215
+ _r as MembraneSynth,
6216
+ Mr as Merge,
6130
6217
  Ir as MetalSynth,
6131
6218
  xr as Meter,
6132
6219
  Er as MidSideCompressor,
6133
6220
  Pr as MidSideMerge,
6134
6221
  Fr as MidSideSplit,
6135
6222
  Ar as Midi,
6136
- gs as MidiController,
6137
- Be as MidiToneTrack,
6223
+ gn as MidiController,
6224
+ Ue as MidiToneTrack,
6138
6225
  Nr as Mono,
6139
6226
  Or as MonoSynth,
6140
- Ur as MultibandCompressor,
6141
- Br as MultibandSplit,
6142
- Dr as Multiply,
6143
- Gr as Negate,
6227
+ Gr as MultibandCompressor,
6228
+ Ur as MultibandSplit,
6229
+ Br as Multiply,
6230
+ Dr as Negate,
6144
6231
  Rr as NoiseSynth,
6145
6232
  Vr as OnePoleFilter,
6146
6233
  qr as Oscillator,
@@ -6158,131 +6245,131 @@ export {
6158
6245
  Qr as Players,
6159
6246
  Pe as PlaylistEngine,
6160
6247
  Yr as PluckSynth,
6161
- dn as PluginHost,
6248
+ hs as PluginHost,
6162
6249
  ti as PolySynth,
6163
6250
  ei as Pow,
6164
- ni as PulseOscillator,
6165
- Sn as Quantizer,
6166
- si as Reverb,
6251
+ si as PulseOscillator,
6252
+ bs as Quantizer,
6253
+ ni as Reverb,
6167
6254
  ri as Sampler,
6168
- pn as SamplerInstrument,
6255
+ fs as SamplerInstrument,
6169
6256
  ii as Scale,
6170
6257
  ai as ScaleExp,
6171
6258
  oi as Sequence,
6172
6259
  ci as Signal,
6173
- Tn as SignalRouter,
6260
+ ks as SignalRouter,
6174
6261
  ui as Solo,
6175
- fn as SongramEngine,
6176
- ns as SoundFontCache,
6262
+ ds as SongramEngine,
6263
+ en as SoundFontCache,
6177
6264
  ot as SoundFontToneTrack,
6178
- Mn as SpectrumAnalyzer,
6265
+ Cs as SpectrumAnalyzer,
6179
6266
  li as Split,
6180
- vn as StepSequencer,
6267
+ ys as StepSequencer,
6181
6268
  hi as StereoWidener,
6182
6269
  di as Subtract,
6183
6270
  fi as Synth,
6184
6271
  pi as Ticks,
6185
6272
  mi as Time,
6186
6273
  gi as ToneEvent,
6187
- De as TonePlayout,
6274
+ Be as TonePlayout,
6188
6275
  Oe as ToneTrack,
6189
6276
  yi as ToneTransport,
6190
- bn as TransportSync,
6277
+ vs as TransportSync,
6191
6278
  vi as TransportTime,
6192
6279
  bi as Tremolo,
6193
6280
  Si as Vibrato,
6194
6281
  wi as Volume,
6195
6282
  ki as WaveShaper,
6196
6283
  Ti as Waveform,
6197
- _n as WaveformDisplay,
6284
+ _s as WaveformDisplay,
6198
6285
  wt as applyFadeIn,
6199
6286
  kt as applyFadeOut,
6200
6287
  Q as calculateDuration,
6201
6288
  Ve as calculatePlaybackRate,
6202
- Zn as calculateSplitPoint,
6203
- Qn as calculateViewportBounds,
6204
- es as calculateZoomScrollPosition,
6205
- Me as canSplitAt,
6289
+ Xs as calculateSplitPoint,
6290
+ Zs as calculateViewportBounds,
6291
+ tn as calculateZoomScrollPosition,
6292
+ _e as canSplitAt,
6206
6293
  yt as clampSeekPosition,
6207
6294
  gt as clipDurationTime,
6208
6295
  pt as clipEndTime,
6209
6296
  mt as clipOffsetTime,
6210
- Xn as clipPixelWidth,
6297
+ Ks as clipPixelWidth,
6211
6298
  H as clipStartTime,
6212
- Bn as clipsOverlap,
6213
- os as closeGlobalAudioContext,
6299
+ Gs as clipsOverlap,
6300
+ on as closeGlobalAudioContext,
6214
6301
  Te as constrainBoundaryTrim,
6215
6302
  ke as constrainClipDrag,
6216
- Fs as createAudioMeter,
6303
+ Fn as createAudioMeter,
6217
6304
  it as createClip,
6218
- Fn as createClipFromSeconds,
6219
- bs as createControlChange,
6220
- Ts as createEffectChain,
6221
- Cs as createEffectRack,
6222
- Es as createEnvelopeFollower,
6223
- xs as createLFOModulator,
6224
- vs as createNoteOff,
6225
- ys as createNoteOn,
6226
- Is as createQuantizer,
6227
- ws as createSamplerFromUrls,
6228
- Ps as createSignalRouter,
6229
- Ss as createSongramEngine,
6230
- As as createSpectrumAnalyzer,
6231
- Ms as createStepSequencer,
6232
- Nn as createTimeline,
6305
+ Ps as createClipFromSeconds,
6306
+ bn as createControlChange,
6307
+ Tn as createEffectChain,
6308
+ Cn as createEffectRack,
6309
+ En as createEnvelopeFollower,
6310
+ xn as createLFOModulator,
6311
+ vn as createNoteOff,
6312
+ yn as createNoteOn,
6313
+ In as createQuantizer,
6314
+ wn as createSamplerFromUrls,
6315
+ Pn as createSignalRouter,
6316
+ Sn as createSongramEngine,
6317
+ An as createSpectrumAnalyzer,
6318
+ _n as createStepSequencer,
6319
+ As as createTimeline,
6233
6320
  Le as createToneAdapter,
6234
- An as createTrack,
6235
- _s as createTransportSync,
6236
- Ns as createWaveformDisplay,
6321
+ Fs as createTrack,
6322
+ Mn as createTransportSync,
6323
+ Nn as createWaveformDisplay,
6237
6324
  we as dBToNormalized,
6238
6325
  qe as extractLoopAndEnvelope,
6239
- _e as findClosestZoomIndex,
6240
- Dn as findGaps,
6241
- Kn as gainToNormalized,
6242
- Un as getClipsAtSample,
6243
- On as getClipsInRange,
6326
+ Me as findClosestZoomIndex,
6327
+ Us as findGaps,
6328
+ Js as gainToNormalized,
6329
+ Os as getClipsAtSample,
6330
+ Ns as getClipsInRange,
6244
6331
  Ci as getDraw,
6245
- _ as getGeneratorValue,
6246
- ss as getGlobalAudioContext,
6247
- as as getGlobalAudioContextState,
6332
+ M as getGeneratorValue,
6333
+ sn as getGlobalAudioContext,
6334
+ an as getGlobalAudioContextState,
6248
6335
  ht as getGlobalContext,
6249
- rs as getGlobalToneContext,
6250
- Gt as getInstrumentName,
6251
- cs as getMediaStreamSource,
6252
- un as getMidiInputs,
6253
- ln as getMidiOutputs,
6254
- Mi as getTransport,
6336
+ nn as getGlobalToneContext,
6337
+ Dt as getInstrumentName,
6338
+ cn as getMediaStreamSource,
6339
+ cs as getMidiInputs,
6340
+ us as getMidiOutputs,
6341
+ _i as getTransport,
6255
6342
  Z as getUnderlyingAudioParam,
6256
- Yn as getVisibleChunkIndices,
6257
- ls as hasMediaStreamSource,
6258
- _i as immediate,
6343
+ Qs as getVisibleChunkIndices,
6344
+ ln as hasMediaStreamSource,
6345
+ Mi as immediate,
6259
6346
  Re as int16ToFloat32,
6260
- on as isWebMidiSupported,
6261
- ds as midiNoteToName,
6262
- Jn as normalizedToDb,
6263
- fs as noteNameToMidi,
6347
+ as as isWebMidiSupported,
6348
+ dn as midiNoteToName,
6349
+ Ws as normalizedToDb,
6350
+ fn as noteNameToMidi,
6264
6351
  Ii as now,
6265
- rn as parseMidiFile,
6266
- an as parseMidiMessage,
6267
- hs as parseMidiUrl,
6268
- qn as pixelsToSamples,
6269
- Ln as pixelsToSeconds,
6270
- us as releaseMediaStreamSource,
6271
- cn as requestMidiAccess,
6272
- is as resumeGlobalAudioContext,
6273
- Vn as samplesToPixels,
6274
- Gn as samplesToSeconds,
6275
- jn as samplesToTicks,
6276
- zn as secondsToPixels,
6277
- Rn as secondsToSamples,
6278
- ts as shouldUpdateViewport,
6279
- Hn as snapToGrid,
6352
+ rs as parseMidiFile,
6353
+ is as parseMidiMessage,
6354
+ hn as parseMidiUrl,
6355
+ Vs as pixelsToSamples,
6356
+ qs as pixelsToSeconds,
6357
+ un as releaseMediaStreamSource,
6358
+ os as requestMidiAccess,
6359
+ rn as resumeGlobalAudioContext,
6360
+ Rs as samplesToPixels,
6361
+ Bs as samplesToSeconds,
6362
+ $s as samplesToTicks,
6363
+ Ls as secondsToPixels,
6364
+ Ds as secondsToSamples,
6365
+ Ys as shouldUpdateViewport,
6366
+ js as snapToGrid,
6280
6367
  at as sortClipsByTime,
6281
6368
  Ce as splitClip,
6282
6369
  Se as ticksPerBar,
6283
- ne as ticksPerBeat,
6284
- Wn as ticksToBarBeatLabel,
6285
- $n as ticksToSamples,
6370
+ se as ticksPerBeat,
6371
+ Hs as ticksToBarBeatLabel,
6372
+ zs as ticksToSamples,
6286
6373
  W as timecentsToSeconds
6287
6374
  };
6288
6375
  //# sourceMappingURL=index.js.map