@waveform-playlist/core 13.0.0-next.8 → 13.0.0-next.9
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/README.md +13 -6
- package/dist/index.d.mts +71 -14
- package/dist/index.d.ts +71 -14
- package/dist/index.js +65 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1306,9 +1306,9 @@ function applyAnnotationBounds(current, changes) {
|
|
|
1306
1306
|
|
|
1307
1307
|
// src/panStage.ts
|
|
1308
1308
|
var PREFIX = "[waveform-playlist] ";
|
|
1309
|
-
function panMatrix(pan,
|
|
1309
|
+
function panMatrix(pan, panLaw) {
|
|
1310
1310
|
const p = Number.isFinite(pan) ? Math.max(-1, Math.min(1, pan)) : 0;
|
|
1311
|
-
if (
|
|
1311
|
+
if (panLaw === "mono") {
|
|
1312
1312
|
const theta = (p + 1) * Math.PI / 4;
|
|
1313
1313
|
return { ll: Math.cos(theta), lr: 0, rl: 0, rr: Math.sin(theta) };
|
|
1314
1314
|
}
|
|
@@ -1319,7 +1319,8 @@ function panMatrix(pan, sourceChannelCount) {
|
|
|
1319
1319
|
const x = p * Math.PI / 2;
|
|
1320
1320
|
return { ll: Math.cos(x), lr: Math.sin(x), rl: 0, rr: 1 };
|
|
1321
1321
|
}
|
|
1322
|
-
|
|
1322
|
+
var PAN_LAW_RAMP_SECONDS = 0.01;
|
|
1323
|
+
function createPanStage(context, pan, panLaw) {
|
|
1323
1324
|
const upmix = context.createGain();
|
|
1324
1325
|
upmix.channelCount = 2;
|
|
1325
1326
|
upmix.channelCountMode = "explicit";
|
|
@@ -1331,13 +1332,32 @@ function createPanStage(context, pan, sourceChannelCount) {
|
|
|
1331
1332
|
const rl = context.createGain();
|
|
1332
1333
|
const rr = context.createGain();
|
|
1333
1334
|
let currentPan = pan;
|
|
1334
|
-
let
|
|
1335
|
+
let currentLaw = panLaw;
|
|
1336
|
+
let rampScheduled = false;
|
|
1337
|
+
const targets = () => {
|
|
1338
|
+
const matrix = panMatrix(currentPan, currentLaw);
|
|
1339
|
+
return [
|
|
1340
|
+
[ll, matrix.ll],
|
|
1341
|
+
[lr, matrix.lr],
|
|
1342
|
+
[rl, matrix.rl],
|
|
1343
|
+
[rr, matrix.rr]
|
|
1344
|
+
];
|
|
1345
|
+
};
|
|
1335
1346
|
const apply = () => {
|
|
1336
|
-
const
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1347
|
+
for (const [node, value] of targets()) {
|
|
1348
|
+
if (rampScheduled) node.gain.cancelScheduledValues(context.currentTime);
|
|
1349
|
+
node.gain.value = value;
|
|
1350
|
+
}
|
|
1351
|
+
rampScheduled = false;
|
|
1352
|
+
};
|
|
1353
|
+
const ramp = () => {
|
|
1354
|
+
const now = context.currentTime;
|
|
1355
|
+
for (const [node, value] of targets()) {
|
|
1356
|
+
node.gain.cancelScheduledValues(now);
|
|
1357
|
+
node.gain.setValueAtTime(node.gain.value, now);
|
|
1358
|
+
node.gain.linearRampToValueAtTime(value, now + PAN_LAW_RAMP_SECONDS);
|
|
1359
|
+
}
|
|
1360
|
+
rampScheduled = true;
|
|
1341
1361
|
};
|
|
1342
1362
|
apply();
|
|
1343
1363
|
upmix.connect(split);
|
|
@@ -1356,9 +1376,10 @@ function createPanStage(context, pan, sourceChannelCount) {
|
|
|
1356
1376
|
currentPan = value;
|
|
1357
1377
|
apply();
|
|
1358
1378
|
},
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1379
|
+
setPanLaw: (value) => {
|
|
1380
|
+
if (value === currentLaw) return;
|
|
1381
|
+
currentLaw = value;
|
|
1382
|
+
ramp();
|
|
1362
1383
|
},
|
|
1363
1384
|
dispose: () => {
|
|
1364
1385
|
for (const node of [upmix, split, ll, lr, rl, rr, merge]) {
|
|
@@ -1372,6 +1393,26 @@ function createPanStage(context, pan, sourceChannelCount) {
|
|
|
1372
1393
|
};
|
|
1373
1394
|
}
|
|
1374
1395
|
|
|
1396
|
+
// src/panLaw.ts
|
|
1397
|
+
var DEFAULT_PAN_LAW = "auto";
|
|
1398
|
+
function isDecidedPanLaw(value) {
|
|
1399
|
+
return value === "mono" || value === "stereo";
|
|
1400
|
+
}
|
|
1401
|
+
function audioPanLaw(track) {
|
|
1402
|
+
let law = null;
|
|
1403
|
+
for (const clip of track.clips) {
|
|
1404
|
+
const channels = clip.audioBuffer?.numberOfChannels;
|
|
1405
|
+
if (channels === void 0) continue;
|
|
1406
|
+
if (channels >= 2) return "stereo";
|
|
1407
|
+
law = "mono";
|
|
1408
|
+
}
|
|
1409
|
+
return law;
|
|
1410
|
+
}
|
|
1411
|
+
function trackPanLaw(track) {
|
|
1412
|
+
if (isDecidedPanLaw(track.panLaw)) return track.panLaw;
|
|
1413
|
+
return audioPanLaw(track) ?? "mono";
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1375
1416
|
// src/valueSource.ts
|
|
1376
1417
|
function silentMeterLevels(channelCount) {
|
|
1377
1418
|
const count = Math.max(0, Math.floor(channelCount));
|
|
@@ -1607,7 +1648,8 @@ function audioTrack(options) {
|
|
|
1607
1648
|
...base,
|
|
1608
1649
|
id: options.id || base.id,
|
|
1609
1650
|
clips: [clip],
|
|
1610
|
-
renderMode: options.renderMode
|
|
1651
|
+
renderMode: options.renderMode,
|
|
1652
|
+
...options.panLaw !== void 0 && { panLaw: options.panLaw }
|
|
1611
1653
|
};
|
|
1612
1654
|
return track;
|
|
1613
1655
|
}
|
|
@@ -1777,6 +1819,7 @@ function createEffectInstance(type, audioContext, params = {}) {
|
|
|
1777
1819
|
export {
|
|
1778
1820
|
ANNOTATION_LINK_THRESHOLD_TICKS,
|
|
1779
1821
|
DEFAULT_ANNOTATION_SHORTCUTS,
|
|
1822
|
+
DEFAULT_PAN_LAW,
|
|
1780
1823
|
DEFAULT_SPECTROGRAM_COLOR_MAP,
|
|
1781
1824
|
InteractionState,
|
|
1782
1825
|
LINK_THRESHOLD,
|
|
@@ -1784,6 +1827,7 @@ export {
|
|
|
1784
1827
|
METER_PEAK_DECAY,
|
|
1785
1828
|
MIN_ANNOTATION_DURATION,
|
|
1786
1829
|
MIN_PIXELS_PER_UNIT,
|
|
1830
|
+
PAN_LAW_RAMP_SECONDS,
|
|
1787
1831
|
PPQN,
|
|
1788
1832
|
SPECTROGRAM_DEFAULTS,
|
|
1789
1833
|
TRACK_VIEW_FIELDS,
|
|
@@ -1795,6 +1839,7 @@ export {
|
|
|
1795
1839
|
applyFadeOut,
|
|
1796
1840
|
assertTrackKind,
|
|
1797
1841
|
audibleLatencySamples,
|
|
1842
|
+
audioPanLaw,
|
|
1798
1843
|
audioTrack,
|
|
1799
1844
|
buildSpectrogramCanvasId,
|
|
1800
1845
|
carveClipRange,
|
|
@@ -1833,6 +1878,7 @@ export {
|
|
|
1833
1878
|
getClipsInRange,
|
|
1834
1879
|
getEffectDefinitions,
|
|
1835
1880
|
handleKeyboardEvent,
|
|
1881
|
+
isDecidedPanLaw,
|
|
1836
1882
|
isLoadingClip,
|
|
1837
1883
|
keyBelongsToFocusedControl,
|
|
1838
1884
|
linearCurve,
|
|
@@ -1868,6 +1914,7 @@ export {
|
|
|
1868
1914
|
ticksToSamples,
|
|
1869
1915
|
trackChannelCount,
|
|
1870
1916
|
trackKind,
|
|
1917
|
+
trackPanLaw,
|
|
1871
1918
|
unregisterEffect,
|
|
1872
1919
|
updateAnnotationBoundaries,
|
|
1873
1920
|
watchMicrophoneDevices
|