@dawcore/transport 0.0.12 → 0.0.13
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 +41 -10
- package/dist/index.d.mts +26 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +51 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -674,6 +674,8 @@ var MeterMap = class {
|
|
|
674
674
|
// src/audio/master-node.ts
|
|
675
675
|
var MasterNode = class {
|
|
676
676
|
constructor(audioContext) {
|
|
677
|
+
this._destination = null;
|
|
678
|
+
this._effectsInput = null;
|
|
677
679
|
this._gainNode = audioContext.createGain();
|
|
678
680
|
}
|
|
679
681
|
get input() {
|
|
@@ -682,6 +684,37 @@ var MasterNode = class {
|
|
|
682
684
|
get output() {
|
|
683
685
|
return this._gainNode;
|
|
684
686
|
}
|
|
687
|
+
/** Connect the master output to its final destination (audioContext.destination) */
|
|
688
|
+
connectOutput(destination) {
|
|
689
|
+
this._destination = destination;
|
|
690
|
+
this._gainNode.connect(destination);
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Insert an effects chain between the master gain and the destination.
|
|
694
|
+
* Only the destination edge is severed (targeted disconnect), so parallel
|
|
695
|
+
* taps on the master output (analyzers, recorders) keep working.
|
|
696
|
+
* The caller is responsible for routing the chain's output onward.
|
|
697
|
+
*/
|
|
698
|
+
connectEffects(effectsInput) {
|
|
699
|
+
if (this._effectsInput) {
|
|
700
|
+
this._gainNode.disconnect(this._effectsInput);
|
|
701
|
+
} else if (this._destination) {
|
|
702
|
+
this._gainNode.disconnect(this._destination);
|
|
703
|
+
}
|
|
704
|
+
this._gainNode.connect(effectsInput);
|
|
705
|
+
this._effectsInput = effectsInput;
|
|
706
|
+
}
|
|
707
|
+
/** Remove the effects chain and restore direct routing to the destination */
|
|
708
|
+
disconnectEffects() {
|
|
709
|
+
if (!this._effectsInput) {
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
this._gainNode.disconnect(this._effectsInput);
|
|
713
|
+
if (this._destination) {
|
|
714
|
+
this._gainNode.connect(this._destination);
|
|
715
|
+
}
|
|
716
|
+
this._effectsInput = null;
|
|
717
|
+
}
|
|
685
718
|
setVolume(value) {
|
|
686
719
|
this._gainNode.gain.value = value;
|
|
687
720
|
}
|
|
@@ -691,6 +724,8 @@ var MasterNode = class {
|
|
|
691
724
|
} catch (err) {
|
|
692
725
|
console.warn("[waveform-playlist] MasterNode.dispose: error disconnecting: " + String(err));
|
|
693
726
|
}
|
|
727
|
+
this._destination = null;
|
|
728
|
+
this._effectsInput = null;
|
|
694
729
|
}
|
|
695
730
|
};
|
|
696
731
|
|
|
@@ -1341,6 +1376,7 @@ var _Transport = class _Transport {
|
|
|
1341
1376
|
this._clipPlayer.onPositionJump(seekTick);
|
|
1342
1377
|
this._timer.start();
|
|
1343
1378
|
}
|
|
1379
|
+
this._emit("seek", { seconds: time });
|
|
1344
1380
|
}
|
|
1345
1381
|
getCurrentTime() {
|
|
1346
1382
|
if (this._countingIn) {
|
|
@@ -1650,6 +1686,20 @@ var _Transport = class _Transport {
|
|
|
1650
1686
|
get masterOutputNode() {
|
|
1651
1687
|
return this._masterNode.output;
|
|
1652
1688
|
}
|
|
1689
|
+
/**
|
|
1690
|
+
* Insert an effects chain on the master bus, between the master gain and
|
|
1691
|
+
* audioContext.destination. Accepts any AudioNode chain (Tone.js effects,
|
|
1692
|
+
* WAM plugins, native nodes). The caller is responsible for connecting the
|
|
1693
|
+
* chain's output to audioContext.destination. Calling again replaces the
|
|
1694
|
+
* previous chain. Parallel taps on `masterOutputNode` are unaffected.
|
|
1695
|
+
*/
|
|
1696
|
+
connectMasterOutput(node) {
|
|
1697
|
+
this._masterNode.connectEffects(node);
|
|
1698
|
+
}
|
|
1699
|
+
/** Remove the master effects chain and restore direct routing to audioContext.destination. */
|
|
1700
|
+
disconnectMasterOutput() {
|
|
1701
|
+
this._masterNode.disconnectEffects();
|
|
1702
|
+
}
|
|
1653
1703
|
// --- Events ---
|
|
1654
1704
|
on(event, cb) {
|
|
1655
1705
|
if (!this._listeners.has(event)) {
|
|
@@ -1703,7 +1753,7 @@ var _Transport = class _Transport {
|
|
|
1703
1753
|
}
|
|
1704
1754
|
_initAudioGraph(audioContext) {
|
|
1705
1755
|
this._masterNode = new MasterNode(audioContext);
|
|
1706
|
-
this._masterNode.
|
|
1756
|
+
this._masterNode.connectOutput(audioContext.destination);
|
|
1707
1757
|
const toAudioTime = (transportTime) => this._clock.toAudioTime(transportTime);
|
|
1708
1758
|
this._clipPlayer = new ClipPlayer(
|
|
1709
1759
|
audioContext,
|