@dawcore/transport 0.0.15 → 0.0.16-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -16
- package/dist/index.d.mts +51 -8
- package/dist/index.d.ts +51 -8
- package/dist/index.js +81 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -9,8 +9,8 @@ Native Web Audio transport for the dawcore family — multi-track scheduling, lo
|
|
|
9
9
|
- **Dual timeline** — Sample-absolute positions for audio clips, PPQN tick positions for metronome/MIDI.
|
|
10
10
|
- **Built-in metronome** — Beat-grid click scheduling with accent on beat 1. Default synthesized click sounds out of the box.
|
|
11
11
|
- **Count-in (pre-roll)** — Configurable bars of click sounds before playback begins. Beat-by-beat events for UI countdown.
|
|
12
|
-
- **Per-track signal chain** —
|
|
13
|
-
- **Effects plugin hook** — `
|
|
12
|
+
- **Per-track signal chain** — clip sources → effects insert (pre-fader) → GainNode (volume) → pan stage (a gain matrix, not a `StereoPannerNode` — see [Panning](#panning)) → GainNode (mute) → master output.
|
|
13
|
+
- **Effects plugin hook** — `connectTrackEffects(trackId, input, output)` (pre-fader track insert) and `connectMasterOutput(node)` insert any `AudioNode` chain (Tone.js effects, WAM plugins, native nodes) per-track or on the master bus.
|
|
14
14
|
- **Type-safe coordinates** — Branded `Tick` and `Sample` types prevent accidentally passing seconds where ticks or samples are expected. Zero runtime cost.
|
|
15
15
|
- **PlayoutAdapter bridge** — `NativePlayoutAdapter` implements the `PlayoutAdapter` interface from `@waveform-playlist/engine`.
|
|
16
16
|
|
|
@@ -20,7 +20,7 @@ Native Web Audio transport for the dawcore family — multi-track scheduling, lo
|
|
|
20
20
|
npm install @dawcore/transport
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
One runtime dependency, installed automatically: `@waveform-playlist/core` (dependency-free itself; the transport uses its shared pan stage). When using `NativePlayoutAdapter` (bridge to `@waveform-playlist/engine`), install `@waveform-playlist/engine` alongside.
|
|
24
24
|
|
|
25
25
|
## Quick Start
|
|
26
26
|
|
|
@@ -150,21 +150,26 @@ transport.setTempo(140, transport.barToTick(9), { interpolation: 'linear' }); /
|
|
|
150
150
|
### Effects
|
|
151
151
|
|
|
152
152
|
```typescript
|
|
153
|
-
// Insert any AudioNode chain
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
// Insert any AudioNode chain on a track, PRE-FADER:
|
|
154
|
+
// clips → input … output → volume → pan → mute → master
|
|
155
|
+
// Pass the chain's first and last node; the transport wires both ends.
|
|
156
|
+
const highpass = audioContext.createBiquadFilter();
|
|
157
|
+
highpass.type = 'highpass';
|
|
158
|
+
const compressor = audioContext.createDynamicsCompressor();
|
|
159
|
+
highpass.connect(compressor);
|
|
157
160
|
|
|
158
|
-
transport.
|
|
161
|
+
transport.connectTrackEffects('vocals', highpass, compressor);
|
|
162
|
+
// A single-node effect is its own input and output:
|
|
163
|
+
// transport.connectTrackEffects('vocals', reverb, reverb);
|
|
159
164
|
|
|
160
|
-
// Remove effects — restores direct routing
|
|
161
|
-
transport.
|
|
165
|
+
// Remove effects — restores the track's direct routing
|
|
166
|
+
transport.disconnectTrackEffects('vocals');
|
|
162
167
|
|
|
163
168
|
// Master bus effects — inserted between master gain and destination
|
|
164
|
-
const
|
|
165
|
-
|
|
169
|
+
const limiter = audioContext.createDynamicsCompressor();
|
|
170
|
+
limiter.connect(audioContext.destination);
|
|
166
171
|
|
|
167
|
-
transport.connectMasterOutput(
|
|
172
|
+
transport.connectMasterOutput(limiter);
|
|
168
173
|
|
|
169
174
|
// Remove master effects — restores direct routing to destination.
|
|
170
175
|
// Parallel taps on transport.masterOutputNode (analyzers, recorders)
|
|
@@ -172,7 +177,31 @@ transport.connectMasterOutput(compressor);
|
|
|
172
177
|
transport.disconnectMasterOutput();
|
|
173
178
|
```
|
|
174
179
|
|
|
175
|
-
**
|
|
180
|
+
**Track effects are pre-fader inserts.** The chain sees the clips at their own level and channel layout; the track's volume, pan and mute come after it. So:
|
|
181
|
+
|
|
182
|
+
- Moving the volume fader changes the track's level in the mix, not how hard a compressor, limiter or distortion works.
|
|
183
|
+
- A mono clip reaches the chain as mono, at full level (not as two channels at −3 dB from a centred panner).
|
|
184
|
+
- Do **not** connect the chain's output to `masterOutputNode` yourself — the transport returns it into the track. Routing it to the master would bypass the fader, pan, mute and solo.
|
|
185
|
+
- Mute and solo silence a track including its effect tails.
|
|
186
|
+
- Pan is unaffected by what the chain outputs: the pan law follows the track's clips, not the chain. A stereo reverb on a mono track stays stereo and sits at the same centre level as the dry track (see [Panning](#panning)).
|
|
187
|
+
|
|
188
|
+
`setTracks()` rebuilds every track node and drops these hookups — reconnect afterwards. (Before 0.0.16 the hook was `connectTrackOutput(trackId, node)`, post-fader, with the caller wiring the chain to the master.)
|
|
189
|
+
|
|
190
|
+
### Panning
|
|
191
|
+
|
|
192
|
+
A track is panned by a small gain matrix (`createPanStage` from `@waveform-playlist/core`), **not** by a Web Audio `StereoPannerNode`.
|
|
193
|
+
|
|
194
|
+
Why: a `StereoPannerNode` chooses its pan law from the signal it _receives_ — the equal-power law for mono input (−3 dB per side at centre), the stereo law for stereo input (unity at centre). With pre-fader effects the panner is fed by the effects chain, so the law would follow the chain's output instead of the track: a mono track with a stereo reverb or a typical WAM plugin would jump about 3 dB at centre and get a different pan curve the moment the effect was added.
|
|
195
|
+
|
|
196
|
+
The pan stage implements the same two laws — its output matches a `StereoPannerNode` fed the raw clip to within float rounding — but takes the law from the track's **source material**: the highest channel count among the track's clips (`trackChannelCount(track)`), re-evaluated on `setTracks`, `addTrack` and `updateTrack`.
|
|
197
|
+
|
|
198
|
+
- Mono track: equal-power pan. The stage never mixes the two channels, so a stereo effect stays stereo.
|
|
199
|
+
- Stereo track: the stereo law — centre passes both channels at unity; panning left folds the right channel into the left, and vice versa.
|
|
200
|
+
- A track with both mono and stereo clips uses the stereo law for all of them, so its mono clips play 3 dB louder at centre than they would on a mono-only track. Adding the first stereo clip to a mono track (or removing the last one) therefore shifts the track's mono clips by 3 dB at centre. (Before 0.0.16 the law depended on which clips happened to be sounding.)
|
|
201
|
+
|
|
202
|
+
The Tone.js adapter (`@waveform-playlist/playout`) and both offline renderers use the same stage, so pan positions and levels match across backends and between playback and export.
|
|
203
|
+
|
|
204
|
+
**Note:** tracks carry no effects. Use `connectTrackEffects`/`connectMasterOutput` for effects with the native transport. (The Tone.js adapter in `@waveform-playlist/playout` additionally accepts a `trackEffects` lookup of closure-style effects functions; `NativePlayoutAdapter` has no equivalent.)
|
|
176
205
|
|
|
177
206
|
## API
|
|
178
207
|
|
|
@@ -247,8 +276,8 @@ new Transport(audioContext: AudioContext, options?: TransportOptions)
|
|
|
247
276
|
- `isCountingIn()` — whether count-in is active
|
|
248
277
|
|
|
249
278
|
**Effects:**
|
|
250
|
-
- `
|
|
251
|
-
- `
|
|
279
|
+
- `connectTrackEffects(trackId, input, output)` — Insert a per-track effects chain, pre-fader (the transport wires `output` back into the track)
|
|
280
|
+
- `disconnectTrackEffects(trackId)` — Remove the per-track effects chain
|
|
252
281
|
- `connectMasterOutput(node)` — Insert master bus effects chain
|
|
253
282
|
- `disconnectMasterOutput()` — Remove master bus effects chain
|
|
254
283
|
- `masterOutputNode` (getter) — Master gain node, for parallel taps (analyzers, recorders) that should survive chain connect/disconnect
|
package/dist/index.d.mts
CHANGED
|
@@ -642,24 +642,55 @@ declare class MasterNode {
|
|
|
642
642
|
dispose(): void;
|
|
643
643
|
}
|
|
644
644
|
|
|
645
|
+
/**
|
|
646
|
+
* One track's signal path:
|
|
647
|
+
*
|
|
648
|
+
* clip sources → input → [effects insert] → volume → pan → mute → output
|
|
649
|
+
*
|
|
650
|
+
* Effects are PRE-FADER inserts (#660), the usual DAW convention: the
|
|
651
|
+
* chain sees the clips' own level and channel layout, so the volume fader
|
|
652
|
+
* and pan only place the processed track in the mix — they never change
|
|
653
|
+
* how hard a compressor or distortion works. Mute sits last, so a muted
|
|
654
|
+
* (or un-soloed) track is silent including its effect tails.
|
|
655
|
+
*
|
|
656
|
+
* Pan is core's gain-matrix stage, not a `StereoPannerNode` (#669): a
|
|
657
|
+
* panner picks its law from the layout it RECEIVES, which pre-fader is the
|
|
658
|
+
* effects chain's output — a stereo reverb on a mono track would sit ~3 dB
|
|
659
|
+
* louder at centre. The stage takes its law from `sourceChannelCount`, the
|
|
660
|
+
* max channel count of the track's clips, whatever the chain outputs.
|
|
661
|
+
*/
|
|
645
662
|
declare class TrackNode {
|
|
646
663
|
readonly id: string;
|
|
664
|
+
private _inputNode;
|
|
647
665
|
private _volumeNode;
|
|
648
|
-
private
|
|
666
|
+
private _panStage;
|
|
649
667
|
private _muteNode;
|
|
650
|
-
private
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
/** Where clip sources connect */
|
|
668
|
+
private _effects;
|
|
669
|
+
constructor(id: string, audioContext: AudioContext, sourceChannelCount?: number);
|
|
670
|
+
/** Where clip sources connect (pre-fader, pre-effects). */
|
|
654
671
|
get input(): GainNode;
|
|
655
672
|
/** Connect this track's output to a destination (master node) */
|
|
656
673
|
connectOutput(destination: AudioNode): void;
|
|
657
674
|
setVolume(value: number): void;
|
|
658
675
|
setPan(value: number): void;
|
|
676
|
+
/** Select the pan law from the track's source material: 1 = mono law
|
|
677
|
+
* (−3 dB per side at centre), 2+ = stereo law (unity at centre). */
|
|
678
|
+
setSourceChannelCount(sourceChannelCount: number): void;
|
|
659
679
|
setMute(muted: boolean): void;
|
|
660
|
-
|
|
680
|
+
/**
|
|
681
|
+
* Insert an effects chain between the track input and the fader:
|
|
682
|
+
* `input → effectsInput … effectsOutput → volume`. The transport owns
|
|
683
|
+
* BOTH edges — the caller only builds what lies between the two nodes
|
|
684
|
+
* (pass the same node twice for a single-node effect). Replaces any
|
|
685
|
+
* chain connected earlier.
|
|
686
|
+
*/
|
|
687
|
+
connectEffects(effectsInput: AudioNode, effectsOutput: AudioNode): void;
|
|
688
|
+
/** Remove the effects chain and restore `input → volume`. No-op without one. */
|
|
661
689
|
disconnectEffects(): void;
|
|
662
690
|
dispose(): void;
|
|
691
|
+
/** Targeted disconnect of `effectsOutput → volume` — other consumers of
|
|
692
|
+
* the chain's output (analyser taps) keep their edges. */
|
|
693
|
+
private _releaseEffectsReturn;
|
|
663
694
|
}
|
|
664
695
|
|
|
665
696
|
interface ClipEvent extends SchedulerEvent {
|
|
@@ -942,8 +973,20 @@ declare class Transport {
|
|
|
942
973
|
setCountInMode(mode: CountInMode): void;
|
|
943
974
|
setRecording(recording: boolean): void;
|
|
944
975
|
isCountingIn(): boolean;
|
|
945
|
-
|
|
946
|
-
|
|
976
|
+
/**
|
|
977
|
+
* Insert an effects chain on a track, PRE-FADER: clip sources → `input` …
|
|
978
|
+
* `output` → volume → pan → mute → master. Accepts any AudioNode chain
|
|
979
|
+
* (native nodes, WAM plugins, Tone.js effects) — pass the same node twice
|
|
980
|
+
* for a single-node effect. The transport owns both edges; do NOT connect
|
|
981
|
+
* `output` to the master bus yourself (that would bypass the fader, pan
|
|
982
|
+
* and mute). Calling again replaces the previous chain.
|
|
983
|
+
*
|
|
984
|
+
* `setTracks()` rebuilds every track node, dropping these hookups —
|
|
985
|
+
* reconnect afterwards.
|
|
986
|
+
*/
|
|
987
|
+
connectTrackEffects(trackId: string, input: AudioNode, output: AudioNode): void;
|
|
988
|
+
/** Remove a track's effects chain and restore its direct routing. */
|
|
989
|
+
disconnectTrackEffects(trackId: string): void;
|
|
947
990
|
/** The master output AudioNode. Connect your own nodes (analyzers, recorders, etc.)
|
|
948
991
|
* in parallel. The transport already routes this to audioContext.destination. */
|
|
949
992
|
get masterOutputNode(): AudioNode;
|
package/dist/index.d.ts
CHANGED
|
@@ -642,24 +642,55 @@ declare class MasterNode {
|
|
|
642
642
|
dispose(): void;
|
|
643
643
|
}
|
|
644
644
|
|
|
645
|
+
/**
|
|
646
|
+
* One track's signal path:
|
|
647
|
+
*
|
|
648
|
+
* clip sources → input → [effects insert] → volume → pan → mute → output
|
|
649
|
+
*
|
|
650
|
+
* Effects are PRE-FADER inserts (#660), the usual DAW convention: the
|
|
651
|
+
* chain sees the clips' own level and channel layout, so the volume fader
|
|
652
|
+
* and pan only place the processed track in the mix — they never change
|
|
653
|
+
* how hard a compressor or distortion works. Mute sits last, so a muted
|
|
654
|
+
* (or un-soloed) track is silent including its effect tails.
|
|
655
|
+
*
|
|
656
|
+
* Pan is core's gain-matrix stage, not a `StereoPannerNode` (#669): a
|
|
657
|
+
* panner picks its law from the layout it RECEIVES, which pre-fader is the
|
|
658
|
+
* effects chain's output — a stereo reverb on a mono track would sit ~3 dB
|
|
659
|
+
* louder at centre. The stage takes its law from `sourceChannelCount`, the
|
|
660
|
+
* max channel count of the track's clips, whatever the chain outputs.
|
|
661
|
+
*/
|
|
645
662
|
declare class TrackNode {
|
|
646
663
|
readonly id: string;
|
|
664
|
+
private _inputNode;
|
|
647
665
|
private _volumeNode;
|
|
648
|
-
private
|
|
666
|
+
private _panStage;
|
|
649
667
|
private _muteNode;
|
|
650
|
-
private
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
/** Where clip sources connect */
|
|
668
|
+
private _effects;
|
|
669
|
+
constructor(id: string, audioContext: AudioContext, sourceChannelCount?: number);
|
|
670
|
+
/** Where clip sources connect (pre-fader, pre-effects). */
|
|
654
671
|
get input(): GainNode;
|
|
655
672
|
/** Connect this track's output to a destination (master node) */
|
|
656
673
|
connectOutput(destination: AudioNode): void;
|
|
657
674
|
setVolume(value: number): void;
|
|
658
675
|
setPan(value: number): void;
|
|
676
|
+
/** Select the pan law from the track's source material: 1 = mono law
|
|
677
|
+
* (−3 dB per side at centre), 2+ = stereo law (unity at centre). */
|
|
678
|
+
setSourceChannelCount(sourceChannelCount: number): void;
|
|
659
679
|
setMute(muted: boolean): void;
|
|
660
|
-
|
|
680
|
+
/**
|
|
681
|
+
* Insert an effects chain between the track input and the fader:
|
|
682
|
+
* `input → effectsInput … effectsOutput → volume`. The transport owns
|
|
683
|
+
* BOTH edges — the caller only builds what lies between the two nodes
|
|
684
|
+
* (pass the same node twice for a single-node effect). Replaces any
|
|
685
|
+
* chain connected earlier.
|
|
686
|
+
*/
|
|
687
|
+
connectEffects(effectsInput: AudioNode, effectsOutput: AudioNode): void;
|
|
688
|
+
/** Remove the effects chain and restore `input → volume`. No-op without one. */
|
|
661
689
|
disconnectEffects(): void;
|
|
662
690
|
dispose(): void;
|
|
691
|
+
/** Targeted disconnect of `effectsOutput → volume` — other consumers of
|
|
692
|
+
* the chain's output (analyser taps) keep their edges. */
|
|
693
|
+
private _releaseEffectsReturn;
|
|
663
694
|
}
|
|
664
695
|
|
|
665
696
|
interface ClipEvent extends SchedulerEvent {
|
|
@@ -942,8 +973,20 @@ declare class Transport {
|
|
|
942
973
|
setCountInMode(mode: CountInMode): void;
|
|
943
974
|
setRecording(recording: boolean): void;
|
|
944
975
|
isCountingIn(): boolean;
|
|
945
|
-
|
|
946
|
-
|
|
976
|
+
/**
|
|
977
|
+
* Insert an effects chain on a track, PRE-FADER: clip sources → `input` …
|
|
978
|
+
* `output` → volume → pan → mute → master. Accepts any AudioNode chain
|
|
979
|
+
* (native nodes, WAM plugins, Tone.js effects) — pass the same node twice
|
|
980
|
+
* for a single-node effect. The transport owns both edges; do NOT connect
|
|
981
|
+
* `output` to the master bus yourself (that would bypass the fader, pan
|
|
982
|
+
* and mute). Calling again replaces the previous chain.
|
|
983
|
+
*
|
|
984
|
+
* `setTracks()` rebuilds every track node, dropping these hookups —
|
|
985
|
+
* reconnect afterwards.
|
|
986
|
+
*/
|
|
987
|
+
connectTrackEffects(trackId: string, input: AudioNode, output: AudioNode): void;
|
|
988
|
+
/** Remove a track's effects chain and restore its direct routing. */
|
|
989
|
+
disconnectTrackEffects(trackId: string): void;
|
|
947
990
|
/** The master output AudioNode. Connect your own nodes (analyzers, recorders, etc.)
|
|
948
991
|
* in parallel. The transport already routes this to audioContext.destination. */
|
|
949
992
|
get masterOutputNode(): AudioNode;
|
package/dist/index.js
CHANGED
|
@@ -1328,62 +1328,92 @@ var MasterNode = class {
|
|
|
1328
1328
|
};
|
|
1329
1329
|
|
|
1330
1330
|
// src/audio/track-node.ts
|
|
1331
|
+
var import_core = require("@waveform-playlist/core");
|
|
1332
|
+
var PREFIX = "[waveform-playlist] ";
|
|
1331
1333
|
var TrackNode = class {
|
|
1332
|
-
constructor(id, audioContext) {
|
|
1333
|
-
this.
|
|
1334
|
-
this._effectsInput = null;
|
|
1334
|
+
constructor(id, audioContext, sourceChannelCount = 1) {
|
|
1335
|
+
this._effects = null;
|
|
1335
1336
|
this.id = id;
|
|
1337
|
+
this._inputNode = audioContext.createGain();
|
|
1336
1338
|
this._volumeNode = audioContext.createGain();
|
|
1337
|
-
this.
|
|
1338
|
-
this._panNode.channelCount = 2;
|
|
1339
|
+
this._panStage = (0, import_core.createPanStage)(audioContext, 0, sourceChannelCount);
|
|
1339
1340
|
this._muteNode = audioContext.createGain();
|
|
1340
|
-
this.
|
|
1341
|
-
this.
|
|
1341
|
+
this._inputNode.connect(this._volumeNode);
|
|
1342
|
+
this._volumeNode.connect(this._panStage.input);
|
|
1343
|
+
this._panStage.output.connect(this._muteNode);
|
|
1342
1344
|
}
|
|
1343
|
-
/** Where clip sources connect */
|
|
1345
|
+
/** Where clip sources connect (pre-fader, pre-effects). */
|
|
1344
1346
|
get input() {
|
|
1345
|
-
return this.
|
|
1347
|
+
return this._inputNode;
|
|
1346
1348
|
}
|
|
1347
1349
|
/** Connect this track's output to a destination (master node) */
|
|
1348
1350
|
connectOutput(destination) {
|
|
1349
|
-
this._destination = destination;
|
|
1350
1351
|
this._muteNode.connect(destination);
|
|
1351
1352
|
}
|
|
1352
1353
|
setVolume(value) {
|
|
1353
1354
|
this._volumeNode.gain.value = value;
|
|
1354
1355
|
}
|
|
1355
1356
|
setPan(value) {
|
|
1356
|
-
this.
|
|
1357
|
+
this._panStage.setPan(value);
|
|
1358
|
+
}
|
|
1359
|
+
/** Select the pan law from the track's source material: 1 = mono law
|
|
1360
|
+
* (−3 dB per side at centre), 2+ = stereo law (unity at centre). */
|
|
1361
|
+
setSourceChannelCount(sourceChannelCount) {
|
|
1362
|
+
this._panStage.setSourceChannelCount(sourceChannelCount);
|
|
1357
1363
|
}
|
|
1358
1364
|
setMute(muted) {
|
|
1359
1365
|
this._muteNode.gain.value = muted ? 0 : 1;
|
|
1360
1366
|
}
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1367
|
+
/**
|
|
1368
|
+
* Insert an effects chain between the track input and the fader:
|
|
1369
|
+
* `input → effectsInput … effectsOutput → volume`. The transport owns
|
|
1370
|
+
* BOTH edges — the caller only builds what lies between the two nodes
|
|
1371
|
+
* (pass the same node twice for a single-node effect). Replaces any
|
|
1372
|
+
* chain connected earlier.
|
|
1373
|
+
*/
|
|
1374
|
+
connectEffects(effectsInput, effectsOutput) {
|
|
1375
|
+
this.disconnectEffects();
|
|
1376
|
+
this._inputNode.disconnect();
|
|
1377
|
+
this._inputNode.connect(effectsInput);
|
|
1378
|
+
effectsOutput.connect(this._volumeNode);
|
|
1379
|
+
this._effects = { input: effectsInput, output: effectsOutput };
|
|
1380
|
+
}
|
|
1381
|
+
/** Remove the effects chain and restore `input → volume`. No-op without one. */
|
|
1369
1382
|
disconnectEffects() {
|
|
1370
|
-
if (this.
|
|
1371
|
-
|
|
1372
|
-
this._muteNode.connect(this._destination);
|
|
1373
|
-
this._effectsInput = null;
|
|
1383
|
+
if (!this._effects) {
|
|
1384
|
+
return;
|
|
1374
1385
|
}
|
|
1386
|
+
this._releaseEffectsReturn();
|
|
1387
|
+
this._inputNode.disconnect();
|
|
1388
|
+
this._inputNode.connect(this._volumeNode);
|
|
1389
|
+
this._effects = null;
|
|
1375
1390
|
}
|
|
1376
1391
|
dispose() {
|
|
1377
|
-
|
|
1392
|
+
this._releaseEffectsReturn();
|
|
1393
|
+
this._effects = null;
|
|
1394
|
+
for (const node of [this._inputNode, this._volumeNode, this._muteNode]) {
|
|
1378
1395
|
try {
|
|
1379
1396
|
node.disconnect();
|
|
1380
1397
|
} catch (err) {
|
|
1381
|
-
console.warn(
|
|
1382
|
-
"[waveform-playlist] TrackNode.dispose: error disconnecting node:",
|
|
1383
|
-
String(err)
|
|
1384
|
-
);
|
|
1398
|
+
console.warn(PREFIX + "TrackNode.dispose: error disconnecting node:", String(err));
|
|
1385
1399
|
}
|
|
1386
1400
|
}
|
|
1401
|
+
this._panStage.dispose();
|
|
1402
|
+
}
|
|
1403
|
+
/** Targeted disconnect of `effectsOutput → volume` — other consumers of
|
|
1404
|
+
* the chain's output (analyser taps) keep their edges. */
|
|
1405
|
+
_releaseEffectsReturn() {
|
|
1406
|
+
if (!this._effects) {
|
|
1407
|
+
return;
|
|
1408
|
+
}
|
|
1409
|
+
try {
|
|
1410
|
+
this._effects.output.disconnect(this._volumeNode);
|
|
1411
|
+
} catch (err) {
|
|
1412
|
+
console.warn(
|
|
1413
|
+
PREFIX + 'TrackNode: effects chain was already disconnected from track "' + this.id + '": ',
|
|
1414
|
+
String(err)
|
|
1415
|
+
);
|
|
1416
|
+
}
|
|
1387
1417
|
}
|
|
1388
1418
|
};
|
|
1389
1419
|
|
|
@@ -1702,6 +1732,9 @@ var MetronomePlayer = class {
|
|
|
1702
1732
|
}
|
|
1703
1733
|
};
|
|
1704
1734
|
|
|
1735
|
+
// src/transport.ts
|
|
1736
|
+
var import_core2 = require("@waveform-playlist/core");
|
|
1737
|
+
|
|
1705
1738
|
// src/audio/count-in-player.ts
|
|
1706
1739
|
var CountInPlayer = class {
|
|
1707
1740
|
constructor(audioContext, tempoMap, destination, toAudioTime) {
|
|
@@ -2142,7 +2175,7 @@ var _Transport = class _Transport {
|
|
|
2142
2175
|
this._mutedTrackIds.clear();
|
|
2143
2176
|
this._tracks = tracks;
|
|
2144
2177
|
for (const track of tracks) {
|
|
2145
|
-
const trackNode = new TrackNode(track.id, this._audioContext);
|
|
2178
|
+
const trackNode = new TrackNode(track.id, this._audioContext, (0, import_core2.trackChannelCount)(track));
|
|
2146
2179
|
trackNode.setVolume(track.volume);
|
|
2147
2180
|
trackNode.setPan(track.pan);
|
|
2148
2181
|
trackNode.connectOutput(this._masterNode.input);
|
|
@@ -2158,7 +2191,7 @@ var _Transport = class _Transport {
|
|
|
2158
2191
|
this._clipPlayer.setTracks(tracks, this._trackNodes);
|
|
2159
2192
|
}
|
|
2160
2193
|
addTrack(track) {
|
|
2161
|
-
const trackNode = new TrackNode(track.id, this._audioContext);
|
|
2194
|
+
const trackNode = new TrackNode(track.id, this._audioContext, (0, import_core2.trackChannelCount)(track));
|
|
2162
2195
|
trackNode.setVolume(track.volume);
|
|
2163
2196
|
trackNode.setPan(track.pan);
|
|
2164
2197
|
trackNode.connectOutput(this._masterNode.input);
|
|
@@ -2191,6 +2224,7 @@ var _Transport = class _Transport {
|
|
|
2191
2224
|
if (node) {
|
|
2192
2225
|
node.setVolume(track.volume);
|
|
2193
2226
|
node.setPan(track.pan);
|
|
2227
|
+
node.setSourceChannelCount((0, import_core2.trackChannelCount)(track));
|
|
2194
2228
|
}
|
|
2195
2229
|
if (track.muted) {
|
|
2196
2230
|
this._mutedTrackIds.add(trackId);
|
|
@@ -2427,18 +2461,30 @@ var _Transport = class _Transport {
|
|
|
2427
2461
|
return this._countingIn;
|
|
2428
2462
|
}
|
|
2429
2463
|
// --- Effects Hook ---
|
|
2430
|
-
|
|
2464
|
+
/**
|
|
2465
|
+
* Insert an effects chain on a track, PRE-FADER: clip sources → `input` …
|
|
2466
|
+
* `output` → volume → pan → mute → master. Accepts any AudioNode chain
|
|
2467
|
+
* (native nodes, WAM plugins, Tone.js effects) — pass the same node twice
|
|
2468
|
+
* for a single-node effect. The transport owns both edges; do NOT connect
|
|
2469
|
+
* `output` to the master bus yourself (that would bypass the fader, pan
|
|
2470
|
+
* and mute). Calling again replaces the previous chain.
|
|
2471
|
+
*
|
|
2472
|
+
* `setTracks()` rebuilds every track node, dropping these hookups —
|
|
2473
|
+
* reconnect afterwards.
|
|
2474
|
+
*/
|
|
2475
|
+
connectTrackEffects(trackId, input, output) {
|
|
2431
2476
|
const trackNode = this._trackNodes.get(trackId);
|
|
2432
2477
|
if (!trackNode) {
|
|
2433
|
-
console.warn('[waveform-playlist]
|
|
2478
|
+
console.warn('[waveform-playlist] connectTrackEffects: unknown trackId "' + trackId + '"');
|
|
2434
2479
|
return;
|
|
2435
2480
|
}
|
|
2436
|
-
trackNode.connectEffects(
|
|
2481
|
+
trackNode.connectEffects(input, output);
|
|
2437
2482
|
}
|
|
2438
|
-
|
|
2483
|
+
/** Remove a track's effects chain and restore its direct routing. */
|
|
2484
|
+
disconnectTrackEffects(trackId) {
|
|
2439
2485
|
const trackNode = this._trackNodes.get(trackId);
|
|
2440
2486
|
if (!trackNode) {
|
|
2441
|
-
console.warn('[waveform-playlist]
|
|
2487
|
+
console.warn('[waveform-playlist] disconnectTrackEffects: unknown trackId "' + trackId + '"');
|
|
2442
2488
|
return;
|
|
2443
2489
|
}
|
|
2444
2490
|
trackNode.disconnectEffects();
|