@songram/songram-daw-engine 3.4.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +784 -778
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/LICENSE.md +0 -21
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Volume as L, Panner as X, Gain as C, getDestination as O, getTransport as
|
|
2
|
-
import { AMOscillator as Bs, AMSynth as Ds, Abs as Gs, Add as
|
|
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";
|
|
3
3
|
import ve from "eventemitter3";
|
|
4
4
|
import { SoundFont2 as ft, GeneratorType as M } from "soundfont2";
|
|
5
5
|
const Pn = 1e3;
|
|
@@ -11,40 +11,40 @@ function it(i) {
|
|
|
11
11
|
gain: r = 1,
|
|
12
12
|
name: s,
|
|
13
13
|
color: a,
|
|
14
|
-
fadeIn:
|
|
14
|
+
fadeIn: o,
|
|
15
15
|
fadeOut: u,
|
|
16
16
|
waveformData: l,
|
|
17
|
-
midiNotes:
|
|
17
|
+
midiNotes: c,
|
|
18
18
|
midiChannel: h,
|
|
19
19
|
midiProgram: d
|
|
20
|
-
} = i, f = t?.sampleRate ?? i.sampleRate ?? l?.sample_rate,
|
|
20
|
+
} = i, f = t?.sampleRate ?? i.sampleRate ?? l?.sample_rate, y = t?.length ?? i.sourceDurationSamples ?? (l && f ? Math.ceil(l.duration * f) : void 0);
|
|
21
21
|
if (f === void 0)
|
|
22
22
|
throw new Error(
|
|
23
23
|
"createClip: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)"
|
|
24
24
|
);
|
|
25
|
-
if (
|
|
25
|
+
if (y === void 0)
|
|
26
26
|
throw new Error(
|
|
27
27
|
"createClip: sourceDurationSamples is required when audioBuffer is not provided (can use waveformData.duration)"
|
|
28
28
|
);
|
|
29
29
|
t && l && t.sampleRate !== l.sample_rate && console.warn(
|
|
30
30
|
`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${l.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`
|
|
31
31
|
);
|
|
32
|
-
const
|
|
32
|
+
const v = i.durationSamples ?? y;
|
|
33
33
|
return {
|
|
34
34
|
id: ee(),
|
|
35
35
|
audioBuffer: t,
|
|
36
36
|
startSample: e,
|
|
37
|
-
durationSamples:
|
|
37
|
+
durationSamples: v,
|
|
38
38
|
offsetSamples: n,
|
|
39
39
|
sampleRate: f,
|
|
40
|
-
sourceDurationSamples:
|
|
40
|
+
sourceDurationSamples: y,
|
|
41
41
|
gain: r,
|
|
42
42
|
name: s,
|
|
43
43
|
color: a,
|
|
44
|
-
fadeIn:
|
|
44
|
+
fadeIn: o,
|
|
45
45
|
fadeOut: u,
|
|
46
46
|
waveformData: l,
|
|
47
|
-
midiNotes:
|
|
47
|
+
midiNotes: c,
|
|
48
48
|
midiChannel: h,
|
|
49
49
|
midiProgram: d
|
|
50
50
|
};
|
|
@@ -57,10 +57,10 @@ function Fn(i) {
|
|
|
57
57
|
gain: r = 1,
|
|
58
58
|
name: s,
|
|
59
59
|
color: a,
|
|
60
|
-
fadeIn:
|
|
60
|
+
fadeIn: o,
|
|
61
61
|
fadeOut: u,
|
|
62
62
|
waveformData: l,
|
|
63
|
-
midiNotes:
|
|
63
|
+
midiNotes: c,
|
|
64
64
|
midiChannel: h,
|
|
65
65
|
midiProgram: d
|
|
66
66
|
} = i, f = t?.sampleRate ?? i.sampleRate ?? l?.sample_rate;
|
|
@@ -68,29 +68,29 @@ function Fn(i) {
|
|
|
68
68
|
throw new Error(
|
|
69
69
|
"createClipFromSeconds: sampleRate is required when audioBuffer is not provided (can use waveformData.sample_rate)"
|
|
70
70
|
);
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
71
|
+
const y = t?.duration ?? i.sourceDuration ?? l?.duration;
|
|
72
|
+
if (y === void 0)
|
|
73
73
|
throw new Error(
|
|
74
74
|
"createClipFromSeconds: sourceDuration is required when audioBuffer is not provided (can use waveformData.duration)"
|
|
75
75
|
);
|
|
76
76
|
t && l && t.sampleRate !== l.sample_rate && console.warn(
|
|
77
77
|
`Sample rate mismatch: audioBuffer (${t.sampleRate}) vs waveformData (${l.sample_rate}). Using audioBuffer sample rate. Waveform visualization may be slightly off.`
|
|
78
78
|
);
|
|
79
|
-
const
|
|
79
|
+
const v = i.duration ?? y;
|
|
80
80
|
return it({
|
|
81
81
|
audioBuffer: t,
|
|
82
82
|
startSample: Math.round(e * f),
|
|
83
|
-
durationSamples: Math.round(
|
|
83
|
+
durationSamples: Math.round(v * f),
|
|
84
84
|
offsetSamples: Math.round(n * f),
|
|
85
85
|
sampleRate: f,
|
|
86
|
-
sourceDurationSamples: Math.ceil(
|
|
86
|
+
sourceDurationSamples: Math.ceil(y * f),
|
|
87
87
|
gain: r,
|
|
88
88
|
name: s,
|
|
89
89
|
color: a,
|
|
90
|
-
fadeIn:
|
|
90
|
+
fadeIn: o,
|
|
91
91
|
fadeOut: u,
|
|
92
92
|
waveformData: l,
|
|
93
|
-
midiNotes:
|
|
93
|
+
midiNotes: c,
|
|
94
94
|
midiChannel: h,
|
|
95
95
|
midiProgram: d
|
|
96
96
|
});
|
|
@@ -103,10 +103,10 @@ function An(i) {
|
|
|
103
103
|
soloed: r = !1,
|
|
104
104
|
volume: s = 1,
|
|
105
105
|
pan: a = 0,
|
|
106
|
-
color:
|
|
106
|
+
color: o,
|
|
107
107
|
height: u,
|
|
108
108
|
spectrogramConfig: l,
|
|
109
|
-
spectrogramColorMap:
|
|
109
|
+
spectrogramColorMap: c
|
|
110
110
|
} = i;
|
|
111
111
|
return {
|
|
112
112
|
id: ee(),
|
|
@@ -116,16 +116,16 @@ function An(i) {
|
|
|
116
116
|
soloed: r,
|
|
117
117
|
volume: s,
|
|
118
118
|
pan: a,
|
|
119
|
-
color:
|
|
119
|
+
color: o,
|
|
120
120
|
height: u,
|
|
121
121
|
spectrogramConfig: l,
|
|
122
|
-
spectrogramColorMap:
|
|
122
|
+
spectrogramColorMap: c
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
function Nn(i, t = 44100, e) {
|
|
126
126
|
const r = i.reduce((s, a) => {
|
|
127
|
-
const
|
|
128
|
-
return Math.max(s,
|
|
127
|
+
const o = a.clips.reduce((u, l) => Math.max(u, l.startSample + l.durationSamples), 0);
|
|
128
|
+
return Math.max(s, o);
|
|
129
129
|
}, 0) / t;
|
|
130
130
|
return {
|
|
131
131
|
tracks: i,
|
|
@@ -175,13 +175,13 @@ var be = /* @__PURE__ */ ((i) => (i.Cursor = "cursor", i.Select = "select", i.Sh
|
|
|
175
175
|
function Gn(i, t) {
|
|
176
176
|
return i / t;
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function Rn(i, t) {
|
|
179
179
|
return Math.ceil(i * t);
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function Vn(i, t) {
|
|
182
182
|
return Math.floor(i / t);
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function qn(i, t) {
|
|
185
185
|
return Math.floor(i * t);
|
|
186
186
|
}
|
|
187
187
|
function Ln(i, t, e) {
|
|
@@ -247,8 +247,8 @@ function ke(i, t, e, n) {
|
|
|
247
247
|
r = Math.max(r, u);
|
|
248
248
|
}
|
|
249
249
|
if (n < e.length - 1) {
|
|
250
|
-
const
|
|
251
|
-
r = Math.min(r,
|
|
250
|
+
const o = e[n + 1].startSample - (i.startSample + i.durationSamples);
|
|
251
|
+
r = Math.min(r, o);
|
|
252
252
|
}
|
|
253
253
|
return r;
|
|
254
254
|
}
|
|
@@ -256,13 +256,13 @@ function Te(i, t, e, n, r, s) {
|
|
|
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
|
|
259
|
+
const o = n[r - 1], u = o.startSample + o.durationSamples;
|
|
260
260
|
a = Math.max(a, u - i.startSample);
|
|
261
261
|
}
|
|
262
262
|
a = Math.min(a, i.durationSamples - s);
|
|
263
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
|
|
265
|
-
a = Math.min(a,
|
|
264
|
+
const o = n[r + 1];
|
|
265
|
+
a = Math.min(a, o.startSample - i.startSample - i.durationSamples);
|
|
266
266
|
}
|
|
267
267
|
return a;
|
|
268
268
|
}
|
|
@@ -282,7 +282,7 @@ function Ce(i, t) {
|
|
|
282
282
|
fadeIn: i.fadeIn,
|
|
283
283
|
audioBuffer: i.audioBuffer,
|
|
284
284
|
waveformData: i.waveformData
|
|
285
|
-
}),
|
|
285
|
+
}), o = it({
|
|
286
286
|
startSample: t,
|
|
287
287
|
durationSamples: n,
|
|
288
288
|
offsetSamples: i.offsetSamples + e,
|
|
@@ -295,7 +295,7 @@ function Ce(i, t) {
|
|
|
295
295
|
audioBuffer: i.audioBuffer,
|
|
296
296
|
waveformData: i.waveformData
|
|
297
297
|
});
|
|
298
|
-
return { left: a, right:
|
|
298
|
+
return { left: a, right: o };
|
|
299
299
|
}
|
|
300
300
|
function Me(i, t, e) {
|
|
301
301
|
const n = i.startSample + i.durationSamples;
|
|
@@ -314,8 +314,8 @@ function Qn(i, t, e = 1.5) {
|
|
|
314
314
|
function Yn(i, t, e, n) {
|
|
315
315
|
const r = Math.ceil(i / t), s = [];
|
|
316
316
|
for (let a = 0; a < r; a++) {
|
|
317
|
-
const
|
|
318
|
-
|
|
317
|
+
const o = a * t, u = Math.min(i - o, t);
|
|
318
|
+
o + u <= e || o >= n || s.push(a);
|
|
319
319
|
}
|
|
320
320
|
return s;
|
|
321
321
|
}
|
|
@@ -402,55 +402,55 @@ class Pe {
|
|
|
402
402
|
// Clip Editing (delegates to operations/)
|
|
403
403
|
// ---------------------------------------------------------------------------
|
|
404
404
|
moveClip(t, e, n) {
|
|
405
|
-
const r = this._tracks.find((
|
|
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((
|
|
410
|
+
const s = r.clips.findIndex((c) => c.id === e);
|
|
411
411
|
if (s === -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],
|
|
418
|
-
l !== 0 && (this._tracks = this._tracks.map((
|
|
419
|
-
if (
|
|
420
|
-
const h =
|
|
417
|
+
const a = r.clips[s], o = at(r.clips), u = o.findIndex((c) => c.id === e), l = ke(a, n, o, u);
|
|
418
|
+
l !== 0 && (this._tracks = this._tracks.map((c) => {
|
|
419
|
+
if (c.id !== t) return c;
|
|
420
|
+
const h = c.clips.map(
|
|
421
421
|
(d, f) => f === s ? {
|
|
422
422
|
...d,
|
|
423
423
|
startSample: Math.floor(d.startSample + l)
|
|
424
424
|
} : d
|
|
425
425
|
);
|
|
426
|
-
return { ...
|
|
426
|
+
return { ...c, clips: h };
|
|
427
427
|
}), this._tracksVersion++, this._adapter?.setTracks(this._tracks), this._emitStateChange());
|
|
428
428
|
}
|
|
429
429
|
splitClip(t, e, n) {
|
|
430
|
-
const r = this._tracks.find((
|
|
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((
|
|
435
|
+
const s = r.clips.findIndex((c) => c.id === e);
|
|
436
436
|
if (s === -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],
|
|
443
|
-
if (!Me(a, n,
|
|
442
|
+
const a = r.clips[s], o = Math.floor(vt * this._sampleRate);
|
|
443
|
+
if (!Me(a, n, 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: ${
|
|
445
|
+
`[songram-daw/engine] splitClip: cannot split clip "${e}" at sample ${n} (clip range: ${a.startSample}–${a.startSample + a.durationSamples}, minDuration: ${o})`
|
|
446
446
|
);
|
|
447
447
|
return;
|
|
448
448
|
}
|
|
449
449
|
const { left: u, right: l } = Ce(a, n);
|
|
450
|
-
this._tracks = this._tracks.map((
|
|
451
|
-
if (
|
|
452
|
-
const h = [...
|
|
453
|
-
return h.splice(s, 1, u, l), { ...
|
|
450
|
+
this._tracks = this._tracks.map((c) => {
|
|
451
|
+
if (c.id !== t) return c;
|
|
452
|
+
const h = [...c.clips];
|
|
453
|
+
return h.splice(s, 1, u, l), { ...c, clips: h };
|
|
454
454
|
}), this._tracksVersion++, this._adapter?.setTracks(this._tracks), this._emitStateChange();
|
|
455
455
|
}
|
|
456
456
|
trimClip(t, e, n, r) {
|
|
@@ -466,22 +466,22 @@ class Pe {
|
|
|
466
466
|
);
|
|
467
467
|
return;
|
|
468
468
|
}
|
|
469
|
-
const
|
|
470
|
-
|
|
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(
|
|
470
|
+
o,
|
|
471
471
|
r,
|
|
472
472
|
n,
|
|
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((
|
|
480
|
-
...
|
|
481
|
-
startSample:
|
|
482
|
-
offsetSamples:
|
|
483
|
-
durationSamples:
|
|
484
|
-
} : { ...
|
|
479
|
+
const f = d.clips.map((y, v) => v !== a ? y : n === "left" ? {
|
|
480
|
+
...y,
|
|
481
|
+
startSample: y.startSample + h,
|
|
482
|
+
offsetSamples: y.offsetSamples + h,
|
|
483
|
+
durationSamples: y.durationSamples - h
|
|
484
|
+
} : { ...y, durationSamples: y.durationSamples + h });
|
|
485
485
|
return { ...d, clips: f };
|
|
486
486
|
}), this._tracksVersion++, this._adapter?.setTracks(this._tracks), this._emitStateChange());
|
|
487
487
|
}
|
|
@@ -698,10 +698,10 @@ function wt(i, t, e, n = "linear", r = 0, s = 1) {
|
|
|
698
698
|
else if (n === "exponential")
|
|
699
699
|
i.setValueAtTime(Math.max(r, 1e-3), t), i.exponentialRampToValueAtTime(Math.max(s, 1e-3), t + e);
|
|
700
700
|
else {
|
|
701
|
-
const a = se(n, 1e4, !0),
|
|
701
|
+
const a = se(n, 1e4, !0), o = new Float32Array(a.length), u = s - r;
|
|
702
702
|
for (let l = 0; l < a.length; l++)
|
|
703
|
-
|
|
704
|
-
i.setValueCurveAtTime(
|
|
703
|
+
o[l] = r + a[l] * u;
|
|
704
|
+
i.setValueCurveAtTime(o, t, e);
|
|
705
705
|
}
|
|
706
706
|
}
|
|
707
707
|
function kt(i, t, e, n = "linear", r = 1, s = 0) {
|
|
@@ -711,10 +711,10 @@ function kt(i, t, e, n = "linear", r = 1, s = 0) {
|
|
|
711
711
|
else if (n === "exponential")
|
|
712
712
|
i.setValueAtTime(Math.max(r, 1e-3), t), i.exponentialRampToValueAtTime(Math.max(s, 1e-3), t + e);
|
|
713
713
|
else {
|
|
714
|
-
const a = se(n, 1e4, !1),
|
|
714
|
+
const a = se(n, 1e4, !1), o = new Float32Array(a.length), u = r - s;
|
|
715
715
|
for (let l = 0; l < a.length; l++)
|
|
716
|
-
|
|
717
|
-
i.setValueCurveAtTime(
|
|
716
|
+
o[l] = s + a[l] * u;
|
|
717
|
+
i.setValueCurveAtTime(o, t, e);
|
|
718
718
|
}
|
|
719
719
|
}
|
|
720
720
|
class Oe {
|
|
@@ -722,8 +722,8 @@ class Oe {
|
|
|
722
722
|
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
723
|
const e = t.destination || O();
|
|
724
724
|
if (t.effects) {
|
|
725
|
-
const
|
|
726
|
-
|
|
725
|
+
const o = t.effects(this.muteGain, e, !1);
|
|
726
|
+
o && (this.effectsCleanup = o);
|
|
727
727
|
} else
|
|
728
728
|
this.muteGain.connect(e);
|
|
729
729
|
const n = t.clips || (t.buffer ? [
|
|
@@ -736,14 +736,14 @@ class Oe {
|
|
|
736
736
|
fadeOut: t.track.fadeOut,
|
|
737
737
|
gain: 1
|
|
738
738
|
}
|
|
739
|
-
] : []), r =
|
|
740
|
-
this.scheduledClips = n.map((
|
|
739
|
+
] : []), r = w(), s = N().rawContext, a = this.volumeNode.input.input;
|
|
740
|
+
this.scheduledClips = n.map((o) => {
|
|
741
741
|
const u = s.createGain();
|
|
742
|
-
u.gain.value =
|
|
743
|
-
const l = this.track.startTime +
|
|
744
|
-
l < this._scheduleGuardOffset || this.startClipSource(
|
|
742
|
+
u.gain.value = o.gain, u.connect(a);
|
|
743
|
+
const l = this.track.startTime + o.startTime, c = r.schedule((h) => {
|
|
744
|
+
l < this._scheduleGuardOffset || this.startClipSource(o, u, h);
|
|
745
745
|
}, l);
|
|
746
|
-
return { clipInfo:
|
|
746
|
+
return { clipInfo: o, fadeGainNode: u, scheduleId: c };
|
|
747
747
|
});
|
|
748
748
|
}
|
|
749
749
|
/**
|
|
@@ -751,20 +751,20 @@ class Oe {
|
|
|
751
751
|
* Sources are one-shot: each play or loop iteration creates a fresh one.
|
|
752
752
|
*/
|
|
753
753
|
startClipSource(t, e, n, r, s) {
|
|
754
|
-
const
|
|
755
|
-
|
|
754
|
+
const o = N().rawContext.createBufferSource();
|
|
755
|
+
o.buffer = t.buffer, o.connect(e);
|
|
756
756
|
const u = r ?? t.offset, l = s ?? t.duration;
|
|
757
757
|
try {
|
|
758
|
-
|
|
759
|
-
} catch (
|
|
758
|
+
o.start(n, u, l);
|
|
759
|
+
} catch (c) {
|
|
760
760
|
console.warn(
|
|
761
761
|
`[songram-daw] Failed to start source on track "${this.id}" (time=${n}, offset=${u}, duration=${l}):`,
|
|
762
|
-
|
|
763
|
-
),
|
|
762
|
+
c
|
|
763
|
+
), o.disconnect();
|
|
764
764
|
return;
|
|
765
765
|
}
|
|
766
|
-
this.activeSources.add(
|
|
767
|
-
this.activeSources.delete(
|
|
766
|
+
this.activeSources.add(o), o.onended = () => {
|
|
767
|
+
this.activeSources.delete(o);
|
|
768
768
|
};
|
|
769
769
|
}
|
|
770
770
|
/**
|
|
@@ -787,7 +787,7 @@ class Oe {
|
|
|
787
787
|
for (const { clipInfo: n, fadeGainNode: r } of this.scheduledClips) {
|
|
788
788
|
const s = this.track.startTime + n.startTime, a = s + n.duration;
|
|
789
789
|
if (s < t && a > t) {
|
|
790
|
-
const
|
|
790
|
+
const o = t - s, u = n.offset + o, l = n.duration - o;
|
|
791
791
|
this.startClipSource(
|
|
792
792
|
n,
|
|
793
793
|
r,
|
|
@@ -819,10 +819,10 @@ class Oe {
|
|
|
819
819
|
scheduleFades(t, e, n = 0) {
|
|
820
820
|
const { clipInfo: r, fadeGainNode: s } = t, a = s.gain;
|
|
821
821
|
a.cancelScheduledValues(0);
|
|
822
|
-
const
|
|
823
|
-
if (r.fadeIn &&
|
|
822
|
+
const o = n - r.offset;
|
|
823
|
+
if (r.fadeIn && o < r.fadeIn.duration) {
|
|
824
824
|
const u = r.fadeIn.duration;
|
|
825
|
-
if (
|
|
825
|
+
if (o <= 0)
|
|
826
826
|
wt(
|
|
827
827
|
a,
|
|
828
828
|
e,
|
|
@@ -832,7 +832,7 @@ class Oe {
|
|
|
832
832
|
r.gain
|
|
833
833
|
);
|
|
834
834
|
else {
|
|
835
|
-
const l = u -
|
|
835
|
+
const l = u - o, c = o / u, h = r.gain * c;
|
|
836
836
|
wt(
|
|
837
837
|
a,
|
|
838
838
|
e,
|
|
@@ -845,19 +845,19 @@ class Oe {
|
|
|
845
845
|
} else
|
|
846
846
|
a.setValueAtTime(r.gain, e);
|
|
847
847
|
if (r.fadeOut) {
|
|
848
|
-
const l = r.duration - r.fadeOut.duration -
|
|
848
|
+
const l = r.duration - r.fadeOut.duration - o;
|
|
849
849
|
if (l > 0) {
|
|
850
|
-
const
|
|
850
|
+
const c = e + l;
|
|
851
851
|
kt(
|
|
852
852
|
a,
|
|
853
|
-
|
|
853
|
+
c,
|
|
854
854
|
r.fadeOut.duration,
|
|
855
855
|
r.fadeOut.type || "linear",
|
|
856
856
|
r.gain,
|
|
857
857
|
0
|
|
858
858
|
);
|
|
859
859
|
} else if (l > -r.fadeOut.duration) {
|
|
860
|
-
const
|
|
860
|
+
const c = -l, h = r.fadeOut.duration - c, d = c / r.fadeOut.duration, f = r.gain * (1 - d);
|
|
861
861
|
kt(
|
|
862
862
|
a,
|
|
863
863
|
e,
|
|
@@ -914,7 +914,7 @@ class Oe {
|
|
|
914
914
|
this.track.soloed = t;
|
|
915
915
|
}
|
|
916
916
|
dispose() {
|
|
917
|
-
const t =
|
|
917
|
+
const t = w();
|
|
918
918
|
if (this.effectsCleanup)
|
|
919
919
|
try {
|
|
920
920
|
this.effectsCleanup();
|
|
@@ -1015,10 +1015,10 @@ class Be {
|
|
|
1015
1015
|
this.muteGain.connect(n);
|
|
1016
1016
|
this.scheduledClips = t.clips.map((r) => {
|
|
1017
1017
|
const s = r.notes.filter((l) => {
|
|
1018
|
-
const
|
|
1019
|
-
return l.time < r.offset + r.duration &&
|
|
1020
|
-
}), a = this.track.startTime + r.startTime,
|
|
1021
|
-
const
|
|
1018
|
+
const c = l.time + l.duration;
|
|
1019
|
+
return l.time < r.offset + r.duration && c > r.offset;
|
|
1020
|
+
}), a = this.track.startTime + r.startTime, o = s.map((l) => {
|
|
1021
|
+
const c = l.time - r.offset, h = Math.max(0, c), d = Math.min(
|
|
1022
1022
|
l.duration - Math.max(0, r.offset - l.time),
|
|
1023
1023
|
r.duration - h
|
|
1024
1024
|
);
|
|
@@ -1030,16 +1030,16 @@ class Be {
|
|
|
1030
1030
|
velocity: l.velocity,
|
|
1031
1031
|
channel: l.channel
|
|
1032
1032
|
};
|
|
1033
|
-
}), u = new lt((l,
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1033
|
+
}), u = new lt((l, c) => {
|
|
1034
|
+
c.duration > 0 && this.triggerNote(
|
|
1035
|
+
c.midi,
|
|
1036
|
+
c.note,
|
|
1037
|
+
c.duration,
|
|
1038
1038
|
l,
|
|
1039
|
-
|
|
1040
|
-
|
|
1039
|
+
c.velocity,
|
|
1040
|
+
c.channel
|
|
1041
1041
|
);
|
|
1042
|
-
},
|
|
1042
|
+
}, o);
|
|
1043
1043
|
return u.start(0), { clipInfo: r, part: u };
|
|
1044
1044
|
});
|
|
1045
1045
|
}
|
|
@@ -1105,14 +1105,14 @@ class Be {
|
|
|
1105
1105
|
const r = this.track.startTime + n.startTime, s = r + n.duration;
|
|
1106
1106
|
if (r < t && s > t)
|
|
1107
1107
|
for (const a of n.notes) {
|
|
1108
|
-
const
|
|
1108
|
+
const o = a.time - n.offset, u = r + Math.max(0, o), l = u + a.duration;
|
|
1109
1109
|
if (u < t && l > t) {
|
|
1110
|
-
const
|
|
1110
|
+
const c = l - t;
|
|
1111
1111
|
try {
|
|
1112
1112
|
this.triggerNote(
|
|
1113
1113
|
a.midi,
|
|
1114
1114
|
a.name,
|
|
1115
|
-
|
|
1115
|
+
c,
|
|
1116
1116
|
e,
|
|
1117
1117
|
a.velocity,
|
|
1118
1118
|
a.channel
|
|
@@ -1131,7 +1131,7 @@ class Be {
|
|
|
1131
1131
|
* Stop all sounding notes and cancel scheduled Part events.
|
|
1132
1132
|
*/
|
|
1133
1133
|
stopAllSources() {
|
|
1134
|
-
const t =
|
|
1134
|
+
const t = N().rawContext.currentTime;
|
|
1135
1135
|
try {
|
|
1136
1136
|
this.synth.releaseAll(t), this.kickSynth.releaseAll(t), this.cymbalSynth.releaseAll(t), this.tomSynth.releaseAll(t);
|
|
1137
1137
|
} catch (e) {
|
|
@@ -1229,7 +1229,7 @@ class Be {
|
|
|
1229
1229
|
return this.track.startTime;
|
|
1230
1230
|
}
|
|
1231
1231
|
}
|
|
1232
|
-
const
|
|
1232
|
+
const q = class q {
|
|
1233
1233
|
constructor(t) {
|
|
1234
1234
|
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
1235
|
const e = t.destination || O();
|
|
@@ -1243,22 +1243,22 @@ const R = class R {
|
|
|
1243
1243
|
const l = u.time + u.duration;
|
|
1244
1244
|
return u.time < n.offset + n.duration && l > n.offset;
|
|
1245
1245
|
}), s = this.track.startTime + n.startTime, a = r.map((u) => {
|
|
1246
|
-
const l = u.time - n.offset,
|
|
1246
|
+
const l = u.time - n.offset, c = Math.max(0, l), h = Math.min(
|
|
1247
1247
|
u.duration - Math.max(0, n.offset - u.time),
|
|
1248
|
-
n.duration -
|
|
1248
|
+
n.duration - c
|
|
1249
1249
|
);
|
|
1250
1250
|
return {
|
|
1251
|
-
time: s +
|
|
1251
|
+
time: s + c,
|
|
1252
1252
|
note: u.name,
|
|
1253
1253
|
midi: u.midi,
|
|
1254
1254
|
duration: Math.max(0, h),
|
|
1255
1255
|
velocity: u.velocity,
|
|
1256
1256
|
channel: u.channel
|
|
1257
1257
|
};
|
|
1258
|
-
}),
|
|
1258
|
+
}), o = new lt((u, l) => {
|
|
1259
1259
|
l.duration > 0 && this.triggerNote(l.midi, l.duration, u, l.velocity, l.channel);
|
|
1260
1260
|
}, a);
|
|
1261
|
-
return
|
|
1261
|
+
return o.start(0), { clipInfo: n, part: o };
|
|
1262
1262
|
});
|
|
1263
1263
|
}
|
|
1264
1264
|
/**
|
|
@@ -1267,26 +1267,26 @@ const R = class R {
|
|
|
1267
1267
|
* Per-note routing: channel 9 → bank 128 (drums), others → bank 0 with programNumber.
|
|
1268
1268
|
*/
|
|
1269
1269
|
triggerNote(t, e, n, r, s) {
|
|
1270
|
-
const a = s === 9 ? 128 : this.bankNumber,
|
|
1270
|
+
const a = s === 9 ? 128 : this.bankNumber, o = s === 9 ? 0 : this.programNumber, u = this.soundFontCache.getAudioBuffer(t, a, o);
|
|
1271
1271
|
if (!u) {
|
|
1272
|
-
|
|
1273
|
-
`[songram-daw] SoundFont sample not found for MIDI note ${t} (bank ${a}, preset ${
|
|
1274
|
-
),
|
|
1272
|
+
q._missingSampleWarned || (console.warn(
|
|
1273
|
+
`[songram-daw] SoundFont sample not found for MIDI note ${t} (bank ${a}, preset ${o}). Subsequent missing samples will be silent.`
|
|
1274
|
+
), q._missingSampleWarned = !0);
|
|
1275
1275
|
return;
|
|
1276
1276
|
}
|
|
1277
|
-
const l =
|
|
1278
|
-
|
|
1279
|
-
const h = u.buffer.duration / u.playbackRate, d = u.loopMode === 0 ? Math.max(e, h) : e, f = r * r,
|
|
1280
|
-
|
|
1281
|
-
const
|
|
1282
|
-
|
|
1283
|
-
this.activeSources.delete(
|
|
1277
|
+
const l = N().rawContext, c = l.createBufferSource();
|
|
1278
|
+
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
|
+
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 = () => {
|
|
1283
|
+
this.activeSources.delete(c);
|
|
1284
1284
|
try {
|
|
1285
|
-
|
|
1285
|
+
y.disconnect();
|
|
1286
1286
|
} catch (T) {
|
|
1287
1287
|
console.warn("[songram-daw] GainNode already disconnected:", T);
|
|
1288
1288
|
}
|
|
1289
|
-
},
|
|
1289
|
+
}, c.start(n), c.stop(n + d + b);
|
|
1290
1290
|
}
|
|
1291
1291
|
gainToDb(t) {
|
|
1292
1292
|
return 20 * Math.log10(t);
|
|
@@ -1304,13 +1304,13 @@ const R = class R {
|
|
|
1304
1304
|
const r = this.track.startTime + n.startTime, s = r + n.duration;
|
|
1305
1305
|
if (r < t && s > t)
|
|
1306
1306
|
for (const a of n.notes) {
|
|
1307
|
-
const
|
|
1307
|
+
const o = a.time - n.offset, u = r + Math.max(0, o), l = u + a.duration;
|
|
1308
1308
|
if (u < t && l > t) {
|
|
1309
|
-
const
|
|
1309
|
+
const c = l - t;
|
|
1310
1310
|
try {
|
|
1311
1311
|
this.triggerNote(
|
|
1312
1312
|
a.midi,
|
|
1313
|
-
|
|
1313
|
+
c,
|
|
1314
1314
|
e,
|
|
1315
1315
|
a.velocity,
|
|
1316
1316
|
a.channel
|
|
@@ -1417,8 +1417,8 @@ const R = class R {
|
|
|
1417
1417
|
return this.track.startTime;
|
|
1418
1418
|
}
|
|
1419
1419
|
};
|
|
1420
|
-
|
|
1421
|
-
let ot =
|
|
1420
|
+
q._missingSampleWarned = !1;
|
|
1421
|
+
let ot = q;
|
|
1422
1422
|
class De {
|
|
1423
1423
|
constructor(t = {}) {
|
|
1424
1424
|
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) {
|
|
@@ -1436,7 +1436,7 @@ class De {
|
|
|
1436
1436
|
clearCompletionEvent() {
|
|
1437
1437
|
if (this._completionEventId !== null) {
|
|
1438
1438
|
try {
|
|
1439
|
-
|
|
1439
|
+
w().clear(this._completionEventId);
|
|
1440
1440
|
} catch (t) {
|
|
1441
1441
|
console.warn("[songram-daw] Error clearing Transport completion event:", t);
|
|
1442
1442
|
}
|
|
@@ -1484,32 +1484,32 @@ class De {
|
|
|
1484
1484
|
play(t, e, n) {
|
|
1485
1485
|
if (!this.isInitialized)
|
|
1486
1486
|
throw new Error("[songram-daw] TonePlayout not initialized. Call init() first.");
|
|
1487
|
-
const r = t ?? rt(), s =
|
|
1487
|
+
const r = t ?? rt(), s = w();
|
|
1488
1488
|
this.clearCompletionEvent();
|
|
1489
1489
|
const a = e ?? 0;
|
|
1490
|
-
this.tracks.forEach((
|
|
1491
|
-
|
|
1490
|
+
this.tracks.forEach((o) => {
|
|
1491
|
+
o.cancelFades(), o.prepareFades(r, a);
|
|
1492
1492
|
}), n !== void 0 && (this._completionEventId = s.scheduleOnce(() => {
|
|
1493
1493
|
this._completionEventId = null;
|
|
1494
1494
|
try {
|
|
1495
1495
|
this.onPlaybackCompleteCallback?.();
|
|
1496
|
-
} catch (
|
|
1497
|
-
console.warn("[songram-daw] Error in playback completion callback:",
|
|
1496
|
+
} catch (o) {
|
|
1497
|
+
console.warn("[songram-daw] Error in playback completion callback:", o);
|
|
1498
1498
|
}
|
|
1499
1499
|
}, a + n));
|
|
1500
1500
|
try {
|
|
1501
|
-
s.state !== "stopped" && s.stop(), this.tracks.forEach((
|
|
1502
|
-
|
|
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) => {
|
|
1502
|
+
o.startMidClipSources(a, r);
|
|
1503
1503
|
});
|
|
1504
|
-
} catch (
|
|
1504
|
+
} catch (o) {
|
|
1505
1505
|
throw this.clearCompletionEvent(), this.tracks.forEach((u) => u.cancelFades()), console.warn(
|
|
1506
1506
|
"[songram-daw] Transport.start() failed. Audio playback could not begin.",
|
|
1507
|
-
|
|
1508
|
-
),
|
|
1507
|
+
o
|
|
1508
|
+
), o;
|
|
1509
1509
|
}
|
|
1510
1510
|
}
|
|
1511
1511
|
pause() {
|
|
1512
|
-
const t =
|
|
1512
|
+
const t = w();
|
|
1513
1513
|
try {
|
|
1514
1514
|
t.pause();
|
|
1515
1515
|
} catch (e) {
|
|
@@ -1518,7 +1518,7 @@ class De {
|
|
|
1518
1518
|
this.tracks.forEach((e) => e.stopAllSources()), this.tracks.forEach((e) => e.cancelFades()), this.clearCompletionEvent();
|
|
1519
1519
|
}
|
|
1520
1520
|
stop() {
|
|
1521
|
-
const t =
|
|
1521
|
+
const t = w();
|
|
1522
1522
|
try {
|
|
1523
1523
|
t.stop();
|
|
1524
1524
|
} catch (e) {
|
|
@@ -1575,7 +1575,7 @@ class De {
|
|
|
1575
1575
|
}
|
|
1576
1576
|
setLoop(t, e, n) {
|
|
1577
1577
|
this._loopEnabled = t, this._loopStart = e, this._loopEnd = n;
|
|
1578
|
-
const r =
|
|
1578
|
+
const r = w();
|
|
1579
1579
|
try {
|
|
1580
1580
|
r.loopStart = e, r.loopEnd = n, r.loop = t;
|
|
1581
1581
|
} catch (s) {
|
|
@@ -1587,20 +1587,20 @@ class De {
|
|
|
1587
1587
|
this.tracks.forEach((a) => {
|
|
1588
1588
|
try {
|
|
1589
1589
|
a.stopAllSources(), a.cancelFades(), a.setScheduleGuardOffset(this._loopStart), a.startMidClipSources(this._loopStart, s), a.prepareFades(s, this._loopStart);
|
|
1590
|
-
} catch (
|
|
1590
|
+
} catch (o) {
|
|
1591
1591
|
console.warn(
|
|
1592
1592
|
`[songram-daw] Error re-scheduling track "${a.id}" on loop:`,
|
|
1593
|
-
|
|
1593
|
+
o
|
|
1594
1594
|
);
|
|
1595
1595
|
}
|
|
1596
1596
|
});
|
|
1597
1597
|
}, r.on("loop", this._loopHandler)) : !t && this._loopHandler && (r.off("loop", this._loopHandler), this._loopHandler = null);
|
|
1598
1598
|
}
|
|
1599
1599
|
getCurrentTime() {
|
|
1600
|
-
return
|
|
1600
|
+
return w().seconds;
|
|
1601
1601
|
}
|
|
1602
1602
|
seekTo(t) {
|
|
1603
|
-
|
|
1603
|
+
w().seconds = t;
|
|
1604
1604
|
}
|
|
1605
1605
|
dispose() {
|
|
1606
1606
|
try {
|
|
@@ -1627,10 +1627,10 @@ class De {
|
|
|
1627
1627
|
}
|
|
1628
1628
|
}
|
|
1629
1629
|
get context() {
|
|
1630
|
-
return
|
|
1630
|
+
return N();
|
|
1631
1631
|
}
|
|
1632
1632
|
get sampleRate() {
|
|
1633
|
-
return
|
|
1633
|
+
return N().sampleRate;
|
|
1634
1634
|
}
|
|
1635
1635
|
setOnPlaybackComplete(t) {
|
|
1636
1636
|
this.onPlaybackCompleteCallback = t;
|
|
@@ -1643,22 +1643,22 @@ const Ge = 5;
|
|
|
1643
1643
|
function _(i, t) {
|
|
1644
1644
|
return i[t]?.value;
|
|
1645
1645
|
}
|
|
1646
|
-
function
|
|
1646
|
+
function Re(i) {
|
|
1647
1647
|
const t = new Float32Array(i.length);
|
|
1648
1648
|
for (let e = 0; e < i.length; e++)
|
|
1649
1649
|
t[e] = i[e] / 32768;
|
|
1650
1650
|
return t;
|
|
1651
1651
|
}
|
|
1652
|
-
function
|
|
1652
|
+
function Ve(i) {
|
|
1653
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;
|
|
1654
1654
|
return Math.pow(2, u / 12);
|
|
1655
1655
|
}
|
|
1656
|
-
function
|
|
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,
|
|
1656
|
+
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
1658
|
_(t, M.AttackVolEnv) ?? -12e3
|
|
1659
1659
|
), l = W(
|
|
1660
1660
|
_(t, M.HoldVolEnv) ?? -12e3
|
|
1661
|
-
),
|
|
1661
|
+
), c = W(
|
|
1662
1662
|
_(t, M.DecayVolEnv) ?? -12e3
|
|
1663
1663
|
), h = Math.min(
|
|
1664
1664
|
W(_(t, M.ReleaseVolEnv) ?? -12e3),
|
|
@@ -1667,10 +1667,10 @@ function Re(i) {
|
|
|
1667
1667
|
return {
|
|
1668
1668
|
loopMode: n,
|
|
1669
1669
|
loopStart: a,
|
|
1670
|
-
loopEnd:
|
|
1670
|
+
loopEnd: o,
|
|
1671
1671
|
attackVolEnv: u,
|
|
1672
1672
|
holdVolEnv: l,
|
|
1673
|
-
decayVolEnv:
|
|
1673
|
+
decayVolEnv: c,
|
|
1674
1674
|
sustainVolEnv: f,
|
|
1675
1675
|
releaseVolEnv: h
|
|
1676
1676
|
};
|
|
@@ -1728,27 +1728,27 @@ class ns {
|
|
|
1728
1728
|
const r = this.sf2.getKeyData(t, e, n);
|
|
1729
1729
|
if (!r) return null;
|
|
1730
1730
|
const s = r.sample, a = this.sf2.samples.indexOf(s);
|
|
1731
|
-
let
|
|
1732
|
-
|
|
1733
|
-
const u =
|
|
1731
|
+
let o = this.audioBufferCache.get(a);
|
|
1732
|
+
o || (o = this.int16ToAudioBuffer(s.data, s.header.sampleRate), this.audioBufferCache.set(a, o));
|
|
1733
|
+
const u = Ve({
|
|
1734
1734
|
midiNote: t,
|
|
1735
1735
|
overrideRootKey: _(r.generators, M.OverridingRootKey),
|
|
1736
1736
|
originalPitch: s.header.originalPitch,
|
|
1737
1737
|
coarseTune: _(r.generators, M.CoarseTune) ?? 0,
|
|
1738
1738
|
fineTune: _(r.generators, M.FineTune) ?? 0,
|
|
1739
1739
|
pitchCorrection: s.header.pitchCorrection ?? 0
|
|
1740
|
-
}), l =
|
|
1740
|
+
}), l = qe({
|
|
1741
1741
|
generators: r.generators,
|
|
1742
1742
|
header: r.sample.header
|
|
1743
1743
|
});
|
|
1744
|
-
return { buffer:
|
|
1744
|
+
return { buffer: o, playbackRate: u, ...l };
|
|
1745
1745
|
}
|
|
1746
1746
|
/**
|
|
1747
1747
|
* Convert Int16Array sample data to an AudioBuffer.
|
|
1748
1748
|
* Uses the extracted int16ToFloat32 for the conversion, then copies into an AudioBuffer.
|
|
1749
1749
|
*/
|
|
1750
1750
|
int16ToAudioBuffer(t, e) {
|
|
1751
|
-
const n =
|
|
1751
|
+
const n = Re(t), r = this.context.createBuffer(1, n.length, e);
|
|
1752
1752
|
return r.getChannelData(0).set(n), r;
|
|
1753
1753
|
}
|
|
1754
1754
|
/**
|
|
@@ -1778,14 +1778,14 @@ function as() {
|
|
|
1778
1778
|
async function os() {
|
|
1779
1779
|
x && x.rawContext.state !== "closed" && (await x.close(), x = null);
|
|
1780
1780
|
}
|
|
1781
|
-
const
|
|
1781
|
+
const V = /* @__PURE__ */ new Map(), ct = /* @__PURE__ */ new Map();
|
|
1782
1782
|
function cs(i) {
|
|
1783
|
-
if (
|
|
1784
|
-
return
|
|
1785
|
-
const e =
|
|
1786
|
-
|
|
1783
|
+
if (V.has(i))
|
|
1784
|
+
return V.get(i);
|
|
1785
|
+
const e = N().createMediaStreamSource(i);
|
|
1786
|
+
V.set(i, e);
|
|
1787
1787
|
const n = () => {
|
|
1788
|
-
e.disconnect(),
|
|
1788
|
+
e.disconnect(), V.delete(i), ct.delete(i), i.removeEventListener("ended", n), i.removeEventListener("inactive", n);
|
|
1789
1789
|
};
|
|
1790
1790
|
return ct.set(i, n), i.addEventListener("ended", n), i.addEventListener("inactive", n), e;
|
|
1791
1791
|
}
|
|
@@ -1794,121 +1794,127 @@ function us(i) {
|
|
|
1794
1794
|
t && t();
|
|
1795
1795
|
}
|
|
1796
1796
|
function ls(i) {
|
|
1797
|
-
return
|
|
1797
|
+
return V.has(i);
|
|
1798
1798
|
}
|
|
1799
1799
|
function Le(i) {
|
|
1800
|
-
let t = null, e = !1, n = 0, r = !1, s = 0, a = 0,
|
|
1801
|
-
function
|
|
1802
|
-
const
|
|
1803
|
-
if (
|
|
1804
|
-
const
|
|
1805
|
-
id:
|
|
1806
|
-
name:
|
|
1807
|
-
gain:
|
|
1808
|
-
muted:
|
|
1809
|
-
soloed:
|
|
1810
|
-
stereoPan:
|
|
1811
|
-
startTime:
|
|
1812
|
-
endTime:
|
|
1813
|
-
},
|
|
1814
|
-
buffer:
|
|
1815
|
-
startTime: H(
|
|
1816
|
-
duration: gt(
|
|
1817
|
-
offset: mt(
|
|
1818
|
-
fadeIn:
|
|
1819
|
-
fadeOut:
|
|
1820
|
-
gain:
|
|
1800
|
+
let t = null, e = !1, n = 0, r = !1, s = 0, a = 0, o = !1, u = null;
|
|
1801
|
+
function l(h, d) {
|
|
1802
|
+
const f = d.clips.filter((v) => v.audioBuffer && !v.midiNotes), y = d.clips.filter((v) => v.midiNotes && v.midiNotes.length > 0);
|
|
1803
|
+
if (f.length > 0) {
|
|
1804
|
+
const v = Math.min(...f.map(H)), g = Math.max(...f.map(pt)), m = {
|
|
1805
|
+
id: d.id,
|
|
1806
|
+
name: d.name,
|
|
1807
|
+
gain: d.volume,
|
|
1808
|
+
muted: d.muted,
|
|
1809
|
+
soloed: d.soloed,
|
|
1810
|
+
stereoPan: d.pan,
|
|
1811
|
+
startTime: v,
|
|
1812
|
+
endTime: g
|
|
1813
|
+
}, S = f.map((b) => ({
|
|
1814
|
+
buffer: b.audioBuffer,
|
|
1815
|
+
startTime: H(b) - v,
|
|
1816
|
+
duration: gt(b),
|
|
1817
|
+
offset: mt(b),
|
|
1818
|
+
fadeIn: b.fadeIn,
|
|
1819
|
+
fadeOut: b.fadeOut,
|
|
1820
|
+
gain: b.gain
|
|
1821
1821
|
}));
|
|
1822
|
-
|
|
1823
|
-
clips:
|
|
1824
|
-
track:
|
|
1825
|
-
effects:
|
|
1822
|
+
h.addTrack({
|
|
1823
|
+
clips: S,
|
|
1824
|
+
track: m,
|
|
1825
|
+
effects: d.effects
|
|
1826
1826
|
});
|
|
1827
1827
|
}
|
|
1828
|
-
if (
|
|
1829
|
-
const
|
|
1830
|
-
id:
|
|
1831
|
-
name:
|
|
1832
|
-
gain:
|
|
1833
|
-
muted:
|
|
1834
|
-
soloed:
|
|
1835
|
-
stereoPan:
|
|
1836
|
-
startTime:
|
|
1837
|
-
endTime:
|
|
1838
|
-
},
|
|
1839
|
-
notes:
|
|
1840
|
-
startTime: H(
|
|
1841
|
-
duration: gt(
|
|
1842
|
-
offset: mt(
|
|
1828
|
+
if (y.length > 0) {
|
|
1829
|
+
const v = Math.min(...y.map(H)), g = Math.max(...y.map(pt)), S = {
|
|
1830
|
+
id: f.length > 0 ? `${d.id}:midi` : d.id,
|
|
1831
|
+
name: d.name,
|
|
1832
|
+
gain: d.volume,
|
|
1833
|
+
muted: d.muted,
|
|
1834
|
+
soloed: d.soloed,
|
|
1835
|
+
stereoPan: d.pan,
|
|
1836
|
+
startTime: v,
|
|
1837
|
+
endTime: g
|
|
1838
|
+
}, b = y.map((p) => ({
|
|
1839
|
+
notes: p.midiNotes,
|
|
1840
|
+
startTime: H(p) - v,
|
|
1841
|
+
duration: gt(p),
|
|
1842
|
+
offset: mt(p)
|
|
1843
1843
|
}));
|
|
1844
1844
|
if (i?.soundFontCache?.isLoaded) {
|
|
1845
|
-
const
|
|
1846
|
-
|
|
1847
|
-
clips:
|
|
1848
|
-
track:
|
|
1845
|
+
const p = y[0], T = p.midiChannel === 9, E = p.midiProgram ?? 0;
|
|
1846
|
+
h.addSoundFontTrack({
|
|
1847
|
+
clips: b,
|
|
1848
|
+
track: S,
|
|
1849
1849
|
soundFontCache: i.soundFontCache,
|
|
1850
|
-
programNumber:
|
|
1851
|
-
isPercussion:
|
|
1852
|
-
effects:
|
|
1850
|
+
programNumber: E,
|
|
1851
|
+
isPercussion: T,
|
|
1852
|
+
effects: d.effects
|
|
1853
1853
|
});
|
|
1854
1854
|
} else
|
|
1855
1855
|
i?.soundFontCache && console.warn(
|
|
1856
|
-
`[songram-daw] SoundFont not loaded for track "${
|
|
1857
|
-
),
|
|
1858
|
-
clips:
|
|
1859
|
-
track:
|
|
1860
|
-
effects:
|
|
1856
|
+
`[songram-daw] SoundFont not loaded for track "${d.name}" — falling back to PolySynth.`
|
|
1857
|
+
), h.addMidiTrack({
|
|
1858
|
+
clips: b,
|
|
1859
|
+
track: S,
|
|
1860
|
+
effects: d.effects
|
|
1861
1861
|
});
|
|
1862
1862
|
}
|
|
1863
1863
|
}
|
|
1864
|
-
function
|
|
1864
|
+
function c(h) {
|
|
1865
1865
|
if (t) {
|
|
1866
1866
|
try {
|
|
1867
1867
|
t.dispose();
|
|
1868
|
-
} catch (
|
|
1869
|
-
console.warn("[songram-daw] Error disposing previous playout during rebuild:",
|
|
1868
|
+
} catch (f) {
|
|
1869
|
+
console.warn("[songram-daw] Error disposing previous playout during rebuild:", f);
|
|
1870
1870
|
}
|
|
1871
1871
|
t = null;
|
|
1872
1872
|
}
|
|
1873
1873
|
n++;
|
|
1874
|
-
const
|
|
1874
|
+
const d = n;
|
|
1875
1875
|
t = new De({
|
|
1876
1876
|
effects: i?.effects
|
|
1877
|
-
}),
|
|
1877
|
+
}), o ? u = t.init().catch((f) => {
|
|
1878
1878
|
console.warn(
|
|
1879
1879
|
"[songram-daw] Failed to re-initialize playout after rebuild. Audio playback will require another user gesture.",
|
|
1880
|
-
|
|
1881
|
-
),
|
|
1882
|
-
});
|
|
1883
|
-
for (const
|
|
1884
|
-
|
|
1880
|
+
f
|
|
1881
|
+
), o = !1;
|
|
1882
|
+
}) : u = null;
|
|
1883
|
+
for (const f of h)
|
|
1884
|
+
l(t, f);
|
|
1885
1885
|
t.applyInitialSoloState(), t.setLoop(r, s, a), t.setOnPlaybackComplete(() => {
|
|
1886
|
-
|
|
1886
|
+
d === n && (e = !1);
|
|
1887
1887
|
});
|
|
1888
1888
|
}
|
|
1889
1889
|
return {
|
|
1890
1890
|
async init() {
|
|
1891
|
-
t && (await t.init(),
|
|
1891
|
+
t && (await t.init(), o = !0);
|
|
1892
1892
|
},
|
|
1893
|
-
setTracks(
|
|
1894
|
-
|
|
1893
|
+
setTracks(h) {
|
|
1894
|
+
c(h);
|
|
1895
1895
|
},
|
|
1896
|
-
addTrack(
|
|
1896
|
+
addTrack(h) {
|
|
1897
1897
|
if (!t)
|
|
1898
1898
|
throw new Error(
|
|
1899
1899
|
"[songram-daw] adapter.addTrack() called but no playout exists. Call setTracks() first to initialize the playout."
|
|
1900
1900
|
);
|
|
1901
|
-
|
|
1901
|
+
l(t, h), t.applyInitialSoloState();
|
|
1902
1902
|
},
|
|
1903
|
-
play(
|
|
1903
|
+
play(h, d) {
|
|
1904
1904
|
if (!t) {
|
|
1905
1905
|
console.warn(
|
|
1906
1906
|
"[songram-daw] adapter.play() called but no playout is available. Tracks may not have been set, or the adapter was disposed."
|
|
1907
1907
|
);
|
|
1908
1908
|
return;
|
|
1909
1909
|
}
|
|
1910
|
-
const
|
|
1911
|
-
|
|
1910
|
+
const f = () => {
|
|
1911
|
+
if (!t) return;
|
|
1912
|
+
const y = d !== void 0 ? d - h : void 0;
|
|
1913
|
+
t.play(rt(), h, y), e = !0;
|
|
1914
|
+
};
|
|
1915
|
+
u ? (u.then(f).catch((y) => {
|
|
1916
|
+
console.warn("[songram-daw] play() waiting for init failed:", y);
|
|
1917
|
+
}), u = null) : f();
|
|
1912
1918
|
},
|
|
1913
1919
|
pause() {
|
|
1914
1920
|
t?.pause(), e = !1;
|
|
@@ -1916,8 +1922,8 @@ function Le(i) {
|
|
|
1916
1922
|
stop() {
|
|
1917
1923
|
t?.stop(), e = !1;
|
|
1918
1924
|
},
|
|
1919
|
-
seek(
|
|
1920
|
-
t?.seekTo(
|
|
1925
|
+
seek(h) {
|
|
1926
|
+
t?.seekTo(h);
|
|
1921
1927
|
},
|
|
1922
1928
|
getCurrentTime() {
|
|
1923
1929
|
return t?.getCurrentTime() ?? 0;
|
|
@@ -1925,29 +1931,29 @@ function Le(i) {
|
|
|
1925
1931
|
isPlaying() {
|
|
1926
1932
|
return e;
|
|
1927
1933
|
},
|
|
1928
|
-
setMasterVolume(
|
|
1929
|
-
t?.setMasterGain(
|
|
1934
|
+
setMasterVolume(h) {
|
|
1935
|
+
t?.setMasterGain(h);
|
|
1930
1936
|
},
|
|
1931
|
-
setTrackVolume(
|
|
1932
|
-
t?.getTrack(
|
|
1937
|
+
setTrackVolume(h, d) {
|
|
1938
|
+
t?.getTrack(h)?.setVolume(d);
|
|
1933
1939
|
},
|
|
1934
|
-
setTrackMute(
|
|
1935
|
-
t?.setMute(
|
|
1940
|
+
setTrackMute(h, d) {
|
|
1941
|
+
t?.setMute(h, d);
|
|
1936
1942
|
},
|
|
1937
|
-
setTrackSolo(
|
|
1938
|
-
t?.setSolo(
|
|
1943
|
+
setTrackSolo(h, d) {
|
|
1944
|
+
t?.setSolo(h, d);
|
|
1939
1945
|
},
|
|
1940
|
-
setTrackPan(
|
|
1941
|
-
t?.getTrack(
|
|
1946
|
+
setTrackPan(h, d) {
|
|
1947
|
+
t?.getTrack(h)?.setPan(d);
|
|
1942
1948
|
},
|
|
1943
|
-
setLoop(
|
|
1944
|
-
r =
|
|
1949
|
+
setLoop(h, d, f) {
|
|
1950
|
+
r = h, s = d, a = f, t?.setLoop(h, d, f);
|
|
1945
1951
|
},
|
|
1946
1952
|
dispose() {
|
|
1947
1953
|
try {
|
|
1948
1954
|
t?.dispose();
|
|
1949
|
-
} catch (
|
|
1950
|
-
console.warn("[songram-daw] Error disposing playout:",
|
|
1955
|
+
} catch (h) {
|
|
1956
|
+
console.warn("[songram-daw] Error disposing playout:", h);
|
|
1951
1957
|
}
|
|
1952
1958
|
t = null, e = !1;
|
|
1953
1959
|
}
|
|
@@ -1977,7 +1983,7 @@ function ze(i) {
|
|
|
1977
1983
|
});
|
|
1978
1984
|
}), e;
|
|
1979
1985
|
}
|
|
1980
|
-
var
|
|
1986
|
+
var P = {}, J = {}, Y, Tt;
|
|
1981
1987
|
function $e() {
|
|
1982
1988
|
if (Tt) return Y;
|
|
1983
1989
|
Tt = 1;
|
|
@@ -1985,122 +1991,122 @@ function $e() {
|
|
|
1985
1991
|
var s = new n(r), a = s.readChunk();
|
|
1986
1992
|
if (a.id != "MThd")
|
|
1987
1993
|
throw "Bad MIDI file. Expected 'MHdr', got: '" + a.id + "'";
|
|
1988
|
-
for (var
|
|
1989
|
-
var
|
|
1990
|
-
if (
|
|
1991
|
-
throw "Bad MIDI file. Expected 'MTrk', got: '" +
|
|
1992
|
-
var h = e(
|
|
1994
|
+
for (var o = t(a.data), u = [], l = 0; !s.eof() && l < o.numTracks; l++) {
|
|
1995
|
+
var c = s.readChunk();
|
|
1996
|
+
if (c.id != "MTrk")
|
|
1997
|
+
throw "Bad MIDI file. Expected 'MTrk', got: '" + c.id + "'";
|
|
1998
|
+
var h = e(c.data);
|
|
1993
1999
|
u.push(h);
|
|
1994
2000
|
}
|
|
1995
2001
|
return {
|
|
1996
|
-
header:
|
|
2002
|
+
header: o,
|
|
1997
2003
|
tracks: u
|
|
1998
2004
|
};
|
|
1999
2005
|
}
|
|
2000
2006
|
function t(r) {
|
|
2001
|
-
var s = new n(r), a = s.readUInt16(),
|
|
2007
|
+
var s = new n(r), a = s.readUInt16(), o = s.readUInt16(), u = {
|
|
2002
2008
|
format: a,
|
|
2003
|
-
numTracks:
|
|
2009
|
+
numTracks: o
|
|
2004
2010
|
}, l = s.readUInt16();
|
|
2005
2011
|
return l & 32768 ? (u.framesPerSecond = 256 - (l >> 8), u.ticksPerFrame = l & 255) : u.ticksPerBeat = l, u;
|
|
2006
2012
|
}
|
|
2007
2013
|
function e(r) {
|
|
2008
2014
|
for (var s = new n(r), a = []; !s.eof(); ) {
|
|
2009
|
-
var
|
|
2010
|
-
a.push(
|
|
2015
|
+
var o = l();
|
|
2016
|
+
a.push(o);
|
|
2011
2017
|
}
|
|
2012
2018
|
return a;
|
|
2013
2019
|
var u;
|
|
2014
2020
|
function l() {
|
|
2015
|
-
var
|
|
2016
|
-
|
|
2021
|
+
var c = {};
|
|
2022
|
+
c.deltaTime = s.readVarInt();
|
|
2017
2023
|
var h = s.readUInt8();
|
|
2018
2024
|
if ((h & 240) === 240)
|
|
2019
2025
|
if (h === 255) {
|
|
2020
|
-
|
|
2026
|
+
c.meta = !0;
|
|
2021
2027
|
var d = s.readUInt8(), f = s.readVarInt();
|
|
2022
2028
|
switch (d) {
|
|
2023
2029
|
case 0:
|
|
2024
|
-
if (
|
|
2025
|
-
return
|
|
2030
|
+
if (c.type = "sequenceNumber", f !== 2) throw "Expected length for sequenceNumber event is 2, got " + f;
|
|
2031
|
+
return c.number = s.readUInt16(), c;
|
|
2026
2032
|
case 1:
|
|
2027
|
-
return
|
|
2033
|
+
return c.type = "text", c.text = s.readString(f), c;
|
|
2028
2034
|
case 2:
|
|
2029
|
-
return
|
|
2035
|
+
return c.type = "copyrightNotice", c.text = s.readString(f), c;
|
|
2030
2036
|
case 3:
|
|
2031
|
-
return
|
|
2037
|
+
return c.type = "trackName", c.text = s.readString(f), c;
|
|
2032
2038
|
case 4:
|
|
2033
|
-
return
|
|
2039
|
+
return c.type = "instrumentName", c.text = s.readString(f), c;
|
|
2034
2040
|
case 5:
|
|
2035
|
-
return
|
|
2041
|
+
return c.type = "lyrics", c.text = s.readString(f), c;
|
|
2036
2042
|
case 6:
|
|
2037
|
-
return
|
|
2043
|
+
return c.type = "marker", c.text = s.readString(f), c;
|
|
2038
2044
|
case 7:
|
|
2039
|
-
return
|
|
2045
|
+
return c.type = "cuePoint", c.text = s.readString(f), c;
|
|
2040
2046
|
case 32:
|
|
2041
|
-
if (
|
|
2042
|
-
return
|
|
2047
|
+
if (c.type = "channelPrefix", f != 1) throw "Expected length for channelPrefix event is 1, got " + f;
|
|
2048
|
+
return c.channel = s.readUInt8(), c;
|
|
2043
2049
|
case 33:
|
|
2044
|
-
if (
|
|
2045
|
-
return
|
|
2050
|
+
if (c.type = "portPrefix", f != 1) throw "Expected length for portPrefix event is 1, got " + f;
|
|
2051
|
+
return c.port = s.readUInt8(), c;
|
|
2046
2052
|
case 47:
|
|
2047
|
-
if (
|
|
2048
|
-
return
|
|
2053
|
+
if (c.type = "endOfTrack", f != 0) throw "Expected length for endOfTrack event is 0, got " + f;
|
|
2054
|
+
return c;
|
|
2049
2055
|
case 81:
|
|
2050
|
-
if (
|
|
2051
|
-
return
|
|
2056
|
+
if (c.type = "setTempo", f != 3) throw "Expected length for setTempo event is 3, got " + f;
|
|
2057
|
+
return c.microsecondsPerBeat = s.readUInt24(), c;
|
|
2052
2058
|
case 84:
|
|
2053
|
-
if (
|
|
2054
|
-
var
|
|
2055
|
-
return
|
|
2059
|
+
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;
|
|
2056
2062
|
case 88:
|
|
2057
|
-
if (
|
|
2058
|
-
return
|
|
2063
|
+
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;
|
|
2059
2065
|
case 89:
|
|
2060
|
-
if (
|
|
2061
|
-
return
|
|
2066
|
+
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;
|
|
2062
2068
|
case 127:
|
|
2063
|
-
return
|
|
2069
|
+
return c.type = "sequencerSpecific", c.data = s.readBytes(f), c;
|
|
2064
2070
|
default:
|
|
2065
|
-
return
|
|
2071
|
+
return c.type = "unknownMeta", c.data = s.readBytes(f), c.metatypeByte = d, c;
|
|
2066
2072
|
}
|
|
2067
2073
|
} else if (h == 240) {
|
|
2068
|
-
|
|
2074
|
+
c.type = "sysEx";
|
|
2069
2075
|
var f = s.readVarInt();
|
|
2070
|
-
return
|
|
2076
|
+
return c.data = s.readBytes(f), c;
|
|
2071
2077
|
} else if (h == 247) {
|
|
2072
|
-
|
|
2078
|
+
c.type = "endSysEx";
|
|
2073
2079
|
var f = s.readVarInt();
|
|
2074
|
-
return
|
|
2080
|
+
return c.data = s.readBytes(f), c;
|
|
2075
2081
|
} else
|
|
2076
2082
|
throw "Unrecognised MIDI event type byte: " + h;
|
|
2077
2083
|
else {
|
|
2078
|
-
var
|
|
2084
|
+
var g;
|
|
2079
2085
|
if ((h & 128) === 0) {
|
|
2080
2086
|
if (u === null)
|
|
2081
2087
|
throw "Running status byte encountered before status byte";
|
|
2082
|
-
|
|
2088
|
+
g = h, h = u, c.running = !0;
|
|
2083
2089
|
} else
|
|
2084
|
-
|
|
2085
|
-
var
|
|
2086
|
-
switch (
|
|
2090
|
+
g = s.readUInt8(), u = h;
|
|
2091
|
+
var m = h >> 4;
|
|
2092
|
+
switch (c.channel = h & 15, m) {
|
|
2087
2093
|
case 8:
|
|
2088
|
-
return
|
|
2094
|
+
return c.type = "noteOff", c.noteNumber = g, c.velocity = s.readUInt8(), c;
|
|
2089
2095
|
case 9:
|
|
2090
|
-
var
|
|
2091
|
-
return
|
|
2096
|
+
var S = s.readUInt8();
|
|
2097
|
+
return c.type = S === 0 ? "noteOff" : "noteOn", c.noteNumber = g, c.velocity = S, S === 0 && (c.byte9 = !0), c;
|
|
2092
2098
|
case 10:
|
|
2093
|
-
return
|
|
2099
|
+
return c.type = "noteAftertouch", c.noteNumber = g, c.amount = s.readUInt8(), c;
|
|
2094
2100
|
case 11:
|
|
2095
|
-
return
|
|
2101
|
+
return c.type = "controller", c.controllerType = g, c.value = s.readUInt8(), c;
|
|
2096
2102
|
case 12:
|
|
2097
|
-
return
|
|
2103
|
+
return c.type = "programChange", c.programNumber = g, c;
|
|
2098
2104
|
case 13:
|
|
2099
|
-
return
|
|
2105
|
+
return c.type = "channelAftertouch", c.amount = g, c;
|
|
2100
2106
|
case 14:
|
|
2101
|
-
return
|
|
2107
|
+
return c.type = "pitchBend", c.value = g + (s.readUInt8() << 7) - 8192, c;
|
|
2102
2108
|
default:
|
|
2103
|
-
throw "Unrecognised MIDI event type: " +
|
|
2109
|
+
throw "Unrecognised MIDI event type: " + m;
|
|
2104
2110
|
}
|
|
2105
2111
|
}
|
|
2106
2112
|
}
|
|
@@ -2129,8 +2135,8 @@ function $e() {
|
|
|
2129
2135
|
var r = this.readUInt24();
|
|
2130
2136
|
return r & 8388608 ? r - 16777216 : r;
|
|
2131
2137
|
}, n.prototype.readUInt32 = function() {
|
|
2132
|
-
var r = this.readUInt8(), s = this.readUInt8(), a = this.readUInt8(),
|
|
2133
|
-
return (r << 24) + (s << 16) + (a << 8) +
|
|
2138
|
+
var r = this.readUInt8(), s = this.readUInt8(), a = this.readUInt8(), o = this.readUInt8();
|
|
2139
|
+
return (r << 24) + (s << 16) + (a << 8) + o;
|
|
2134
2140
|
}, n.prototype.readBytes = function(r) {
|
|
2135
2141
|
var s = this.buffer.slice(this.pos, this.pos + r);
|
|
2136
2142
|
return this.pos += r, s;
|
|
@@ -2163,26 +2169,26 @@ function je() {
|
|
|
2163
2169
|
if (typeof s != "object")
|
|
2164
2170
|
throw "Invalid MIDI data";
|
|
2165
2171
|
a = a || {};
|
|
2166
|
-
var
|
|
2167
|
-
for (t(h,
|
|
2172
|
+
var o = s.header || {}, u = s.tracks || [], l, c = u.length, h = new r();
|
|
2173
|
+
for (t(h, o, c), l = 0; l < c; l++)
|
|
2168
2174
|
e(h, u[l], a);
|
|
2169
2175
|
return h.buffer;
|
|
2170
2176
|
}
|
|
2171
|
-
function t(s, a,
|
|
2177
|
+
function t(s, a, o) {
|
|
2172
2178
|
var u = a.format == null ? 1 : a.format, l = 128;
|
|
2173
2179
|
a.timeDivision ? l = a.timeDivision : a.ticksPerFrame && a.framesPerSecond ? l = -(a.framesPerSecond & 255) << 8 | a.ticksPerFrame & 255 : a.ticksPerBeat && (l = a.ticksPerBeat & 32767);
|
|
2174
|
-
var
|
|
2175
|
-
|
|
2180
|
+
var c = new r();
|
|
2181
|
+
c.writeUInt16(u), c.writeUInt16(o), c.writeUInt16(l), s.writeChunk("MThd", c.buffer);
|
|
2176
2182
|
}
|
|
2177
|
-
function e(s, a,
|
|
2178
|
-
var u = new r(), l,
|
|
2179
|
-
for (l = 0; l <
|
|
2180
|
-
(
|
|
2183
|
+
function e(s, a, o) {
|
|
2184
|
+
var u = new r(), l, c = a.length, h = null;
|
|
2185
|
+
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);
|
|
2181
2187
|
s.writeChunk("MTrk", u.buffer);
|
|
2182
2188
|
}
|
|
2183
|
-
function n(s, a,
|
|
2184
|
-
var l = a.type,
|
|
2185
|
-
switch (s.writeVarInt(
|
|
2189
|
+
function n(s, a, o, u) {
|
|
2190
|
+
var l = a.type, c = a.deltaTime, h = a.text || "", d = a.data || [], f = null;
|
|
2191
|
+
switch (s.writeVarInt(c), l) {
|
|
2186
2192
|
// meta events
|
|
2187
2193
|
case "sequenceNumber":
|
|
2188
2194
|
s.writeUInt8(255), s.writeUInt8(0), s.writeVarInt(2), s.writeUInt16(a.number);
|
|
@@ -2222,13 +2228,13 @@ function je() {
|
|
|
2222
2228
|
break;
|
|
2223
2229
|
case "smpteOffset":
|
|
2224
2230
|
s.writeUInt8(255), s.writeUInt8(84), s.writeVarInt(5);
|
|
2225
|
-
var
|
|
2226
|
-
s.writeUInt8(
|
|
2231
|
+
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);
|
|
2227
2233
|
break;
|
|
2228
2234
|
case "timeSignature":
|
|
2229
2235
|
s.writeUInt8(255), s.writeUInt8(88), s.writeVarInt(4), s.writeUInt8(a.numerator);
|
|
2230
|
-
var
|
|
2231
|
-
s.writeUInt8(
|
|
2236
|
+
var g = Math.floor(Math.log(a.denominator) / Math.LN2) & 255;
|
|
2237
|
+
s.writeUInt8(g), s.writeUInt8(a.metronome), s.writeUInt8(a.thirtyseconds || 8);
|
|
2232
2238
|
break;
|
|
2233
2239
|
case "keySignature":
|
|
2234
2240
|
s.writeUInt8(255), s.writeUInt8(89), s.writeVarInt(2), s.writeInt8(a.key), s.writeUInt8(a.scale);
|
|
@@ -2248,28 +2254,28 @@ function je() {
|
|
|
2248
2254
|
break;
|
|
2249
2255
|
// channel events
|
|
2250
2256
|
case "noteOff":
|
|
2251
|
-
var
|
|
2252
|
-
f =
|
|
2257
|
+
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);
|
|
2253
2259
|
break;
|
|
2254
2260
|
case "noteOn":
|
|
2255
|
-
f = 144 | a.channel, f !==
|
|
2261
|
+
f = 144 | a.channel, f !== o && s.writeUInt8(f), s.writeUInt8(a.noteNumber), s.writeUInt8(a.velocity);
|
|
2256
2262
|
break;
|
|
2257
2263
|
case "noteAftertouch":
|
|
2258
|
-
f = 160 | a.channel, f !==
|
|
2264
|
+
f = 160 | a.channel, f !== o && s.writeUInt8(f), s.writeUInt8(a.noteNumber), s.writeUInt8(a.amount);
|
|
2259
2265
|
break;
|
|
2260
2266
|
case "controller":
|
|
2261
|
-
f = 176 | a.channel, f !==
|
|
2267
|
+
f = 176 | a.channel, f !== o && s.writeUInt8(f), s.writeUInt8(a.controllerType), s.writeUInt8(a.value);
|
|
2262
2268
|
break;
|
|
2263
2269
|
case "programChange":
|
|
2264
|
-
f = 192 | a.channel, f !==
|
|
2270
|
+
f = 192 | a.channel, f !== o && s.writeUInt8(f), s.writeUInt8(a.programNumber);
|
|
2265
2271
|
break;
|
|
2266
2272
|
case "channelAftertouch":
|
|
2267
|
-
f = 208 | a.channel, f !==
|
|
2273
|
+
f = 208 | a.channel, f !== o && s.writeUInt8(f), s.writeUInt8(a.amount);
|
|
2268
2274
|
break;
|
|
2269
2275
|
case "pitchBend":
|
|
2270
|
-
f = 224 | a.channel, f !==
|
|
2271
|
-
var
|
|
2272
|
-
s.writeUInt8(
|
|
2276
|
+
f = 224 | a.channel, f !== o && s.writeUInt8(f);
|
|
2277
|
+
var S = 8192 + a.value, b = S & 127, p = S >> 7 & 127;
|
|
2278
|
+
s.writeUInt8(b), s.writeUInt8(p);
|
|
2273
2279
|
break;
|
|
2274
2280
|
default:
|
|
2275
2281
|
throw "Unrecognized event type: " + l;
|
|
@@ -2282,19 +2288,19 @@ function je() {
|
|
|
2282
2288
|
return r.prototype.writeUInt8 = function(s) {
|
|
2283
2289
|
this.buffer.push(s & 255);
|
|
2284
2290
|
}, r.prototype.writeInt8 = r.prototype.writeUInt8, r.prototype.writeUInt16 = function(s) {
|
|
2285
|
-
var a = s >> 8 & 255,
|
|
2286
|
-
this.writeUInt8(a), this.writeUInt8(
|
|
2291
|
+
var a = s >> 8 & 255, o = s & 255;
|
|
2292
|
+
this.writeUInt8(a), this.writeUInt8(o);
|
|
2287
2293
|
}, r.prototype.writeInt16 = r.prototype.writeUInt16, r.prototype.writeUInt24 = function(s) {
|
|
2288
|
-
var a = s >> 16 & 255,
|
|
2289
|
-
this.writeUInt8(a), this.writeUInt8(
|
|
2294
|
+
var a = s >> 16 & 255, o = s >> 8 & 255, u = s & 255;
|
|
2295
|
+
this.writeUInt8(a), this.writeUInt8(o), this.writeUInt8(u);
|
|
2290
2296
|
}, r.prototype.writeInt24 = r.prototype.writeUInt24, r.prototype.writeUInt32 = function(s) {
|
|
2291
|
-
var a = s >> 24 & 255,
|
|
2292
|
-
this.writeUInt8(a), this.writeUInt8(
|
|
2297
|
+
var a = s >> 24 & 255, o = s >> 16 & 255, u = s >> 8 & 255, l = s & 255;
|
|
2298
|
+
this.writeUInt8(a), this.writeUInt8(o), this.writeUInt8(u), this.writeUInt8(l);
|
|
2293
2299
|
}, r.prototype.writeInt32 = r.prototype.writeUInt32, r.prototype.writeBytes = function(s) {
|
|
2294
2300
|
this.buffer = this.buffer.concat(Array.prototype.slice.call(s, 0));
|
|
2295
2301
|
}, r.prototype.writeString = function(s) {
|
|
2296
|
-
var a,
|
|
2297
|
-
for (a = 0; a <
|
|
2302
|
+
var a, o = s.length, u = [];
|
|
2303
|
+
for (a = 0; a < o; a++)
|
|
2298
2304
|
u.push(s.codePointAt(a));
|
|
2299
2305
|
this.writeBytes(u);
|
|
2300
2306
|
}, r.prototype.writeVarInt = function(s) {
|
|
@@ -2302,12 +2308,12 @@ function je() {
|
|
|
2302
2308
|
if (s <= 127)
|
|
2303
2309
|
this.writeUInt8(s);
|
|
2304
2310
|
else {
|
|
2305
|
-
var a = s,
|
|
2306
|
-
for (
|
|
2311
|
+
var a = s, o = [];
|
|
2312
|
+
for (o.push(a & 127), a >>= 7; a; ) {
|
|
2307
2313
|
var u = a & 127 | 128;
|
|
2308
|
-
|
|
2314
|
+
o.push(u), a >>= 7;
|
|
2309
2315
|
}
|
|
2310
|
-
this.writeBytes(
|
|
2316
|
+
this.writeBytes(o.reverse());
|
|
2311
2317
|
}
|
|
2312
2318
|
}, r.prototype.writeChunk = function(s, a) {
|
|
2313
2319
|
this.writeString(s), this.writeUInt32(a.length), this.writeBytes(a);
|
|
@@ -2317,17 +2323,17 @@ var Mt;
|
|
|
2317
2323
|
function re() {
|
|
2318
2324
|
return Mt || (Mt = 1, J.parseMidi = $e(), J.writeMidi = je()), J;
|
|
2319
2325
|
}
|
|
2320
|
-
var et = {},
|
|
2326
|
+
var et = {}, F = {}, _t;
|
|
2321
2327
|
function ie() {
|
|
2322
|
-
if (_t) return
|
|
2323
|
-
_t = 1, Object.defineProperty(
|
|
2328
|
+
if (_t) return F;
|
|
2329
|
+
_t = 1, Object.defineProperty(F, "__esModule", { value: !0 }), F.insert = F.search = void 0;
|
|
2324
2330
|
function i(e, n, r) {
|
|
2325
2331
|
r === void 0 && (r = "ticks");
|
|
2326
|
-
var s = 0, a = e.length,
|
|
2332
|
+
var s = 0, a = e.length, o = a;
|
|
2327
2333
|
if (a > 0 && e[a - 1][r] <= n)
|
|
2328
2334
|
return a - 1;
|
|
2329
|
-
for (; s <
|
|
2330
|
-
var u = Math.floor(s + (
|
|
2335
|
+
for (; s < o; ) {
|
|
2336
|
+
var u = Math.floor(s + (o - s) / 2), l = e[u], c = e[u + 1];
|
|
2331
2337
|
if (l[r] === n) {
|
|
2332
2338
|
for (var h = u; h < e.length; h++) {
|
|
2333
2339
|
var d = e[h];
|
|
@@ -2335,14 +2341,14 @@ function ie() {
|
|
|
2335
2341
|
}
|
|
2336
2342
|
return u;
|
|
2337
2343
|
} else {
|
|
2338
|
-
if (l[r] < n &&
|
|
2344
|
+
if (l[r] < n && c[r] > n)
|
|
2339
2345
|
return u;
|
|
2340
|
-
l[r] > n ?
|
|
2346
|
+
l[r] > n ? o = u : l[r] < n && (s = u + 1);
|
|
2341
2347
|
}
|
|
2342
2348
|
}
|
|
2343
2349
|
return -1;
|
|
2344
2350
|
}
|
|
2345
|
-
|
|
2351
|
+
F.search = i;
|
|
2346
2352
|
function t(e, n, r) {
|
|
2347
2353
|
if (r === void 0 && (r = "ticks"), e.length) {
|
|
2348
2354
|
var s = i(e, n[r], r);
|
|
@@ -2350,7 +2356,7 @@ function ie() {
|
|
|
2350
2356
|
} else
|
|
2351
2357
|
e.push(n);
|
|
2352
2358
|
}
|
|
2353
|
-
return
|
|
2359
|
+
return F.insert = t, F;
|
|
2354
2360
|
}
|
|
2355
2361
|
var It;
|
|
2356
2362
|
function ut() {
|
|
@@ -2398,43 +2404,43 @@ function ut() {
|
|
|
2398
2404
|
}));
|
|
2399
2405
|
});
|
|
2400
2406
|
});
|
|
2401
|
-
var
|
|
2407
|
+
var o = 0;
|
|
2402
2408
|
s.tracks[0].forEach(function(u) {
|
|
2403
|
-
|
|
2409
|
+
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({
|
|
2404
2410
|
text: u.text,
|
|
2405
|
-
ticks:
|
|
2411
|
+
ticks: o,
|
|
2406
2412
|
type: u.type
|
|
2407
2413
|
}));
|
|
2408
2414
|
}), this.update();
|
|
2409
2415
|
}
|
|
2410
2416
|
}
|
|
2411
2417
|
return r.prototype.update = function() {
|
|
2412
|
-
var s = this, a = 0,
|
|
2418
|
+
var s = this, a = 0, o = 0;
|
|
2413
2419
|
this.tempos.sort(function(u, l) {
|
|
2414
2420
|
return u.ticks - l.ticks;
|
|
2415
2421
|
}), this.tempos.forEach(function(u, l) {
|
|
2416
|
-
var
|
|
2417
|
-
u.time = d + a, a = u.time,
|
|
2422
|
+
var c = l > 0 ? s.tempos[l - 1].bpm : s.tempos[0].bpm, h = u.ticks / s.ppq - o, d = 60 / c * h;
|
|
2423
|
+
u.time = d + a, a = u.time, o += h;
|
|
2418
2424
|
}), this.timeSignatures.sort(function(u, l) {
|
|
2419
2425
|
return u.ticks - l.ticks;
|
|
2420
2426
|
}), this.timeSignatures.forEach(function(u, l) {
|
|
2421
|
-
var
|
|
2422
|
-
|
|
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);
|
|
2428
|
+
c.measures = c.measures || 0, u.measures = d + c.measures;
|
|
2423
2429
|
});
|
|
2424
2430
|
}, r.prototype.ticksToSeconds = function(s) {
|
|
2425
2431
|
var a = (0, t.search)(this.tempos, s);
|
|
2426
2432
|
if (a !== -1) {
|
|
2427
|
-
var
|
|
2428
|
-
return u + 60 /
|
|
2433
|
+
var o = this.tempos[a], u = o.time, l = (s - o.ticks) / this.ppq;
|
|
2434
|
+
return u + 60 / o.bpm * l;
|
|
2429
2435
|
} else {
|
|
2430
|
-
var
|
|
2431
|
-
return 60 / 120 *
|
|
2436
|
+
var c = s / this.ppq;
|
|
2437
|
+
return 60 / 120 * c;
|
|
2432
2438
|
}
|
|
2433
2439
|
}, r.prototype.ticksToMeasures = function(s) {
|
|
2434
2440
|
var a = (0, t.search)(this.timeSignatures, s);
|
|
2435
2441
|
if (a !== -1) {
|
|
2436
|
-
var
|
|
2437
|
-
return
|
|
2442
|
+
var o = this.timeSignatures[a], u = (s - o.ticks) / this.ppq;
|
|
2443
|
+
return o.measures + u / (o.timeSignature[0] / o.timeSignature[1]) / 4;
|
|
2438
2444
|
} else
|
|
2439
2445
|
return s / this.ppq / 4;
|
|
2440
2446
|
}, Object.defineProperty(r.prototype, "ppq", {
|
|
@@ -2449,8 +2455,8 @@ function ut() {
|
|
|
2449
2455
|
}), r.prototype.secondsToTicks = function(s) {
|
|
2450
2456
|
var a = (0, t.search)(this.tempos, s, "time");
|
|
2451
2457
|
if (a !== -1) {
|
|
2452
|
-
var
|
|
2453
|
-
return Math.round(
|
|
2458
|
+
var o = this.tempos[a], u = o.time, l = s - u, c = l / (60 / o.bpm);
|
|
2459
|
+
return Math.round(o.ticks + c * this.ppq);
|
|
2454
2460
|
} else {
|
|
2455
2461
|
var h = s / 0.5;
|
|
2456
2462
|
return Math.round(h * this.ppq);
|
|
@@ -2789,8 +2795,8 @@ function Ke() {
|
|
|
2789
2795
|
(function() {
|
|
2790
2796
|
function n(r, s) {
|
|
2791
2797
|
if (this.number = 0, t.set(this, s), this.number = 0, r) {
|
|
2792
|
-
var a = r.find(function(
|
|
2793
|
-
return
|
|
2798
|
+
var a = r.find(function(o) {
|
|
2799
|
+
return o.type === "programChange";
|
|
2794
2800
|
});
|
|
2795
2801
|
a && (this.number = a.programNumber);
|
|
2796
2802
|
}
|
|
@@ -2840,24 +2846,24 @@ function Ke() {
|
|
|
2840
2846
|
);
|
|
2841
2847
|
return G.Instrument = e, G;
|
|
2842
2848
|
}
|
|
2843
|
-
var
|
|
2849
|
+
var R = {}, Nt;
|
|
2844
2850
|
function Xe() {
|
|
2845
|
-
if (Nt) return
|
|
2846
|
-
Nt = 1, Object.defineProperty(
|
|
2851
|
+
if (Nt) return R;
|
|
2852
|
+
Nt = 1, Object.defineProperty(R, "__esModule", { value: !0 }), R.Note = void 0;
|
|
2847
2853
|
function i(a) {
|
|
2848
|
-
var
|
|
2849
|
-
return t(a) +
|
|
2854
|
+
var o = Math.floor(a / 12) - 1;
|
|
2855
|
+
return t(a) + o.toString();
|
|
2850
2856
|
}
|
|
2851
2857
|
function t(a) {
|
|
2852
|
-
var
|
|
2853
|
-
return
|
|
2858
|
+
var o = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"], u = a % 12;
|
|
2859
|
+
return o[u];
|
|
2854
2860
|
}
|
|
2855
2861
|
function e(a) {
|
|
2856
|
-
var
|
|
2857
|
-
return
|
|
2862
|
+
var o = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
|
|
2863
|
+
return o.indexOf(a);
|
|
2858
2864
|
}
|
|
2859
2865
|
var n = /* @__PURE__ */ (function() {
|
|
2860
|
-
var a = /^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,
|
|
2866
|
+
var a = /^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i, o = {
|
|
2861
2867
|
// tslint:disable-next-line: object-literal-sort-keys
|
|
2862
2868
|
cbb: -2,
|
|
2863
2869
|
cb: -1,
|
|
@@ -2896,14 +2902,14 @@ function Xe() {
|
|
|
2896
2902
|
bx: 13
|
|
2897
2903
|
};
|
|
2898
2904
|
return function(u) {
|
|
2899
|
-
var l = a.exec(u),
|
|
2905
|
+
var l = a.exec(u), c = l[1], h = l[2], d = o[c.toLowerCase()];
|
|
2900
2906
|
return d + (parseInt(h, 10) + 1) * 12;
|
|
2901
2907
|
};
|
|
2902
2908
|
})(), r = /* @__PURE__ */ new WeakMap(), s = (
|
|
2903
2909
|
/** @class */
|
|
2904
2910
|
(function() {
|
|
2905
|
-
function a(
|
|
2906
|
-
r.set(this, l), this.midi =
|
|
2911
|
+
function a(o, u, l) {
|
|
2912
|
+
r.set(this, l), this.midi = o.midi, this.velocity = o.velocity, this.noteOffVelocity = u.velocity, this.ticks = o.ticks, this.durationTicks = u.ticks - o.ticks;
|
|
2907
2913
|
}
|
|
2908
2914
|
return Object.defineProperty(a.prototype, "name", {
|
|
2909
2915
|
/**
|
|
@@ -2912,8 +2918,8 @@ function Xe() {
|
|
|
2912
2918
|
get: function() {
|
|
2913
2919
|
return i(this.midi);
|
|
2914
2920
|
},
|
|
2915
|
-
set: function(
|
|
2916
|
-
this.midi = n(
|
|
2921
|
+
set: function(o) {
|
|
2922
|
+
this.midi = n(o);
|
|
2917
2923
|
},
|
|
2918
2924
|
enumerable: !1,
|
|
2919
2925
|
configurable: !0
|
|
@@ -2924,8 +2930,8 @@ function Xe() {
|
|
|
2924
2930
|
get: function() {
|
|
2925
2931
|
return Math.floor(this.midi / 12) - 1;
|
|
2926
2932
|
},
|
|
2927
|
-
set: function(
|
|
2928
|
-
var u =
|
|
2933
|
+
set: function(o) {
|
|
2934
|
+
var u = o - this.octave;
|
|
2929
2935
|
this.midi += u * 12;
|
|
2930
2936
|
},
|
|
2931
2937
|
enumerable: !1,
|
|
@@ -2937,8 +2943,8 @@ function Xe() {
|
|
|
2937
2943
|
get: function() {
|
|
2938
2944
|
return t(this.midi);
|
|
2939
2945
|
},
|
|
2940
|
-
set: function(
|
|
2941
|
-
this.midi = 12 * (this.octave + 1) + e(
|
|
2946
|
+
set: function(o) {
|
|
2947
|
+
this.midi = 12 * (this.octave + 1) + e(o);
|
|
2942
2948
|
},
|
|
2943
2949
|
enumerable: !1,
|
|
2944
2950
|
configurable: !0
|
|
@@ -2947,11 +2953,11 @@ function Xe() {
|
|
|
2947
2953
|
* The duration of the segment in seconds.
|
|
2948
2954
|
*/
|
|
2949
2955
|
get: function() {
|
|
2950
|
-
var
|
|
2951
|
-
return
|
|
2956
|
+
var o = r.get(this);
|
|
2957
|
+
return o.ticksToSeconds(this.ticks + this.durationTicks) - o.ticksToSeconds(this.ticks);
|
|
2952
2958
|
},
|
|
2953
|
-
set: function(
|
|
2954
|
-
var u = r.get(this), l = u.secondsToTicks(this.time +
|
|
2959
|
+
set: function(o) {
|
|
2960
|
+
var u = r.get(this), l = u.secondsToTicks(this.time + o);
|
|
2955
2961
|
this.durationTicks = l - this.ticks;
|
|
2956
2962
|
},
|
|
2957
2963
|
enumerable: !1,
|
|
@@ -2961,12 +2967,12 @@ function Xe() {
|
|
|
2961
2967
|
* The time of the event in seconds.
|
|
2962
2968
|
*/
|
|
2963
2969
|
get: function() {
|
|
2964
|
-
var
|
|
2965
|
-
return
|
|
2970
|
+
var o = r.get(this);
|
|
2971
|
+
return o.ticksToSeconds(this.ticks);
|
|
2966
2972
|
},
|
|
2967
|
-
set: function(
|
|
2973
|
+
set: function(o) {
|
|
2968
2974
|
var u = r.get(this);
|
|
2969
|
-
this.ticks = u.secondsToTicks(
|
|
2975
|
+
this.ticks = u.secondsToTicks(o);
|
|
2970
2976
|
},
|
|
2971
2977
|
enumerable: !1,
|
|
2972
2978
|
configurable: !0
|
|
@@ -2977,8 +2983,8 @@ function Xe() {
|
|
|
2977
2983
|
* @readonly
|
|
2978
2984
|
*/
|
|
2979
2985
|
get: function() {
|
|
2980
|
-
var
|
|
2981
|
-
return
|
|
2986
|
+
var o = r.get(this);
|
|
2987
|
+
return o.ticksToMeasures(this.ticks);
|
|
2982
2988
|
},
|
|
2983
2989
|
enumerable: !1,
|
|
2984
2990
|
configurable: !0
|
|
@@ -2995,89 +3001,89 @@ function Xe() {
|
|
|
2995
3001
|
}, a;
|
|
2996
3002
|
})()
|
|
2997
3003
|
);
|
|
2998
|
-
return
|
|
3004
|
+
return R.Note = s, R;
|
|
2999
3005
|
}
|
|
3000
3006
|
var Ot;
|
|
3001
3007
|
function Ut() {
|
|
3002
3008
|
if (Ot) return U;
|
|
3003
3009
|
Ot = 1, Object.defineProperty(U, "__esModule", { value: !0 }), U.Track = void 0;
|
|
3004
|
-
var i = ie(), t = ae(), e = He(), n = We(), r = Ke(), s = Xe(), a = /* @__PURE__ */ new WeakMap(),
|
|
3010
|
+
var i = ie(), t = ae(), e = He(), n = We(), r = Ke(), s = Xe(), a = /* @__PURE__ */ new WeakMap(), o = (
|
|
3005
3011
|
/** @class */
|
|
3006
3012
|
(function() {
|
|
3007
|
-
function u(l,
|
|
3013
|
+
function u(l, c) {
|
|
3008
3014
|
var h = this;
|
|
3009
|
-
if (this.name = "", this.notes = [], this.controlChanges = (0, e.createControlChanges)(), this.pitchBends = [], a.set(this,
|
|
3010
|
-
var d = l.find(function(
|
|
3011
|
-
return
|
|
3015
|
+
if (this.name = "", this.notes = [], this.controlChanges = (0, e.createControlChanges)(), this.pitchBends = [], a.set(this, c), l) {
|
|
3016
|
+
var d = l.find(function(p) {
|
|
3017
|
+
return p.type === "trackName";
|
|
3012
3018
|
});
|
|
3013
3019
|
this.name = d ? d.text : "";
|
|
3014
3020
|
}
|
|
3015
3021
|
if (this.instrument = new r.Instrument(l, this), this.channel = 0, l) {
|
|
3016
|
-
for (var f = l.filter(function(
|
|
3017
|
-
return
|
|
3018
|
-
}),
|
|
3019
|
-
return
|
|
3020
|
-
}),
|
|
3021
|
-
var
|
|
3022
|
-
|
|
3023
|
-
var
|
|
3024
|
-
return
|
|
3022
|
+
for (var f = l.filter(function(p) {
|
|
3023
|
+
return p.type === "noteOn";
|
|
3024
|
+
}), y = l.filter(function(p) {
|
|
3025
|
+
return p.type === "noteOff";
|
|
3026
|
+
}), v = function() {
|
|
3027
|
+
var p = f.shift();
|
|
3028
|
+
g.channel = p.channel;
|
|
3029
|
+
var k = y.findIndex(function(E) {
|
|
3030
|
+
return E.noteNumber === p.noteNumber && E.absoluteTime >= p.absoluteTime;
|
|
3025
3031
|
});
|
|
3026
|
-
if (
|
|
3027
|
-
var T =
|
|
3028
|
-
|
|
3029
|
-
durationTicks: T.absoluteTime -
|
|
3030
|
-
midi:
|
|
3032
|
+
if (k !== -1) {
|
|
3033
|
+
var T = y.splice(k, 1)[0];
|
|
3034
|
+
g.addNote({
|
|
3035
|
+
durationTicks: T.absoluteTime - p.absoluteTime,
|
|
3036
|
+
midi: p.noteNumber,
|
|
3031
3037
|
noteOffVelocity: T.velocity / 127,
|
|
3032
|
-
ticks:
|
|
3033
|
-
velocity:
|
|
3038
|
+
ticks: p.absoluteTime,
|
|
3039
|
+
velocity: p.velocity / 127
|
|
3034
3040
|
});
|
|
3035
3041
|
}
|
|
3036
|
-
},
|
|
3037
|
-
|
|
3038
|
-
var
|
|
3039
|
-
return
|
|
3042
|
+
}, g = this; f.length; )
|
|
3043
|
+
v();
|
|
3044
|
+
var m = l.filter(function(p) {
|
|
3045
|
+
return p.type === "controller";
|
|
3040
3046
|
});
|
|
3041
|
-
|
|
3047
|
+
m.forEach(function(p) {
|
|
3042
3048
|
h.addCC({
|
|
3043
|
-
number:
|
|
3044
|
-
ticks:
|
|
3045
|
-
value:
|
|
3049
|
+
number: p.controllerType,
|
|
3050
|
+
ticks: p.absoluteTime,
|
|
3051
|
+
value: p.value / 127
|
|
3046
3052
|
});
|
|
3047
3053
|
});
|
|
3048
|
-
var
|
|
3049
|
-
return
|
|
3054
|
+
var S = l.filter(function(p) {
|
|
3055
|
+
return p.type === "pitchBend";
|
|
3050
3056
|
});
|
|
3051
|
-
|
|
3057
|
+
S.forEach(function(p) {
|
|
3052
3058
|
h.addPitchBend({
|
|
3053
|
-
ticks:
|
|
3059
|
+
ticks: p.absoluteTime,
|
|
3054
3060
|
// Scale the value between -2^13 to 2^13 to -2 to 2.
|
|
3055
|
-
value:
|
|
3061
|
+
value: p.value / Math.pow(2, 13)
|
|
3056
3062
|
});
|
|
3057
3063
|
});
|
|
3058
|
-
var
|
|
3059
|
-
return
|
|
3064
|
+
var b = l.find(function(p) {
|
|
3065
|
+
return p.type === "endOfTrack";
|
|
3060
3066
|
});
|
|
3061
|
-
this.endOfTrackTicks =
|
|
3067
|
+
this.endOfTrackTicks = b !== void 0 ? b.absoluteTime : void 0;
|
|
3062
3068
|
}
|
|
3063
3069
|
}
|
|
3064
3070
|
return u.prototype.addNote = function(l) {
|
|
3065
|
-
var
|
|
3071
|
+
var c = a.get(this), h = new s.Note({
|
|
3066
3072
|
midi: 0,
|
|
3067
3073
|
ticks: 0,
|
|
3068
3074
|
velocity: 1
|
|
3069
3075
|
}, {
|
|
3070
3076
|
ticks: 0,
|
|
3071
3077
|
velocity: 0
|
|
3072
|
-
},
|
|
3078
|
+
}, c);
|
|
3073
3079
|
return Object.assign(h, l), (0, i.insert)(this.notes, h, "ticks"), this;
|
|
3074
3080
|
}, u.prototype.addCC = function(l) {
|
|
3075
|
-
var
|
|
3081
|
+
var c = a.get(this), h = new t.ControlChange({
|
|
3076
3082
|
controllerType: l.number
|
|
3077
|
-
},
|
|
3083
|
+
}, c);
|
|
3078
3084
|
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;
|
|
3079
3085
|
}, u.prototype.addPitchBend = function(l) {
|
|
3080
|
-
var
|
|
3086
|
+
var c = a.get(this), h = new n.PitchBend({}, c);
|
|
3081
3087
|
return Object.assign(h, l), (0, i.insert)(this.pitchBends, h, "ticks"), this;
|
|
3082
3088
|
}, Object.defineProperty(u.prototype, "duration", {
|
|
3083
3089
|
/**
|
|
@@ -3086,8 +3092,8 @@ function Ut() {
|
|
|
3086
3092
|
get: function() {
|
|
3087
3093
|
if (!this.notes.length)
|
|
3088
3094
|
return 0;
|
|
3089
|
-
for (var l = this.notes[this.notes.length - 1].time + this.notes[this.notes.length - 1].duration,
|
|
3090
|
-
var h = this.notes[
|
|
3095
|
+
for (var l = this.notes[this.notes.length - 1].time + this.notes[this.notes.length - 1].duration, c = 0; c < this.notes.length - 1; c++) {
|
|
3096
|
+
var h = this.notes[c].time + this.notes[c].duration;
|
|
3091
3097
|
l < h && (l = h);
|
|
3092
3098
|
}
|
|
3093
3099
|
return l;
|
|
@@ -3101,8 +3107,8 @@ function Ut() {
|
|
|
3101
3107
|
get: function() {
|
|
3102
3108
|
if (!this.notes.length)
|
|
3103
3109
|
return 0;
|
|
3104
|
-
for (var l = this.notes[this.notes.length - 1].ticks + this.notes[this.notes.length - 1].durationTicks,
|
|
3105
|
-
var h = this.notes[
|
|
3110
|
+
for (var l = this.notes[this.notes.length - 1].ticks + this.notes[this.notes.length - 1].durationTicks, c = 0; c < this.notes.length - 1; c++) {
|
|
3111
|
+
var h = this.notes[c].ticks + this.notes[c].durationTicks;
|
|
3106
3112
|
l < h && (l = h);
|
|
3107
3113
|
}
|
|
3108
3114
|
return l;
|
|
@@ -3110,18 +3116,18 @@ function Ut() {
|
|
|
3110
3116
|
enumerable: !1,
|
|
3111
3117
|
configurable: !0
|
|
3112
3118
|
}), u.prototype.fromJSON = function(l) {
|
|
3113
|
-
var
|
|
3119
|
+
var c = this;
|
|
3114
3120
|
this.name = l.name, this.channel = l.channel, this.instrument = new r.Instrument(void 0, this), this.instrument.fromJSON(l.instrument), l.endOfTrackTicks !== void 0 && (this.endOfTrackTicks = l.endOfTrackTicks);
|
|
3115
3121
|
for (var h in l.controlChanges)
|
|
3116
3122
|
l.controlChanges[h] && l.controlChanges[h].forEach(function(d) {
|
|
3117
|
-
|
|
3123
|
+
c.addCC({
|
|
3118
3124
|
number: d.number,
|
|
3119
3125
|
ticks: d.ticks,
|
|
3120
3126
|
value: d.value
|
|
3121
3127
|
});
|
|
3122
3128
|
});
|
|
3123
3129
|
l.notes.forEach(function(d) {
|
|
3124
|
-
|
|
3130
|
+
c.addNote({
|
|
3125
3131
|
durationTicks: d.durationTicks,
|
|
3126
3132
|
midi: d.midi,
|
|
3127
3133
|
ticks: d.ticks,
|
|
@@ -3129,8 +3135,8 @@ function Ut() {
|
|
|
3129
3135
|
});
|
|
3130
3136
|
});
|
|
3131
3137
|
}, u.prototype.toJSON = function() {
|
|
3132
|
-
for (var l = {},
|
|
3133
|
-
this.controlChanges.hasOwnProperty(
|
|
3138
|
+
for (var l = {}, c = 0; c < 127; c++)
|
|
3139
|
+
this.controlChanges.hasOwnProperty(c) && (l[c] = this.controlChanges[c].map(function(d) {
|
|
3134
3140
|
return d.toJSON();
|
|
3135
3141
|
}));
|
|
3136
3142
|
var h = {
|
|
@@ -3149,9 +3155,9 @@ function Ut() {
|
|
|
3149
3155
|
}, u;
|
|
3150
3156
|
})()
|
|
3151
3157
|
);
|
|
3152
|
-
return U.Track =
|
|
3158
|
+
return U.Track = o, U;
|
|
3153
3159
|
}
|
|
3154
|
-
var
|
|
3160
|
+
var A = {};
|
|
3155
3161
|
function Ze(i) {
|
|
3156
3162
|
var t = [];
|
|
3157
3163
|
return oe(i, t), t;
|
|
@@ -3168,137 +3174,137 @@ const Qe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3168
3174
|
}, Symbol.toStringTag, { value: "Module" })), Ye = /* @__PURE__ */ ze(Qe);
|
|
3169
3175
|
var Bt;
|
|
3170
3176
|
function tn() {
|
|
3171
|
-
if (Bt) return
|
|
3177
|
+
if (Bt) return A;
|
|
3172
3178
|
Bt = 1;
|
|
3173
|
-
var i =
|
|
3174
|
-
if (
|
|
3175
|
-
(T || !(
|
|
3176
|
-
return
|
|
3179
|
+
var i = A && A.__spreadArray || function(m, S, b) {
|
|
3180
|
+
if (b || arguments.length === 2) for (var p = 0, k = S.length, T; p < k; p++)
|
|
3181
|
+
(T || !(p in S)) && (T || (T = Array.prototype.slice.call(S, 0, p)), T[p] = S[p]);
|
|
3182
|
+
return m.concat(T || Array.prototype.slice.call(S));
|
|
3177
3183
|
};
|
|
3178
|
-
Object.defineProperty(
|
|
3184
|
+
Object.defineProperty(A, "__esModule", { value: !0 }), A.encode = void 0;
|
|
3179
3185
|
var t = re(), e = ut(), n = Ye;
|
|
3180
|
-
function r(
|
|
3186
|
+
function r(m, S) {
|
|
3181
3187
|
return [
|
|
3182
3188
|
{
|
|
3183
|
-
absoluteTime:
|
|
3184
|
-
channel:
|
|
3189
|
+
absoluteTime: m.ticks,
|
|
3190
|
+
channel: S,
|
|
3185
3191
|
deltaTime: 0,
|
|
3186
|
-
noteNumber:
|
|
3192
|
+
noteNumber: m.midi,
|
|
3187
3193
|
type: "noteOn",
|
|
3188
|
-
velocity: Math.floor(
|
|
3194
|
+
velocity: Math.floor(m.velocity * 127)
|
|
3189
3195
|
},
|
|
3190
3196
|
{
|
|
3191
|
-
absoluteTime:
|
|
3192
|
-
channel:
|
|
3197
|
+
absoluteTime: m.ticks + m.durationTicks,
|
|
3198
|
+
channel: S,
|
|
3193
3199
|
deltaTime: 0,
|
|
3194
|
-
noteNumber:
|
|
3200
|
+
noteNumber: m.midi,
|
|
3195
3201
|
type: "noteOff",
|
|
3196
|
-
velocity: Math.floor(
|
|
3202
|
+
velocity: Math.floor(m.noteOffVelocity * 127)
|
|
3197
3203
|
}
|
|
3198
3204
|
];
|
|
3199
3205
|
}
|
|
3200
|
-
function s(
|
|
3201
|
-
return (0, n.flatten)(
|
|
3202
|
-
return r(
|
|
3206
|
+
function s(m) {
|
|
3207
|
+
return (0, n.flatten)(m.notes.map(function(S) {
|
|
3208
|
+
return r(S, m.channel);
|
|
3203
3209
|
}));
|
|
3204
3210
|
}
|
|
3205
|
-
function a(
|
|
3211
|
+
function a(m, S) {
|
|
3206
3212
|
return {
|
|
3207
|
-
absoluteTime:
|
|
3208
|
-
channel:
|
|
3209
|
-
controllerType:
|
|
3213
|
+
absoluteTime: m.ticks,
|
|
3214
|
+
channel: S,
|
|
3215
|
+
controllerType: m.number,
|
|
3210
3216
|
deltaTime: 0,
|
|
3211
3217
|
type: "controller",
|
|
3212
|
-
value: Math.floor(
|
|
3218
|
+
value: Math.floor(m.value * 127)
|
|
3213
3219
|
};
|
|
3214
3220
|
}
|
|
3215
|
-
function
|
|
3216
|
-
for (var
|
|
3217
|
-
|
|
3218
|
-
|
|
3221
|
+
function o(m) {
|
|
3222
|
+
for (var S = [], b = 0; b < 127; b++)
|
|
3223
|
+
m.controlChanges.hasOwnProperty(b) && m.controlChanges[b].forEach(function(p) {
|
|
3224
|
+
S.push(a(p, m.channel));
|
|
3219
3225
|
});
|
|
3220
|
-
return
|
|
3226
|
+
return S;
|
|
3221
3227
|
}
|
|
3222
|
-
function u(
|
|
3228
|
+
function u(m, S) {
|
|
3223
3229
|
return {
|
|
3224
|
-
absoluteTime:
|
|
3225
|
-
channel:
|
|
3230
|
+
absoluteTime: m.ticks,
|
|
3231
|
+
channel: S,
|
|
3226
3232
|
deltaTime: 0,
|
|
3227
3233
|
type: "pitchBend",
|
|
3228
|
-
value:
|
|
3234
|
+
value: m.value
|
|
3229
3235
|
};
|
|
3230
3236
|
}
|
|
3231
|
-
function l(
|
|
3232
|
-
var
|
|
3233
|
-
return
|
|
3234
|
-
|
|
3235
|
-
}),
|
|
3237
|
+
function l(m) {
|
|
3238
|
+
var S = [];
|
|
3239
|
+
return m.pitchBends.forEach(function(b) {
|
|
3240
|
+
S.push(u(b, m.channel));
|
|
3241
|
+
}), S;
|
|
3236
3242
|
}
|
|
3237
|
-
function
|
|
3243
|
+
function c(m) {
|
|
3238
3244
|
return {
|
|
3239
3245
|
absoluteTime: 0,
|
|
3240
|
-
channel:
|
|
3246
|
+
channel: m.channel,
|
|
3241
3247
|
deltaTime: 0,
|
|
3242
|
-
programNumber:
|
|
3248
|
+
programNumber: m.instrument.number,
|
|
3243
3249
|
type: "programChange"
|
|
3244
3250
|
};
|
|
3245
3251
|
}
|
|
3246
|
-
function h(
|
|
3252
|
+
function h(m) {
|
|
3247
3253
|
return {
|
|
3248
3254
|
absoluteTime: 0,
|
|
3249
3255
|
deltaTime: 0,
|
|
3250
3256
|
meta: !0,
|
|
3251
|
-
text:
|
|
3257
|
+
text: m,
|
|
3252
3258
|
type: "trackName"
|
|
3253
3259
|
};
|
|
3254
3260
|
}
|
|
3255
|
-
function d(
|
|
3261
|
+
function d(m) {
|
|
3256
3262
|
return {
|
|
3257
|
-
absoluteTime:
|
|
3263
|
+
absoluteTime: m.ticks,
|
|
3258
3264
|
deltaTime: 0,
|
|
3259
3265
|
meta: !0,
|
|
3260
|
-
microsecondsPerBeat: Math.floor(6e7 /
|
|
3266
|
+
microsecondsPerBeat: Math.floor(6e7 / m.bpm),
|
|
3261
3267
|
type: "setTempo"
|
|
3262
3268
|
};
|
|
3263
3269
|
}
|
|
3264
|
-
function f(
|
|
3270
|
+
function f(m) {
|
|
3265
3271
|
return {
|
|
3266
|
-
absoluteTime:
|
|
3272
|
+
absoluteTime: m.ticks,
|
|
3267
3273
|
deltaTime: 0,
|
|
3268
|
-
denominator:
|
|
3274
|
+
denominator: m.timeSignature[1],
|
|
3269
3275
|
meta: !0,
|
|
3270
3276
|
metronome: 24,
|
|
3271
|
-
numerator:
|
|
3277
|
+
numerator: m.timeSignature[0],
|
|
3272
3278
|
thirtyseconds: 8,
|
|
3273
3279
|
type: "timeSignature"
|
|
3274
3280
|
};
|
|
3275
3281
|
}
|
|
3276
|
-
function
|
|
3277
|
-
var
|
|
3282
|
+
function y(m) {
|
|
3283
|
+
var S = e.keySignatureKeys.indexOf(m.key);
|
|
3278
3284
|
return {
|
|
3279
|
-
absoluteTime:
|
|
3285
|
+
absoluteTime: m.ticks,
|
|
3280
3286
|
deltaTime: 0,
|
|
3281
|
-
key:
|
|
3287
|
+
key: S + 7,
|
|
3282
3288
|
meta: !0,
|
|
3283
|
-
scale:
|
|
3289
|
+
scale: m.scale === "major" ? 0 : 1,
|
|
3284
3290
|
type: "keySignature"
|
|
3285
3291
|
};
|
|
3286
3292
|
}
|
|
3287
|
-
function
|
|
3293
|
+
function v(m) {
|
|
3288
3294
|
return {
|
|
3289
|
-
absoluteTime:
|
|
3295
|
+
absoluteTime: m.ticks,
|
|
3290
3296
|
deltaTime: 0,
|
|
3291
3297
|
meta: !0,
|
|
3292
|
-
text:
|
|
3293
|
-
type:
|
|
3298
|
+
text: m.text,
|
|
3299
|
+
type: m.type
|
|
3294
3300
|
};
|
|
3295
3301
|
}
|
|
3296
|
-
function
|
|
3297
|
-
var
|
|
3302
|
+
function g(m) {
|
|
3303
|
+
var S = {
|
|
3298
3304
|
header: {
|
|
3299
3305
|
format: 1,
|
|
3300
|
-
numTracks:
|
|
3301
|
-
ticksPerBeat:
|
|
3306
|
+
numTracks: m.tracks.length + 1,
|
|
3307
|
+
ticksPerBeat: m.header.ppq
|
|
3302
3308
|
},
|
|
3303
3309
|
tracks: i([
|
|
3304
3310
|
i(i(i(i([
|
|
@@ -3307,162 +3313,162 @@ function tn() {
|
|
|
3307
3313
|
absoluteTime: 0,
|
|
3308
3314
|
deltaTime: 0,
|
|
3309
3315
|
meta: !0,
|
|
3310
|
-
text:
|
|
3316
|
+
text: m.header.name,
|
|
3311
3317
|
type: "trackName"
|
|
3312
3318
|
}
|
|
3313
|
-
],
|
|
3314
|
-
return
|
|
3315
|
-
}), !0),
|
|
3316
|
-
return b
|
|
3317
|
-
}), !0),
|
|
3318
|
-
return d(
|
|
3319
|
-
}), !0),
|
|
3320
|
-
return f(
|
|
3319
|
+
], m.header.keySignatures.map(function(b) {
|
|
3320
|
+
return y(b);
|
|
3321
|
+
}), !0), m.header.meta.map(function(b) {
|
|
3322
|
+
return v(b);
|
|
3323
|
+
}), !0), m.header.tempos.map(function(b) {
|
|
3324
|
+
return d(b);
|
|
3325
|
+
}), !0), m.header.timeSignatures.map(function(b) {
|
|
3326
|
+
return f(b);
|
|
3321
3327
|
}), !0)
|
|
3322
|
-
],
|
|
3328
|
+
], m.tracks.map(function(b) {
|
|
3323
3329
|
return i(i(i([
|
|
3324
3330
|
// Add the name
|
|
3325
|
-
h(
|
|
3331
|
+
h(b.name),
|
|
3326
3332
|
// the instrument
|
|
3327
|
-
|
|
3328
|
-
], s(
|
|
3333
|
+
c(b)
|
|
3334
|
+
], s(b), !0), o(b), !0), l(b), !0);
|
|
3329
3335
|
}), !0)
|
|
3330
3336
|
};
|
|
3331
|
-
return
|
|
3332
|
-
|
|
3333
|
-
return
|
|
3337
|
+
return S.tracks = S.tracks.map(function(b) {
|
|
3338
|
+
b = b.sort(function(k, T) {
|
|
3339
|
+
return k.absoluteTime - T.absoluteTime;
|
|
3334
3340
|
});
|
|
3335
|
-
var
|
|
3336
|
-
return
|
|
3337
|
-
|
|
3338
|
-
}),
|
|
3341
|
+
var p = 0;
|
|
3342
|
+
return b.forEach(function(k) {
|
|
3343
|
+
k.deltaTime = k.absoluteTime - p, p = k.absoluteTime, delete k.absoluteTime;
|
|
3344
|
+
}), b.push({
|
|
3339
3345
|
deltaTime: 0,
|
|
3340
3346
|
meta: !0,
|
|
3341
3347
|
type: "endOfTrack"
|
|
3342
|
-
}),
|
|
3343
|
-
}), new Uint8Array((0, t.writeMidi)(
|
|
3348
|
+
}), b;
|
|
3349
|
+
}), new Uint8Array((0, t.writeMidi)(S));
|
|
3344
3350
|
}
|
|
3345
|
-
return
|
|
3351
|
+
return A.encode = g, A;
|
|
3346
3352
|
}
|
|
3347
3353
|
var Dt;
|
|
3348
3354
|
function en() {
|
|
3349
3355
|
return Dt || (Dt = 1, (function(i) {
|
|
3350
|
-
var t =
|
|
3351
|
-
function
|
|
3352
|
-
return
|
|
3353
|
-
|
|
3356
|
+
var t = P && P.__awaiter || function(h, d, f, y) {
|
|
3357
|
+
function v(g) {
|
|
3358
|
+
return g instanceof f ? g : new f(function(m) {
|
|
3359
|
+
m(g);
|
|
3354
3360
|
});
|
|
3355
3361
|
}
|
|
3356
|
-
return new (f || (f = Promise))(function(
|
|
3357
|
-
function
|
|
3362
|
+
return new (f || (f = Promise))(function(g, m) {
|
|
3363
|
+
function S(k) {
|
|
3358
3364
|
try {
|
|
3359
|
-
|
|
3365
|
+
p(y.next(k));
|
|
3360
3366
|
} catch (T) {
|
|
3361
|
-
|
|
3367
|
+
m(T);
|
|
3362
3368
|
}
|
|
3363
3369
|
}
|
|
3364
|
-
function
|
|
3370
|
+
function b(k) {
|
|
3365
3371
|
try {
|
|
3366
|
-
|
|
3372
|
+
p(y.throw(k));
|
|
3367
3373
|
} catch (T) {
|
|
3368
|
-
|
|
3374
|
+
m(T);
|
|
3369
3375
|
}
|
|
3370
3376
|
}
|
|
3371
|
-
function
|
|
3372
|
-
|
|
3377
|
+
function p(k) {
|
|
3378
|
+
k.done ? g(k.value) : v(k.value).then(S, b);
|
|
3373
3379
|
}
|
|
3374
|
-
|
|
3380
|
+
p((y = y.apply(h, d || [])).next());
|
|
3375
3381
|
});
|
|
3376
|
-
}, e =
|
|
3382
|
+
}, e = P && P.__generator || function(h, d) {
|
|
3377
3383
|
var f = { label: 0, sent: function() {
|
|
3378
|
-
if (
|
|
3379
|
-
return
|
|
3380
|
-
}, trys: [], ops: [] },
|
|
3381
|
-
return
|
|
3384
|
+
if (g[0] & 1) throw g[1];
|
|
3385
|
+
return g[1];
|
|
3386
|
+
}, trys: [], ops: [] }, y, v, g, m;
|
|
3387
|
+
return m = { next: S(0), throw: S(1), return: S(2) }, typeof Symbol == "function" && (m[Symbol.iterator] = function() {
|
|
3382
3388
|
return this;
|
|
3383
|
-
}),
|
|
3384
|
-
function
|
|
3385
|
-
return function(
|
|
3386
|
-
return
|
|
3389
|
+
}), m;
|
|
3390
|
+
function S(p) {
|
|
3391
|
+
return function(k) {
|
|
3392
|
+
return b([p, k]);
|
|
3387
3393
|
};
|
|
3388
3394
|
}
|
|
3389
|
-
function
|
|
3390
|
-
if (
|
|
3395
|
+
function b(p) {
|
|
3396
|
+
if (y) throw new TypeError("Generator is already executing.");
|
|
3391
3397
|
for (; f; ) try {
|
|
3392
|
-
if (
|
|
3393
|
-
switch (
|
|
3398
|
+
if (y = 1, v && (g = p[0] & 2 ? v.return : p[0] ? v.throw || ((g = v.return) && g.call(v), 0) : v.next) && !(g = g.call(v, p[1])).done) return g;
|
|
3399
|
+
switch (v = 0, g && (p = [p[0] & 2, g.value]), p[0]) {
|
|
3394
3400
|
case 0:
|
|
3395
3401
|
case 1:
|
|
3396
|
-
|
|
3402
|
+
g = p;
|
|
3397
3403
|
break;
|
|
3398
3404
|
case 4:
|
|
3399
|
-
return f.label++, { value:
|
|
3405
|
+
return f.label++, { value: p[1], done: !1 };
|
|
3400
3406
|
case 5:
|
|
3401
|
-
f.label++,
|
|
3407
|
+
f.label++, v = p[1], p = [0];
|
|
3402
3408
|
continue;
|
|
3403
3409
|
case 7:
|
|
3404
|
-
|
|
3410
|
+
p = f.ops.pop(), f.trys.pop();
|
|
3405
3411
|
continue;
|
|
3406
3412
|
default:
|
|
3407
|
-
if (
|
|
3413
|
+
if (g = f.trys, !(g = g.length > 0 && g[g.length - 1]) && (p[0] === 6 || p[0] === 2)) {
|
|
3408
3414
|
f = 0;
|
|
3409
3415
|
continue;
|
|
3410
3416
|
}
|
|
3411
|
-
if (
|
|
3412
|
-
f.label =
|
|
3417
|
+
if (p[0] === 3 && (!g || p[1] > g[0] && p[1] < g[3])) {
|
|
3418
|
+
f.label = p[1];
|
|
3413
3419
|
break;
|
|
3414
3420
|
}
|
|
3415
|
-
if (
|
|
3416
|
-
f.label =
|
|
3421
|
+
if (p[0] === 6 && f.label < g[1]) {
|
|
3422
|
+
f.label = g[1], g = p;
|
|
3417
3423
|
break;
|
|
3418
3424
|
}
|
|
3419
|
-
if (
|
|
3420
|
-
f.label =
|
|
3425
|
+
if (g && f.label < g[2]) {
|
|
3426
|
+
f.label = g[2], f.ops.push(p);
|
|
3421
3427
|
break;
|
|
3422
3428
|
}
|
|
3423
|
-
|
|
3429
|
+
g[2] && f.ops.pop(), f.trys.pop();
|
|
3424
3430
|
continue;
|
|
3425
3431
|
}
|
|
3426
|
-
|
|
3427
|
-
} catch (
|
|
3428
|
-
|
|
3432
|
+
p = d.call(h, f);
|
|
3433
|
+
} catch (k) {
|
|
3434
|
+
p = [6, k], v = 0;
|
|
3429
3435
|
} finally {
|
|
3430
|
-
|
|
3436
|
+
y = g = 0;
|
|
3431
3437
|
}
|
|
3432
|
-
if (
|
|
3433
|
-
return { value:
|
|
3438
|
+
if (p[0] & 5) throw p[1];
|
|
3439
|
+
return { value: p[0] ? p[1] : void 0, done: !0 };
|
|
3434
3440
|
}
|
|
3435
3441
|
};
|
|
3436
3442
|
Object.defineProperty(i, "__esModule", { value: !0 }), i.Header = i.Track = i.Midi = void 0;
|
|
3437
|
-
var n = re(), r = ut(), s = Ut(), a = tn(),
|
|
3443
|
+
var n = re(), r = ut(), s = Ut(), a = tn(), o = (
|
|
3438
3444
|
/** @class */
|
|
3439
3445
|
(function() {
|
|
3440
3446
|
function h(d) {
|
|
3441
|
-
var f = this,
|
|
3447
|
+
var f = this, y = null;
|
|
3442
3448
|
if (d) {
|
|
3443
|
-
var
|
|
3444
|
-
|
|
3445
|
-
var
|
|
3446
|
-
|
|
3447
|
-
|
|
3449
|
+
var v = d instanceof ArrayBuffer ? new Uint8Array(d) : d;
|
|
3450
|
+
y = (0, n.parseMidi)(v), y.tracks.forEach(function(g) {
|
|
3451
|
+
var m = 0;
|
|
3452
|
+
g.forEach(function(S) {
|
|
3453
|
+
m += S.deltaTime, S.absoluteTime = m;
|
|
3448
3454
|
});
|
|
3449
|
-
}),
|
|
3455
|
+
}), y.tracks = c(y.tracks);
|
|
3450
3456
|
}
|
|
3451
|
-
this.header = new r.Header(
|
|
3452
|
-
return new s.Track(
|
|
3453
|
-
}),
|
|
3457
|
+
this.header = new r.Header(y), this.tracks = [], d && (this.tracks = y.tracks.map(function(g) {
|
|
3458
|
+
return new s.Track(g, f.header);
|
|
3459
|
+
}), y.header.format === 1 && this.tracks[0].duration === 0 && this.tracks.shift());
|
|
3454
3460
|
}
|
|
3455
3461
|
return h.fromUrl = function(d) {
|
|
3456
3462
|
return t(this, void 0, void 0, function() {
|
|
3457
|
-
var f,
|
|
3458
|
-
return e(this, function(
|
|
3459
|
-
switch (
|
|
3463
|
+
var f, y;
|
|
3464
|
+
return e(this, function(v) {
|
|
3465
|
+
switch (v.label) {
|
|
3460
3466
|
case 0:
|
|
3461
3467
|
return [4, fetch(d)];
|
|
3462
3468
|
case 1:
|
|
3463
|
-
return f =
|
|
3469
|
+
return f = v.sent(), f.ok ? [4, f.arrayBuffer()] : [3, 3];
|
|
3464
3470
|
case 2:
|
|
3465
|
-
return
|
|
3471
|
+
return y = v.sent(), [2, new h(y)];
|
|
3466
3472
|
case 3:
|
|
3467
3473
|
throw new Error("Could not load '".concat(d, "'"));
|
|
3468
3474
|
}
|
|
@@ -3518,9 +3524,9 @@ function en() {
|
|
|
3518
3524
|
};
|
|
3519
3525
|
}, h.prototype.fromJSON = function(d) {
|
|
3520
3526
|
var f = this;
|
|
3521
|
-
this.header = new r.Header(), this.header.fromJSON(d.header), this.tracks = d.tracks.map(function(
|
|
3522
|
-
var
|
|
3523
|
-
return
|
|
3527
|
+
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);
|
|
3529
|
+
return v.fromJSON(y), v;
|
|
3524
3530
|
});
|
|
3525
3531
|
}, h.prototype.clone = function() {
|
|
3526
3532
|
var d = new h();
|
|
@@ -3528,7 +3534,7 @@ function en() {
|
|
|
3528
3534
|
}, h;
|
|
3529
3535
|
})()
|
|
3530
3536
|
);
|
|
3531
|
-
i.Midi =
|
|
3537
|
+
i.Midi = o;
|
|
3532
3538
|
var u = Ut();
|
|
3533
3539
|
Object.defineProperty(i, "Track", { enumerable: !0, get: function() {
|
|
3534
3540
|
return u.Track;
|
|
@@ -3537,20 +3543,20 @@ function en() {
|
|
|
3537
3543
|
Object.defineProperty(i, "Header", { enumerable: !0, get: function() {
|
|
3538
3544
|
return l.Header;
|
|
3539
3545
|
} });
|
|
3540
|
-
function
|
|
3546
|
+
function c(h) {
|
|
3541
3547
|
for (var d = [], f = 0; f < h.length; f++)
|
|
3542
|
-
for (var
|
|
3543
|
-
var
|
|
3544
|
-
if (
|
|
3545
|
-
|
|
3546
|
-
var T =
|
|
3547
|
-
|
|
3548
|
+
for (var y = d.length, v = /* @__PURE__ */ new Map(), g = Array(16).fill(0), m = 0, S = h[f]; m < S.length; m++) {
|
|
3549
|
+
var b = S[m], p = y, k = b.channel;
|
|
3550
|
+
if (k !== void 0) {
|
|
3551
|
+
b.type === "programChange" && (g[k] = b.programNumber);
|
|
3552
|
+
var T = g[k], E = "".concat(T, " ").concat(k);
|
|
3553
|
+
v.has(E) ? p = v.get(E) : (p = y + v.size, v.set(E, p));
|
|
3548
3554
|
}
|
|
3549
|
-
d[
|
|
3555
|
+
d[p] || d.push([]), d[p].push(b);
|
|
3550
3556
|
}
|
|
3551
3557
|
return d;
|
|
3552
3558
|
}
|
|
3553
|
-
})(
|
|
3559
|
+
})(P)), P;
|
|
3554
3560
|
}
|
|
3555
3561
|
var nn = en();
|
|
3556
3562
|
const sn = [
|
|
@@ -3703,19 +3709,19 @@ function Gt(i) {
|
|
|
3703
3709
|
return sn[i] ?? `Program ${i}`;
|
|
3704
3710
|
}
|
|
3705
3711
|
function rn(i, t = {}) {
|
|
3706
|
-
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],
|
|
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();
|
|
3707
3713
|
for (const h of n.tracks) {
|
|
3708
|
-
const d = h.channel, f = h.instrument.number,
|
|
3709
|
-
u.has(d) || u.set(d, { notes: [], programNumber: f, name:
|
|
3710
|
-
const
|
|
3711
|
-
h.name && !
|
|
3712
|
-
for (const
|
|
3713
|
-
|
|
3714
|
-
midi:
|
|
3715
|
-
name:
|
|
3716
|
-
time:
|
|
3717
|
-
duration:
|
|
3718
|
-
velocity:
|
|
3714
|
+
const d = h.channel, f = h.instrument.number, y = h.name || Gt(f);
|
|
3715
|
+
u.has(d) || u.set(d, { notes: [], programNumber: f, name: y });
|
|
3716
|
+
const v = u.get(d);
|
|
3717
|
+
h.name && !v.name.startsWith(h.name) && (v.name = h.name);
|
|
3718
|
+
for (const g of h.notes)
|
|
3719
|
+
v.notes.push({
|
|
3720
|
+
midi: g.midi,
|
|
3721
|
+
name: g.name,
|
|
3722
|
+
time: g.time,
|
|
3723
|
+
duration: g.duration,
|
|
3724
|
+
velocity: g.velocity,
|
|
3719
3725
|
channel: d
|
|
3720
3726
|
});
|
|
3721
3727
|
}
|
|
@@ -3731,7 +3737,7 @@ function rn(i, t = {}) {
|
|
|
3731
3737
|
h.push(...d);
|
|
3732
3738
|
}), h.sort((d, f) => d.time - f.time), {
|
|
3733
3739
|
tracks: [{
|
|
3734
|
-
name:
|
|
3740
|
+
name: o,
|
|
3735
3741
|
notes: h,
|
|
3736
3742
|
duration: l,
|
|
3737
3743
|
channel: 0,
|
|
@@ -3739,32 +3745,32 @@ function rn(i, t = {}) {
|
|
|
3739
3745
|
programNumber: 0
|
|
3740
3746
|
}],
|
|
3741
3747
|
duration: l,
|
|
3742
|
-
name:
|
|
3748
|
+
name: o,
|
|
3743
3749
|
bpm: r,
|
|
3744
3750
|
timeSignature: a
|
|
3745
3751
|
};
|
|
3746
3752
|
}
|
|
3747
|
-
const
|
|
3748
|
-
return u.forEach(({ notes: h, programNumber: d, name: f },
|
|
3753
|
+
const c = [];
|
|
3754
|
+
return u.forEach(({ notes: h, programNumber: d, name: f }, y) => {
|
|
3749
3755
|
if (h.length === 0) return;
|
|
3750
|
-
h.sort((
|
|
3751
|
-
let
|
|
3752
|
-
for (const
|
|
3753
|
-
const
|
|
3754
|
-
|
|
3756
|
+
h.sort((g, m) => g.time - m.time);
|
|
3757
|
+
let v = 0;
|
|
3758
|
+
for (const g of h) {
|
|
3759
|
+
const m = g.time + g.duration;
|
|
3760
|
+
m > v && (v = m);
|
|
3755
3761
|
}
|
|
3756
|
-
|
|
3762
|
+
c.push({
|
|
3757
3763
|
name: f,
|
|
3758
3764
|
notes: h,
|
|
3759
|
-
duration:
|
|
3760
|
-
channel:
|
|
3761
|
-
instrument:
|
|
3765
|
+
duration: v,
|
|
3766
|
+
channel: y,
|
|
3767
|
+
instrument: y === 9 ? "Percussion" : Gt(d),
|
|
3762
3768
|
programNumber: d
|
|
3763
3769
|
});
|
|
3764
3770
|
}), {
|
|
3765
|
-
tracks:
|
|
3771
|
+
tracks: c,
|
|
3766
3772
|
duration: l,
|
|
3767
|
-
name:
|
|
3773
|
+
name: o,
|
|
3768
3774
|
bpm: r,
|
|
3769
3775
|
timeSignature: a
|
|
3770
3776
|
};
|
|
@@ -4004,37 +4010,37 @@ class fn {
|
|
|
4004
4010
|
constructor(t = {}) {
|
|
4005
4011
|
this.events = new hn(), this.plugins = new dn({
|
|
4006
4012
|
events: this.events,
|
|
4007
|
-
requestAssistant: (
|
|
4008
|
-
this.events.emit("assistant:request", { assistantId:
|
|
4013
|
+
requestAssistant: (o, u, l) => {
|
|
4014
|
+
this.events.emit("assistant:request", { assistantId: o, action: u, payload: l });
|
|
4009
4015
|
}
|
|
4010
4016
|
}), this.transport = {
|
|
4011
|
-
play: (
|
|
4017
|
+
play: (o, u) => this.playlist.play(o, u),
|
|
4012
4018
|
pause: () => this.playlist.pause(),
|
|
4013
4019
|
stop: () => this.playlist.stop(),
|
|
4014
|
-
seek: (
|
|
4015
|
-
this.playlist.seek(
|
|
4020
|
+
seek: (o) => {
|
|
4021
|
+
this.playlist.seek(o), this.events.emit("transport:seek", o);
|
|
4016
4022
|
},
|
|
4017
4023
|
getCurrentTime: () => this.playlist.getCurrentTime()
|
|
4018
4024
|
}, this.tracks = {
|
|
4019
|
-
set: (
|
|
4020
|
-
this.playlist.setTracks(
|
|
4025
|
+
set: (o) => {
|
|
4026
|
+
this.playlist.setTracks(o), this.events.emit(
|
|
4021
4027
|
"tracks:set",
|
|
4022
|
-
|
|
4028
|
+
o.map((u) => u.id)
|
|
4023
4029
|
);
|
|
4024
4030
|
},
|
|
4025
|
-
add: (
|
|
4026
|
-
this.playlist.addTrack(
|
|
4031
|
+
add: (o) => {
|
|
4032
|
+
this.playlist.addTrack(o), this.events.emit("tracks:add", o.id);
|
|
4027
4033
|
},
|
|
4028
|
-
remove: (
|
|
4029
|
-
this.playlist.removeTrack(
|
|
4034
|
+
remove: (o) => {
|
|
4035
|
+
this.playlist.removeTrack(o), this.events.emit("tracks:remove", o);
|
|
4030
4036
|
},
|
|
4031
|
-
select: (
|
|
4037
|
+
select: (o) => this.playlist.selectTrack(o)
|
|
4032
4038
|
}, this.state = {
|
|
4033
4039
|
getSnapshot: () => this.playlist.getState()
|
|
4034
|
-
}, this.handleStateChange = (
|
|
4035
|
-
this.events.emit("statechange",
|
|
4036
|
-
}, this.handleTimeUpdate = (
|
|
4037
|
-
this.events.emit("timeupdate",
|
|
4040
|
+
}, this.handleStateChange = (o) => {
|
|
4041
|
+
this.events.emit("statechange", o);
|
|
4042
|
+
}, this.handleTimeUpdate = (o) => {
|
|
4043
|
+
this.events.emit("timeupdate", o);
|
|
4038
4044
|
}, this.handlePlay = () => {
|
|
4039
4045
|
this.events.emit("play");
|
|
4040
4046
|
}, this.handlePause = () => {
|
|
@@ -4070,16 +4076,16 @@ function Ss(i = {}) {
|
|
|
4070
4076
|
class pn {
|
|
4071
4077
|
constructor(t) {
|
|
4072
4078
|
this._loaded = !1;
|
|
4073
|
-
const { samples: e, baseUrl: n, release: r = 0.1, attack: s = 0, onload: a, volume:
|
|
4079
|
+
const { samples: e, baseUrl: n, release: r = 0.1, attack: s = 0, onload: a, volume: o = 0, destination: u } = t;
|
|
4074
4080
|
let l;
|
|
4075
|
-
this._loadPromise = new Promise((
|
|
4076
|
-
l =
|
|
4081
|
+
this._loadPromise = new Promise((c) => {
|
|
4082
|
+
l = c;
|
|
4077
4083
|
}), this.sampler = new fe({
|
|
4078
4084
|
urls: e,
|
|
4079
4085
|
baseUrl: n,
|
|
4080
4086
|
release: r,
|
|
4081
4087
|
attack: s,
|
|
4082
|
-
volume:
|
|
4088
|
+
volume: o,
|
|
4083
4089
|
onload: () => {
|
|
4084
4090
|
this._loaded = !0, l(), a?.();
|
|
4085
4091
|
}
|
|
@@ -4183,12 +4189,12 @@ class ks {
|
|
|
4183
4189
|
constructor(t) {
|
|
4184
4190
|
const { instrument: e, clips: n, track: r, effects: s, destination: a } = t;
|
|
4185
4191
|
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);
|
|
4186
|
-
const
|
|
4192
|
+
const o = a ?? O();
|
|
4187
4193
|
if (s) {
|
|
4188
|
-
const u = s(this.muteGain,
|
|
4194
|
+
const u = s(this.muteGain, o);
|
|
4189
4195
|
u && (this.effectsCleanup = u);
|
|
4190
4196
|
} else
|
|
4191
|
-
this.muteGain.connect(
|
|
4197
|
+
this.muteGain.connect(o);
|
|
4192
4198
|
this._duration = this.calculateDuration(n), this.scheduledClips = this.scheduleClips(n);
|
|
4193
4199
|
}
|
|
4194
4200
|
gainToDb(t) {
|
|
@@ -4203,26 +4209,26 @@ class ks {
|
|
|
4203
4209
|
}
|
|
4204
4210
|
scheduleClips(t) {
|
|
4205
4211
|
return t.map((e) => {
|
|
4206
|
-
const n = e.notes.filter((
|
|
4207
|
-
const u =
|
|
4208
|
-
return
|
|
4209
|
-
}), r = this.startTime + e.startTime, s = n.map((
|
|
4210
|
-
const u =
|
|
4211
|
-
|
|
4212
|
+
const n = e.notes.filter((o) => {
|
|
4213
|
+
const u = o.time + o.duration;
|
|
4214
|
+
return o.time < e.offset + e.duration && u > e.offset;
|
|
4215
|
+
}), r = this.startTime + e.startTime, s = n.map((o) => {
|
|
4216
|
+
const u = o.time - e.offset, l = Math.max(0, u), c = Math.min(
|
|
4217
|
+
o.duration - Math.max(0, e.offset - o.time),
|
|
4212
4218
|
e.duration - l
|
|
4213
4219
|
);
|
|
4214
4220
|
return {
|
|
4215
4221
|
time: r + l,
|
|
4216
|
-
note:
|
|
4217
|
-
midi:
|
|
4218
|
-
duration: Math.max(0.01,
|
|
4219
|
-
velocity:
|
|
4222
|
+
note: o.name ?? this.midiToNoteName(o.midi),
|
|
4223
|
+
midi: o.midi,
|
|
4224
|
+
duration: Math.max(0.01, c),
|
|
4225
|
+
velocity: o.velocity
|
|
4220
4226
|
};
|
|
4221
|
-
}), a = new lt((
|
|
4227
|
+
}), a = new lt((o, u) => {
|
|
4222
4228
|
this._muted || this.instrument.triggerAttackRelease(
|
|
4223
4229
|
u.note ?? u.midi,
|
|
4224
4230
|
u.duration,
|
|
4225
|
-
|
|
4231
|
+
o,
|
|
4226
4232
|
u.velocity
|
|
4227
4233
|
);
|
|
4228
4234
|
}, s);
|
|
@@ -4356,7 +4362,7 @@ function mn(i) {
|
|
|
4356
4362
|
case "bitcrusher":
|
|
4357
4363
|
return new Lt(t.bits ?? 8);
|
|
4358
4364
|
case "pitchshift":
|
|
4359
|
-
return new
|
|
4365
|
+
return new qt({
|
|
4360
4366
|
pitch: t.pitch ?? 0,
|
|
4361
4367
|
wet: t.wet ?? 1
|
|
4362
4368
|
});
|
|
@@ -4369,11 +4375,11 @@ class gn {
|
|
|
4369
4375
|
this.effects = [];
|
|
4370
4376
|
const { effects: e, mix: n = 1 } = t;
|
|
4371
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) => {
|
|
4372
|
-
const a = r.id ?? `${r.type}-${s}`,
|
|
4378
|
+
const a = r.id ?? `${r.type}-${s}`, o = mn(r), u = new C(r.bypassed ? 0 : 1);
|
|
4373
4379
|
this.effects.push({
|
|
4374
4380
|
id: a,
|
|
4375
4381
|
type: r.type,
|
|
4376
|
-
node:
|
|
4382
|
+
node: o,
|
|
4377
4383
|
bypassGain: u,
|
|
4378
4384
|
bypassed: r.bypassed ?? !1
|
|
4379
4385
|
});
|
|
@@ -4438,8 +4444,8 @@ class gn {
|
|
|
4438
4444
|
const r = n.node;
|
|
4439
4445
|
for (const [s, a] of Object.entries(e))
|
|
4440
4446
|
if (s in r) {
|
|
4441
|
-
const
|
|
4442
|
-
|
|
4447
|
+
const o = r[s];
|
|
4448
|
+
o && typeof o == "object" && "value" in o ? o.value = a : r[s] = a;
|
|
4443
4449
|
}
|
|
4444
4450
|
}
|
|
4445
4451
|
/**
|
|
@@ -4551,7 +4557,7 @@ function st(i, t = {}) {
|
|
|
4551
4557
|
case "bitcrusher":
|
|
4552
4558
|
return new Lt(t.bits ?? 8);
|
|
4553
4559
|
case "pitchshift":
|
|
4554
|
-
return new
|
|
4560
|
+
return new qt({
|
|
4555
4561
|
pitch: t.pitch ?? 0,
|
|
4556
4562
|
wet: t.wet ?? 1
|
|
4557
4563
|
});
|
|
@@ -4559,7 +4565,7 @@ function st(i, t = {}) {
|
|
|
4559
4565
|
throw new Error(`Unknown effect type: ${i}`);
|
|
4560
4566
|
}
|
|
4561
4567
|
}
|
|
4562
|
-
let
|
|
4568
|
+
let Rt = 0;
|
|
4563
4569
|
class yn {
|
|
4564
4570
|
constructor(t = {}) {
|
|
4565
4571
|
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);
|
|
@@ -4617,7 +4623,7 @@ class yn {
|
|
|
4617
4623
|
insert(t, e = {}) {
|
|
4618
4624
|
if (this.slots.length >= this.maxSlots)
|
|
4619
4625
|
throw new Error(`Maximum number of effect slots (${this.maxSlots}) reached`);
|
|
4620
|
-
const n = `slot-${++
|
|
4626
|
+
const n = `slot-${++Rt}`, r = st(t, e);
|
|
4621
4627
|
return this.slots.push({
|
|
4622
4628
|
id: n,
|
|
4623
4629
|
type: t,
|
|
@@ -4633,7 +4639,7 @@ class yn {
|
|
|
4633
4639
|
insertAt(t, e, n = {}) {
|
|
4634
4640
|
if (this.slots.length >= this.maxSlots)
|
|
4635
4641
|
throw new Error(`Maximum number of effect slots (${this.maxSlots}) reached`);
|
|
4636
|
-
const r = `slot-${++
|
|
4642
|
+
const r = `slot-${++Rt}`, s = st(e, n), a = Math.max(0, Math.min(t, this.slots.length));
|
|
4637
4643
|
return this.slots.splice(a, 0, {
|
|
4638
4644
|
id: r,
|
|
4639
4645
|
type: e,
|
|
@@ -4685,8 +4691,8 @@ class yn {
|
|
|
4685
4691
|
const r = n.node;
|
|
4686
4692
|
for (const [s, a] of Object.entries(e))
|
|
4687
4693
|
if (s in r) {
|
|
4688
|
-
const
|
|
4689
|
-
|
|
4694
|
+
const o = r[s];
|
|
4695
|
+
o && typeof o == "object" && "value" in o ? o.value = a : r[s] = a;
|
|
4690
4696
|
}
|
|
4691
4697
|
return !0;
|
|
4692
4698
|
}
|
|
@@ -4701,7 +4707,7 @@ class yn {
|
|
|
4701
4707
|
*/
|
|
4702
4708
|
replace(t, e, n = {}) {
|
|
4703
4709
|
let r;
|
|
4704
|
-
if (typeof t == "number" ? r = t : r = this.slots.findIndex((
|
|
4710
|
+
if (typeof t == "number" ? r = t : r = this.slots.findIndex((o) => o.id === t), r < 0 || r >= this.slots.length) return !1;
|
|
4705
4711
|
const s = this.slots[r];
|
|
4706
4712
|
s.node.dispose();
|
|
4707
4713
|
const a = st(e, n);
|
|
@@ -4771,9 +4777,9 @@ class vn {
|
|
|
4771
4777
|
tracks: r = [],
|
|
4772
4778
|
loop: s = !0,
|
|
4773
4779
|
swing: a = 0,
|
|
4774
|
-
onStep:
|
|
4780
|
+
onStep: o
|
|
4775
4781
|
} = t;
|
|
4776
|
-
this.numSteps = e, this.subdivision = n, this._loop = s, this._swing = a, this.onStep =
|
|
4782
|
+
this.numSteps = e, this.subdivision = n, this._loop = s, this._swing = a, this.onStep = o, r.forEach((u) => this.addTrack(u));
|
|
4777
4783
|
}
|
|
4778
4784
|
/**
|
|
4779
4785
|
* Current step index (0-based)
|
|
@@ -4814,25 +4820,25 @@ class vn {
|
|
|
4814
4820
|
note: r = "C2",
|
|
4815
4821
|
steps: s = this.createEmptySteps(),
|
|
4816
4822
|
muted: a = !1,
|
|
4817
|
-
soloed:
|
|
4823
|
+
soloed: o = !1,
|
|
4818
4824
|
volume: u = 1
|
|
4819
|
-
} = t, l = this.normalizeSteps(s),
|
|
4825
|
+
} = t, l = this.normalizeSteps(s), c = new pe(
|
|
4820
4826
|
(d, f) => {
|
|
4821
4827
|
this._currentStep = f, this.triggerStep(e, f, d);
|
|
4822
4828
|
},
|
|
4823
4829
|
Array.from({ length: this.numSteps }, (d, f) => f),
|
|
4824
4830
|
this.subdivision
|
|
4825
4831
|
);
|
|
4826
|
-
|
|
4832
|
+
c.loop = this._loop, this._swing > 0 && (c.humanize = this._swing * 0.05);
|
|
4827
4833
|
const h = {
|
|
4828
4834
|
id: e,
|
|
4829
4835
|
instrument: n,
|
|
4830
4836
|
note: r,
|
|
4831
4837
|
steps: l,
|
|
4832
4838
|
muted: a,
|
|
4833
|
-
soloed:
|
|
4839
|
+
soloed: o,
|
|
4834
4840
|
volume: u,
|
|
4835
|
-
sequence:
|
|
4841
|
+
sequence: c
|
|
4836
4842
|
};
|
|
4837
4843
|
this.tracks.set(e, h);
|
|
4838
4844
|
}
|
|
@@ -4881,8 +4887,8 @@ class vn {
|
|
|
4881
4887
|
const a = r.steps[e];
|
|
4882
4888
|
if (!a || !a.active || a.probability !== void 0 && Math.random() > a.probability)
|
|
4883
4889
|
return;
|
|
4884
|
-
const
|
|
4885
|
-
r.instrument.triggerAttackRelease(u, this.subdivision, n,
|
|
4890
|
+
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);
|
|
4886
4892
|
}
|
|
4887
4893
|
/**
|
|
4888
4894
|
* Set a step's state
|
|
@@ -4965,7 +4971,7 @@ class vn {
|
|
|
4965
4971
|
this.tracks.forEach((n) => {
|
|
4966
4972
|
n.sequence.start(t);
|
|
4967
4973
|
});
|
|
4968
|
-
const e =
|
|
4974
|
+
const e = w();
|
|
4969
4975
|
e.state !== "started" && e.start(t), this._isPlaying = !0;
|
|
4970
4976
|
}
|
|
4971
4977
|
/**
|
|
@@ -5054,16 +5060,16 @@ class bn {
|
|
|
5054
5060
|
loop: r = !1,
|
|
5055
5061
|
loopStart: s,
|
|
5056
5062
|
loopEnd: a,
|
|
5057
|
-
onStateChange:
|
|
5063
|
+
onStateChange: o,
|
|
5058
5064
|
onBeat: u,
|
|
5059
5065
|
onBar: l
|
|
5060
5066
|
} = t;
|
|
5061
|
-
this.onStateChange =
|
|
5062
|
-
const
|
|
5063
|
-
|
|
5067
|
+
this.onStateChange = o, this.onBeat = u, this.onBar = l;
|
|
5068
|
+
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();
|
|
5064
5070
|
}
|
|
5065
5071
|
scheduleBeatCallback() {
|
|
5066
|
-
const t =
|
|
5072
|
+
const t = w();
|
|
5067
5073
|
this.beatScheduleId = t.scheduleRepeat(
|
|
5068
5074
|
(e) => {
|
|
5069
5075
|
this.currentBeat++, this.onBeat?.(this.currentBeat, e);
|
|
@@ -5073,7 +5079,7 @@ class bn {
|
|
|
5073
5079
|
);
|
|
5074
5080
|
}
|
|
5075
5081
|
scheduleBarCallback() {
|
|
5076
|
-
const t =
|
|
5082
|
+
const t = w();
|
|
5077
5083
|
this.barScheduleId = t.scheduleRepeat(
|
|
5078
5084
|
(e) => {
|
|
5079
5085
|
this.currentBar++, this.onBar?.(this.currentBar, e);
|
|
@@ -5086,7 +5092,7 @@ class bn {
|
|
|
5086
5092
|
* Get current transport state
|
|
5087
5093
|
*/
|
|
5088
5094
|
getState() {
|
|
5089
|
-
const t =
|
|
5095
|
+
const t = w();
|
|
5090
5096
|
return {
|
|
5091
5097
|
isPlaying: t.state === "started",
|
|
5092
5098
|
isPaused: t.state === "paused",
|
|
@@ -5103,78 +5109,78 @@ class bn {
|
|
|
5103
5109
|
* Start playback
|
|
5104
5110
|
*/
|
|
5105
5111
|
start(t, e) {
|
|
5106
|
-
|
|
5112
|
+
w().start(t, e), this.notifyStateChange();
|
|
5107
5113
|
}
|
|
5108
5114
|
/**
|
|
5109
5115
|
* Pause playback
|
|
5110
5116
|
*/
|
|
5111
5117
|
pause(t) {
|
|
5112
|
-
|
|
5118
|
+
w().pause(t), this.notifyStateChange();
|
|
5113
5119
|
}
|
|
5114
5120
|
/**
|
|
5115
5121
|
* Stop playback and reset position
|
|
5116
5122
|
*/
|
|
5117
5123
|
stop(t) {
|
|
5118
|
-
|
|
5124
|
+
w().stop(t), this.currentBeat = 0, this.currentBar = 0, this.notifyStateChange();
|
|
5119
5125
|
}
|
|
5120
5126
|
/**
|
|
5121
5127
|
* Toggle between play and pause
|
|
5122
5128
|
*/
|
|
5123
5129
|
toggle(t) {
|
|
5124
|
-
const e =
|
|
5130
|
+
const e = w();
|
|
5125
5131
|
return e.state === "started" ? (e.pause(t), this.notifyStateChange(), !1) : (e.start(t), this.notifyStateChange(), !0);
|
|
5126
5132
|
}
|
|
5127
5133
|
/**
|
|
5128
5134
|
* Seek to a position
|
|
5129
5135
|
*/
|
|
5130
5136
|
seek(t) {
|
|
5131
|
-
const e =
|
|
5137
|
+
const e = w();
|
|
5132
5138
|
e.position = t, this.notifyStateChange();
|
|
5133
5139
|
}
|
|
5134
5140
|
/**
|
|
5135
5141
|
* Set BPM
|
|
5136
5142
|
*/
|
|
5137
5143
|
setBpm(t, e) {
|
|
5138
|
-
const n =
|
|
5144
|
+
const n = w();
|
|
5139
5145
|
e ? n.bpm.rampTo(t, e) : n.bpm.value = t, this.notifyStateChange();
|
|
5140
5146
|
}
|
|
5141
5147
|
/**
|
|
5142
5148
|
* Set time signature
|
|
5143
5149
|
*/
|
|
5144
5150
|
setTimeSignature(t) {
|
|
5145
|
-
const e =
|
|
5151
|
+
const e = w();
|
|
5146
5152
|
e.timeSignature = t, this.notifyStateChange();
|
|
5147
5153
|
}
|
|
5148
5154
|
/**
|
|
5149
5155
|
* Set loop range
|
|
5150
5156
|
*/
|
|
5151
5157
|
setLoop(t, e, n) {
|
|
5152
|
-
const r =
|
|
5158
|
+
const r = w();
|
|
5153
5159
|
r.loop = t, e !== void 0 && (r.loopStart = e), n !== void 0 && (r.loopEnd = n), this.notifyStateChange();
|
|
5154
5160
|
}
|
|
5155
5161
|
/**
|
|
5156
5162
|
* Schedule a callback at a specific time
|
|
5157
5163
|
*/
|
|
5158
5164
|
schedule(t, e) {
|
|
5159
|
-
return
|
|
5165
|
+
return w().schedule(t, e);
|
|
5160
5166
|
}
|
|
5161
5167
|
/**
|
|
5162
5168
|
* Schedule a repeating callback
|
|
5163
5169
|
*/
|
|
5164
5170
|
scheduleRepeat(t, e, n, r) {
|
|
5165
|
-
return
|
|
5171
|
+
return w().scheduleRepeat(t, e, n, r);
|
|
5166
5172
|
}
|
|
5167
5173
|
/**
|
|
5168
5174
|
* Clear a scheduled callback
|
|
5169
5175
|
*/
|
|
5170
5176
|
clear(t) {
|
|
5171
|
-
|
|
5177
|
+
w().clear(t);
|
|
5172
5178
|
}
|
|
5173
5179
|
/**
|
|
5174
5180
|
* Cancel all scheduled events
|
|
5175
5181
|
*/
|
|
5176
5182
|
cancel(t) {
|
|
5177
|
-
|
|
5183
|
+
w().cancel(t);
|
|
5178
5184
|
}
|
|
5179
5185
|
notifyStateChange() {
|
|
5180
5186
|
this.onStateChange?.(this.getState());
|
|
@@ -5183,27 +5189,27 @@ class bn {
|
|
|
5183
5189
|
* Convert a time value to seconds
|
|
5184
5190
|
*/
|
|
5185
5191
|
toSeconds(t) {
|
|
5186
|
-
return
|
|
5192
|
+
return w().toSeconds(t);
|
|
5187
5193
|
}
|
|
5188
5194
|
/**
|
|
5189
5195
|
* Convert seconds to bars:beats:sixteenths
|
|
5190
5196
|
*/
|
|
5191
5197
|
toBBS(t) {
|
|
5192
|
-
const e =
|
|
5193
|
-
return `${l}:${
|
|
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);
|
|
5199
|
+
return `${l}:${c}:${h}`;
|
|
5194
5200
|
}
|
|
5195
5201
|
/**
|
|
5196
5202
|
* Dispose and clean up
|
|
5197
5203
|
*/
|
|
5198
5204
|
dispose() {
|
|
5199
|
-
const t =
|
|
5205
|
+
const t = w();
|
|
5200
5206
|
this.beatScheduleId !== null && t.clear(this.beatScheduleId), this.barScheduleId !== null && t.clear(this.barScheduleId);
|
|
5201
5207
|
}
|
|
5202
5208
|
}
|
|
5203
5209
|
function _s(i = {}) {
|
|
5204
5210
|
return new bn(i);
|
|
5205
5211
|
}
|
|
5206
|
-
function
|
|
5212
|
+
function Vt(i) {
|
|
5207
5213
|
switch (i) {
|
|
5208
5214
|
case "none":
|
|
5209
5215
|
return 0;
|
|
@@ -5227,22 +5233,22 @@ class Sn {
|
|
|
5227
5233
|
preset: r,
|
|
5228
5234
|
quantizeStart: s = !0,
|
|
5229
5235
|
quantizeEnd: a = !0,
|
|
5230
|
-
swing:
|
|
5236
|
+
swing: o = 0,
|
|
5231
5237
|
swingSubdivision: u = "8n"
|
|
5232
5238
|
} = t;
|
|
5233
|
-
this.subdivision = e, this.strength = r ?
|
|
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;
|
|
5234
5240
|
}
|
|
5235
5241
|
/**
|
|
5236
5242
|
* Get the grid size in seconds for the current subdivision
|
|
5237
5243
|
*/
|
|
5238
5244
|
getGridSize() {
|
|
5239
|
-
return
|
|
5245
|
+
return w().toSeconds(this.subdivision);
|
|
5240
5246
|
}
|
|
5241
5247
|
/**
|
|
5242
5248
|
* Get the swing grid size in seconds
|
|
5243
5249
|
*/
|
|
5244
5250
|
getSwingGridSize() {
|
|
5245
|
-
return
|
|
5251
|
+
return w().toSeconds(this.swingSubdivision);
|
|
5246
5252
|
}
|
|
5247
5253
|
/**
|
|
5248
5254
|
* Quantize a time value to the grid
|
|
@@ -5291,7 +5297,7 @@ class Sn {
|
|
|
5291
5297
|
* Set the quantize strength
|
|
5292
5298
|
*/
|
|
5293
5299
|
setStrength(t) {
|
|
5294
|
-
typeof t == "string" ? this.strength =
|
|
5300
|
+
typeof t == "string" ? this.strength = Vt(t) : this.strength = Math.max(0, Math.min(1, t));
|
|
5295
5301
|
}
|
|
5296
5302
|
/**
|
|
5297
5303
|
* Set swing amount
|
|
@@ -5362,18 +5368,18 @@ class wn {
|
|
|
5362
5368
|
min: r = 0,
|
|
5363
5369
|
max: s = 1,
|
|
5364
5370
|
depth: a = 1,
|
|
5365
|
-
phase:
|
|
5371
|
+
phase: o = 0,
|
|
5366
5372
|
sync: u = !0,
|
|
5367
5373
|
autostart: l = !1
|
|
5368
5374
|
} = t;
|
|
5369
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;
|
|
5370
|
-
const
|
|
5376
|
+
const c = s - r, h = (r + s) / 2, d = c * this.depth;
|
|
5371
5377
|
this.lfo = new me({
|
|
5372
5378
|
frequency: e,
|
|
5373
5379
|
type: n,
|
|
5374
5380
|
min: h - d / 2,
|
|
5375
5381
|
max: h + d / 2,
|
|
5376
|
-
phase:
|
|
5382
|
+
phase: o
|
|
5377
5383
|
}), u && this.lfo.sync(), l && this.start();
|
|
5378
5384
|
}
|
|
5379
5385
|
/**
|
|
@@ -5381,7 +5387,7 @@ class wn {
|
|
|
5381
5387
|
*/
|
|
5382
5388
|
start(t) {
|
|
5383
5389
|
if (!this.isRunning) {
|
|
5384
|
-
const e = t ?? (this.isSynced ?
|
|
5390
|
+
const e = t ?? (this.isSynced ? w().seconds : void 0);
|
|
5385
5391
|
this.lfo.start(e), this.isRunning = !0;
|
|
5386
5392
|
}
|
|
5387
5393
|
return this;
|
|
@@ -5632,8 +5638,8 @@ class Tn {
|
|
|
5632
5638
|
throw new Error(`Invalid fromChannel: ${t}`);
|
|
5633
5639
|
if (e < 0 || e >= this.numOutputs)
|
|
5634
5640
|
throw new Error(`Invalid toChannel: ${e}`);
|
|
5635
|
-
const s = Math.max(0, Math.min(1, n)), a = Math.cos(s * Math.PI * 0.5),
|
|
5636
|
-
return r > 0 ? (this.channels[t].gain.gain.rampTo(a, r), this.channels[e].gain.gain.rampTo(
|
|
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);
|
|
5642
|
+
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;
|
|
5637
5643
|
}
|
|
5638
5644
|
/**
|
|
5639
5645
|
* Mute a channel
|
|
@@ -5857,8 +5863,8 @@ class Mn {
|
|
|
5857
5863
|
getFrequencyBands() {
|
|
5858
5864
|
const t = this.fft.getValue(), e = [], n = this.sampleRate / this.size;
|
|
5859
5865
|
for (let r = 0; r < t.length; r++) {
|
|
5860
|
-
const s = r * n, a = t[r],
|
|
5861
|
-
e.push({ frequency: s, magnitude: a, normalized:
|
|
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 });
|
|
5862
5868
|
}
|
|
5863
5869
|
return e;
|
|
5864
5870
|
}
|
|
@@ -5888,10 +5894,10 @@ class Mn {
|
|
|
5888
5894
|
getAverageInRange(t, e) {
|
|
5889
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));
|
|
5890
5896
|
if (s >= a) return -1 / 0;
|
|
5891
|
-
let
|
|
5897
|
+
let o = 0;
|
|
5892
5898
|
for (let u = s; u <= a; u++)
|
|
5893
|
-
|
|
5894
|
-
return
|
|
5899
|
+
o += n[u];
|
|
5900
|
+
return o / (a - s + 1);
|
|
5895
5901
|
}
|
|
5896
5902
|
/**
|
|
5897
5903
|
* Get common frequency band averages
|
|
@@ -5990,11 +5996,11 @@ class _n {
|
|
|
5990
5996
|
for (let u = 0; u < t.length; u++) {
|
|
5991
5997
|
const l = t[u];
|
|
5992
5998
|
l > e && (e = l), l < n && (n = l), r += l * l;
|
|
5993
|
-
const
|
|
5994
|
-
|
|
5999
|
+
const c = l >= 0;
|
|
6000
|
+
c !== a && s++, a = c;
|
|
5995
6001
|
}
|
|
5996
|
-
const
|
|
5997
|
-
return { peak: e, trough: n, rms:
|
|
6002
|
+
const o = Math.sqrt(r / t.length);
|
|
6003
|
+
return { peak: e, trough: n, rms: o, zeroCrossings: s };
|
|
5998
6004
|
}
|
|
5999
6005
|
/**
|
|
6000
6006
|
* Get downsampled waveform for smaller displays
|
|
@@ -6005,9 +6011,9 @@ class _n {
|
|
|
6005
6011
|
return e;
|
|
6006
6012
|
const n = new Float32Array(t), r = e.length / t;
|
|
6007
6013
|
for (let s = 0; s < t; s++) {
|
|
6008
|
-
const a = Math.floor(s * r),
|
|
6014
|
+
const a = Math.floor(s * r), o = Math.min(Math.floor((s + 1) * r), e.length);
|
|
6009
6015
|
let u = -1 / 0;
|
|
6010
|
-
for (let l = a; l <
|
|
6016
|
+
for (let l = a; l < o; l++)
|
|
6011
6017
|
Math.abs(e[l]) > u && (u = e[l]);
|
|
6012
6018
|
n[s] = u;
|
|
6013
6019
|
}
|
|
@@ -6019,11 +6025,11 @@ class _n {
|
|
|
6019
6025
|
getMinMaxPairs(t) {
|
|
6020
6026
|
const e = this.waveform.getValue(), n = new Float32Array(t), r = new Float32Array(t), s = e.length / t;
|
|
6021
6027
|
for (let a = 0; a < t; a++) {
|
|
6022
|
-
const
|
|
6023
|
-
let l = 1 / 0,
|
|
6024
|
-
for (let h =
|
|
6025
|
-
e[h] < l && (l = e[h]), e[h] >
|
|
6026
|
-
n[a] = l, r[a] =
|
|
6028
|
+
const o = Math.floor(a * s), u = Math.min(Math.floor((a + 1) * s), e.length);
|
|
6029
|
+
let l = 1 / 0, c = -1 / 0;
|
|
6030
|
+
for (let h = o; h < u; h++)
|
|
6031
|
+
e[h] < l && (l = e[h]), e[h] > c && (c = e[h]);
|
|
6032
|
+
n[a] = l, r[a] = c;
|
|
6027
6033
|
}
|
|
6028
6034
|
return { min: n, max: r };
|
|
6029
6035
|
}
|
|
@@ -6068,9 +6074,9 @@ export {
|
|
|
6068
6074
|
Bs as AMOscillator,
|
|
6069
6075
|
Ds as AMSynth,
|
|
6070
6076
|
Gs as Abs,
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6077
|
+
Rs as Add,
|
|
6078
|
+
Vs as AmplitudeEnvelope,
|
|
6079
|
+
qs as Analyser,
|
|
6074
6080
|
Cn as AudioMeter,
|
|
6075
6081
|
Ls as AutoFilter,
|
|
6076
6082
|
zs as AutoPanner,
|
|
@@ -6135,9 +6141,9 @@ export {
|
|
|
6135
6141
|
Br as MultibandSplit,
|
|
6136
6142
|
Dr as Multiply,
|
|
6137
6143
|
Gr as Negate,
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6144
|
+
Rr as NoiseSynth,
|
|
6145
|
+
Vr as OnePoleFilter,
|
|
6146
|
+
qr as Oscillator,
|
|
6141
6147
|
z as PPQN,
|
|
6142
6148
|
Lr as PWMOscillator,
|
|
6143
6149
|
zr as PanVol,
|
|
@@ -6192,7 +6198,7 @@ export {
|
|
|
6192
6198
|
wt as applyFadeIn,
|
|
6193
6199
|
kt as applyFadeOut,
|
|
6194
6200
|
Q as calculateDuration,
|
|
6195
|
-
|
|
6201
|
+
Ve as calculatePlaybackRate,
|
|
6196
6202
|
Zn as calculateSplitPoint,
|
|
6197
6203
|
Qn as calculateViewportBounds,
|
|
6198
6204
|
es as calculateZoomScrollPosition,
|
|
@@ -6229,7 +6235,7 @@ export {
|
|
|
6229
6235
|
_s as createTransportSync,
|
|
6230
6236
|
Ns as createWaveformDisplay,
|
|
6231
6237
|
we as dBToNormalized,
|
|
6232
|
-
|
|
6238
|
+
qe as extractLoopAndEnvelope,
|
|
6233
6239
|
_e as findClosestZoomIndex,
|
|
6234
6240
|
Dn as findGaps,
|
|
6235
6241
|
Kn as gainToNormalized,
|
|
@@ -6250,7 +6256,7 @@ export {
|
|
|
6250
6256
|
Yn as getVisibleChunkIndices,
|
|
6251
6257
|
ls as hasMediaStreamSource,
|
|
6252
6258
|
_i as immediate,
|
|
6253
|
-
|
|
6259
|
+
Re as int16ToFloat32,
|
|
6254
6260
|
on as isWebMidiSupported,
|
|
6255
6261
|
ds as midiNoteToName,
|
|
6256
6262
|
Jn as normalizedToDb,
|
|
@@ -6259,16 +6265,16 @@ export {
|
|
|
6259
6265
|
rn as parseMidiFile,
|
|
6260
6266
|
an as parseMidiMessage,
|
|
6261
6267
|
hs as parseMidiUrl,
|
|
6262
|
-
|
|
6268
|
+
qn as pixelsToSamples,
|
|
6263
6269
|
Ln as pixelsToSeconds,
|
|
6264
6270
|
us as releaseMediaStreamSource,
|
|
6265
6271
|
cn as requestMidiAccess,
|
|
6266
6272
|
is as resumeGlobalAudioContext,
|
|
6267
|
-
|
|
6273
|
+
Vn as samplesToPixels,
|
|
6268
6274
|
Gn as samplesToSeconds,
|
|
6269
6275
|
jn as samplesToTicks,
|
|
6270
6276
|
zn as secondsToPixels,
|
|
6271
|
-
|
|
6277
|
+
Rn as secondsToSamples,
|
|
6272
6278
|
ts as shouldUpdateViewport,
|
|
6273
6279
|
Hn as snapToGrid,
|
|
6274
6280
|
at as sortClipsByTime,
|