@dawcore/transport 0.0.12 → 0.0.14
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 +33 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +73 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +73 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Native Web Audio transport for multi-track audio scheduling, looping, tempo, and
|
|
|
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
12
|
- **Per-track signal chain** — Native GainNode (volume) → StereoPannerNode → GainNode (mute) → effects hook → master output.
|
|
13
|
-
- **Effects plugin hook** — `connectTrackOutput(trackId, node)`
|
|
13
|
+
- **Effects plugin hook** — `connectTrackOutput(trackId, node)` 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
|
|
|
@@ -55,9 +55,12 @@ import { NativePlayoutAdapter } from '@dawcore/transport';
|
|
|
55
55
|
const audioContext = new AudioContext({ sampleRate: 48000 });
|
|
56
56
|
const adapter = new NativePlayoutAdapter(audioContext);
|
|
57
57
|
|
|
58
|
-
// Use as daw-editor's adapter
|
|
58
|
+
// Use as daw-editor's playout adapter
|
|
59
59
|
const editor = document.querySelector('daw-editor');
|
|
60
|
-
editor.
|
|
60
|
+
editor.adapter = adapter;
|
|
61
|
+
|
|
62
|
+
// Transport-specific APIs stay available on your adapter reference
|
|
63
|
+
adapter.transport.setMetronomeEnabled(true);
|
|
61
64
|
```
|
|
62
65
|
|
|
63
66
|
### Metronome
|
|
@@ -156,6 +159,17 @@ transport.connectTrackOutput('vocals', reverb);
|
|
|
156
159
|
|
|
157
160
|
// Remove effects — restores direct routing to master
|
|
158
161
|
transport.disconnectTrackOutput('vocals');
|
|
162
|
+
|
|
163
|
+
// Master bus effects — inserted between master gain and destination
|
|
164
|
+
const compressor = audioContext.createDynamicsCompressor();
|
|
165
|
+
compressor.connect(audioContext.destination);
|
|
166
|
+
|
|
167
|
+
transport.connectMasterOutput(compressor);
|
|
168
|
+
|
|
169
|
+
// Remove master effects — restores direct routing to destination.
|
|
170
|
+
// Parallel taps on transport.masterOutputNode (analyzers, recorders)
|
|
171
|
+
// are unaffected by connect/disconnect.
|
|
172
|
+
transport.disconnectMasterOutput();
|
|
159
173
|
```
|
|
160
174
|
|
|
161
175
|
## API
|
|
@@ -205,7 +219,8 @@ new Transport(audioContext: AudioContext, options?: TransportOptions)
|
|
|
205
219
|
- `setLoopSamples(enabled, startSample: Sample, endSample: Sample)` — Set loop region in samples (convenience)
|
|
206
220
|
|
|
207
221
|
**Tempo & Meter:**
|
|
208
|
-
- `setTempo(bpm, atTick?, options?)` / `getTempo(atTick?: Tick)` — options: `{ interpolation: 'step' | 'linear' | { type: 'curve', slope } }`
|
|
222
|
+
- `setTempo(bpm, atTick?, options?)` / `getTempo(atTick?: Tick)` — options: `{ interpolation: 'step' | 'linear' | { type: 'curve', slope } }`. Returns `boolean`: a defaulted `atTick` is the single-BPM convenience path and is refused (with a warning) when the tempo map has more than one entry — pass an explicit `atTick` to modify a tempo curve.
|
|
223
|
+
- `removeTempo(atTick: Tick)` — remove the tempo entry at a tick (the tick-0 entry cannot be removed)
|
|
209
224
|
- `clearTempos()` — remove all tempo entries
|
|
210
225
|
- `setMeter(numerator, denominator, atTick?: Tick)` / `getMeter(atTick?: Tick)`
|
|
211
226
|
- `removeMeter(atTick: Tick)` / `clearMeters()`
|
|
@@ -224,12 +239,16 @@ new Transport(audioContext: AudioContext, options?: TransportOptions)
|
|
|
224
239
|
- `isCountingIn()` — whether count-in is active
|
|
225
240
|
|
|
226
241
|
**Effects:**
|
|
227
|
-
- `connectTrackOutput(trackId, node)` — Insert effects chain
|
|
228
|
-
- `disconnectTrackOutput(trackId)` — Remove effects chain
|
|
242
|
+
- `connectTrackOutput(trackId, node)` — Insert per-track effects chain
|
|
243
|
+
- `disconnectTrackOutput(trackId)` — Remove per-track effects chain
|
|
244
|
+
- `connectMasterOutput(node)` — Insert master bus effects chain
|
|
245
|
+
- `disconnectMasterOutput()` — Remove master bus effects chain
|
|
246
|
+
- `masterOutputNode` (getter) — Master gain node, for parallel taps (analyzers, recorders) that should survive chain connect/disconnect
|
|
229
247
|
|
|
230
248
|
**Events:**
|
|
231
249
|
- `on(event, callback)` / `off(event, callback)`
|
|
232
|
-
- Events: `play`, `pause`, `stop`, `loop`, `tempochange`, `meterchange`, `countIn`, `countInEnd`
|
|
250
|
+
- Events: `play`, `pause`, `stop`, `seek`, `loop`, `tempochange`, `meterchange`, `countIn`, `countInEnd`
|
|
251
|
+
- `seek` payload: `{ seconds: number }`
|
|
233
252
|
- `tempochange` payload: `{ bpm: number, atTick: Tick }`
|
|
234
253
|
- `meterchange` payload: `{ numerator: number, denominator: number, atTick: Tick }`
|
|
235
254
|
- `countIn` payload: `{ beat: number, totalBeats: number }`
|
|
@@ -245,15 +264,27 @@ new NativePlayoutAdapter(audioContext: AudioContext, options?: TransportOptions)
|
|
|
245
264
|
|
|
246
265
|
Implements `PlayoutAdapter` from `@waveform-playlist/engine`. All methods delegate to the internal `Transport` instance.
|
|
247
266
|
|
|
248
|
-
- `adapter.transport` — Direct access to the `Transport` for tempo, metronome, and effects APIs
|
|
267
|
+
- `adapter.transport` — Direct access to the `Transport` for tempo, metronome, count-in, and effects APIs
|
|
268
|
+
- `adapter.ppqn` — Tick resolution, read by the engine on construction
|
|
269
|
+
- `adapter.masterOutputNode` — Master gain node for parallel taps (analyzers, recorders)
|
|
270
|
+
- `adapter.init()` — Resumes a suspended AudioContext and waits for the hardware pipeline to warm up (Safari needs this before clips scheduled at time 0 play on time)
|
|
271
|
+
- `setTempo(bpm, atTick?)`, `setMeter(numerator, denominator, atTick?)`, `ticksToSeconds(tick)`, `secondsToTicks(seconds)` — tempo/meter surface the engine uses for tick-based timeline math
|
|
272
|
+
|
|
273
|
+
## Examples
|
|
274
|
+
|
|
275
|
+
[`examples/dawcore-native/`](https://github.com/naomiaro/waveform-playlist/tree/main/examples/dawcore-native) pairs this transport with the `@dawcore/components` editor: metronome, tempo automation, mixed meter, beat-map grids, effects, and recording pages (`pnpm example:dawcore-native`).
|
|
249
276
|
|
|
250
277
|
## Architecture
|
|
251
278
|
|
|
252
|
-
See [TRANSPORT.md](
|
|
279
|
+
See [TRANSPORT.md](https://github.com/naomiaro/waveform-playlist/blob/main/packages/transport/TRANSPORT.md) for the full architecture guide.
|
|
253
280
|
|
|
254
281
|
## How It Works
|
|
255
282
|
|
|
256
|
-
See [EDUCATIONAL.md](
|
|
283
|
+
See [EDUCATIONAL.md](https://github.com/naomiaro/waveform-playlist/blob/main/packages/transport/EDUCATIONAL.md) for an in-depth explanation of the math and timing models behind audio transport systems.
|
|
284
|
+
|
|
285
|
+
## Documentation
|
|
286
|
+
|
|
287
|
+
Full guides at [naomiaro.github.io/waveform-playlist](https://naomiaro.github.io/waveform-playlist/).
|
|
257
288
|
|
|
258
289
|
## License
|
|
259
290
|
|
package/dist/index.d.mts
CHANGED
|
@@ -212,6 +212,7 @@ declare class Scheduler<T extends SchedulerEvent> {
|
|
|
212
212
|
private _loopEnabled;
|
|
213
213
|
private _loopStart;
|
|
214
214
|
private _loopEnd;
|
|
215
|
+
private _playEnd;
|
|
215
216
|
private _onLoop;
|
|
216
217
|
private _tempoMap;
|
|
217
218
|
constructor(tempoMap: TempoMap, options?: SchedulerOptions);
|
|
@@ -221,6 +222,12 @@ declare class Scheduler<T extends SchedulerEvent> {
|
|
|
221
222
|
setLoop(enabled: boolean, startTick: Tick, endTick: Tick): void;
|
|
222
223
|
/** Convenience — converts seconds to ticks via TempoMap */
|
|
223
224
|
setLoopSeconds(enabled: boolean, startSec: number, endSec: number): void;
|
|
225
|
+
/** Hard end bound (ticks) for non-loop playback: the lookahead window never
|
|
226
|
+
* generates events at or beyond this tick, so audio (metronome clicks, clips)
|
|
227
|
+
* can't be scheduled past the playback end and sound a beat into the next
|
|
228
|
+
* (nonexistent) bar. Null = unbounded. Set from Transport.play()'s endTime; the
|
|
229
|
+
* loop path is unaffected (loopEnd already bounds it). */
|
|
230
|
+
setPlayEnd(endTick: Tick | null): void;
|
|
224
231
|
/** Reset scheduling cursor. Takes seconds (from Clock), converts to ticks. */
|
|
225
232
|
reset(timeSeconds: number): void;
|
|
226
233
|
/** Advance the scheduling window. Takes seconds (from Clock), converts to ticks. */
|
|
@@ -281,9 +288,22 @@ declare class MeterMap {
|
|
|
281
288
|
|
|
282
289
|
declare class MasterNode {
|
|
283
290
|
private _gainNode;
|
|
291
|
+
private _destination;
|
|
292
|
+
private _effectsInput;
|
|
284
293
|
constructor(audioContext: AudioContext);
|
|
285
294
|
get input(): AudioNode;
|
|
286
295
|
get output(): AudioNode;
|
|
296
|
+
/** Connect the master output to its final destination (audioContext.destination) */
|
|
297
|
+
connectOutput(destination: AudioNode): void;
|
|
298
|
+
/**
|
|
299
|
+
* Insert an effects chain between the master gain and the destination.
|
|
300
|
+
* Only the destination edge is severed (targeted disconnect), so parallel
|
|
301
|
+
* taps on the master output (analyzers, recorders) keep working.
|
|
302
|
+
* The caller is responsible for routing the chain's output onward.
|
|
303
|
+
*/
|
|
304
|
+
connectEffects(effectsInput: AudioNode): void;
|
|
305
|
+
/** Remove the effects chain and restore direct routing to the destination */
|
|
306
|
+
disconnectEffects(): void;
|
|
287
307
|
setVolume(value: number): void;
|
|
288
308
|
dispose(): void;
|
|
289
309
|
}
|
|
@@ -393,6 +413,9 @@ interface TransportEvents {
|
|
|
393
413
|
pause: () => void;
|
|
394
414
|
stop: () => void;
|
|
395
415
|
loop: () => void;
|
|
416
|
+
seek: (event: {
|
|
417
|
+
seconds: number;
|
|
418
|
+
}) => void;
|
|
396
419
|
tempochange: (event: TempoChangeEventData) => void;
|
|
397
420
|
meterchange: (event: MeterChangeEventData) => void;
|
|
398
421
|
countIn: (event: CountInEventData) => void;
|
|
@@ -492,6 +515,16 @@ declare class Transport {
|
|
|
492
515
|
/** The master output AudioNode. Connect your own nodes (analyzers, recorders, etc.)
|
|
493
516
|
* in parallel. The transport already routes this to audioContext.destination. */
|
|
494
517
|
get masterOutputNode(): AudioNode;
|
|
518
|
+
/**
|
|
519
|
+
* Insert an effects chain on the master bus, between the master gain and
|
|
520
|
+
* audioContext.destination. Accepts any AudioNode chain (Tone.js effects,
|
|
521
|
+
* WAM plugins, native nodes). The caller is responsible for connecting the
|
|
522
|
+
* chain's output to audioContext.destination. Calling again replaces the
|
|
523
|
+
* previous chain. Parallel taps on `masterOutputNode` are unaffected.
|
|
524
|
+
*/
|
|
525
|
+
connectMasterOutput(node: AudioNode): void;
|
|
526
|
+
/** Remove the master effects chain and restore direct routing to audioContext.destination. */
|
|
527
|
+
disconnectMasterOutput(): void;
|
|
495
528
|
on<K extends TransportEventType>(event: K, cb: TransportEvents[K]): void;
|
|
496
529
|
off<K extends TransportEventType>(event: K, cb: TransportEvents[K]): void;
|
|
497
530
|
dispose(): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -212,6 +212,7 @@ declare class Scheduler<T extends SchedulerEvent> {
|
|
|
212
212
|
private _loopEnabled;
|
|
213
213
|
private _loopStart;
|
|
214
214
|
private _loopEnd;
|
|
215
|
+
private _playEnd;
|
|
215
216
|
private _onLoop;
|
|
216
217
|
private _tempoMap;
|
|
217
218
|
constructor(tempoMap: TempoMap, options?: SchedulerOptions);
|
|
@@ -221,6 +222,12 @@ declare class Scheduler<T extends SchedulerEvent> {
|
|
|
221
222
|
setLoop(enabled: boolean, startTick: Tick, endTick: Tick): void;
|
|
222
223
|
/** Convenience — converts seconds to ticks via TempoMap */
|
|
223
224
|
setLoopSeconds(enabled: boolean, startSec: number, endSec: number): void;
|
|
225
|
+
/** Hard end bound (ticks) for non-loop playback: the lookahead window never
|
|
226
|
+
* generates events at or beyond this tick, so audio (metronome clicks, clips)
|
|
227
|
+
* can't be scheduled past the playback end and sound a beat into the next
|
|
228
|
+
* (nonexistent) bar. Null = unbounded. Set from Transport.play()'s endTime; the
|
|
229
|
+
* loop path is unaffected (loopEnd already bounds it). */
|
|
230
|
+
setPlayEnd(endTick: Tick | null): void;
|
|
224
231
|
/** Reset scheduling cursor. Takes seconds (from Clock), converts to ticks. */
|
|
225
232
|
reset(timeSeconds: number): void;
|
|
226
233
|
/** Advance the scheduling window. Takes seconds (from Clock), converts to ticks. */
|
|
@@ -281,9 +288,22 @@ declare class MeterMap {
|
|
|
281
288
|
|
|
282
289
|
declare class MasterNode {
|
|
283
290
|
private _gainNode;
|
|
291
|
+
private _destination;
|
|
292
|
+
private _effectsInput;
|
|
284
293
|
constructor(audioContext: AudioContext);
|
|
285
294
|
get input(): AudioNode;
|
|
286
295
|
get output(): AudioNode;
|
|
296
|
+
/** Connect the master output to its final destination (audioContext.destination) */
|
|
297
|
+
connectOutput(destination: AudioNode): void;
|
|
298
|
+
/**
|
|
299
|
+
* Insert an effects chain between the master gain and the destination.
|
|
300
|
+
* Only the destination edge is severed (targeted disconnect), so parallel
|
|
301
|
+
* taps on the master output (analyzers, recorders) keep working.
|
|
302
|
+
* The caller is responsible for routing the chain's output onward.
|
|
303
|
+
*/
|
|
304
|
+
connectEffects(effectsInput: AudioNode): void;
|
|
305
|
+
/** Remove the effects chain and restore direct routing to the destination */
|
|
306
|
+
disconnectEffects(): void;
|
|
287
307
|
setVolume(value: number): void;
|
|
288
308
|
dispose(): void;
|
|
289
309
|
}
|
|
@@ -393,6 +413,9 @@ interface TransportEvents {
|
|
|
393
413
|
pause: () => void;
|
|
394
414
|
stop: () => void;
|
|
395
415
|
loop: () => void;
|
|
416
|
+
seek: (event: {
|
|
417
|
+
seconds: number;
|
|
418
|
+
}) => void;
|
|
396
419
|
tempochange: (event: TempoChangeEventData) => void;
|
|
397
420
|
meterchange: (event: MeterChangeEventData) => void;
|
|
398
421
|
countIn: (event: CountInEventData) => void;
|
|
@@ -492,6 +515,16 @@ declare class Transport {
|
|
|
492
515
|
/** The master output AudioNode. Connect your own nodes (analyzers, recorders, etc.)
|
|
493
516
|
* in parallel. The transport already routes this to audioContext.destination. */
|
|
494
517
|
get masterOutputNode(): AudioNode;
|
|
518
|
+
/**
|
|
519
|
+
* Insert an effects chain on the master bus, between the master gain and
|
|
520
|
+
* audioContext.destination. Accepts any AudioNode chain (Tone.js effects,
|
|
521
|
+
* WAM plugins, native nodes). The caller is responsible for connecting the
|
|
522
|
+
* chain's output to audioContext.destination. Calling again replaces the
|
|
523
|
+
* previous chain. Parallel taps on `masterOutputNode` are unaffected.
|
|
524
|
+
*/
|
|
525
|
+
connectMasterOutput(node: AudioNode): void;
|
|
526
|
+
/** Remove the master effects chain and restore direct routing to audioContext.destination. */
|
|
527
|
+
disconnectMasterOutput(): void;
|
|
495
528
|
on<K extends TransportEventType>(event: K, cb: TransportEvents[K]): void;
|
|
496
529
|
off<K extends TransportEventType>(event: K, cb: TransportEvents[K]): void;
|
|
497
530
|
dispose(): void;
|
package/dist/index.js
CHANGED
|
@@ -94,6 +94,8 @@ var Scheduler = class {
|
|
|
94
94
|
this._loopStart = 0;
|
|
95
95
|
// integer ticks
|
|
96
96
|
this._loopEnd = 0;
|
|
97
|
+
// integer ticks
|
|
98
|
+
this._playEnd = null;
|
|
97
99
|
this._tempoMap = tempoMap;
|
|
98
100
|
this._lookahead = options.lookahead ?? 0.2;
|
|
99
101
|
this._onLoop = options.onLoop;
|
|
@@ -128,6 +130,14 @@ var Scheduler = class {
|
|
|
128
130
|
const endTick = this._tempoMap.secondsToTicks(endSec);
|
|
129
131
|
this.setLoop(enabled, startTick, endTick);
|
|
130
132
|
}
|
|
133
|
+
/** Hard end bound (ticks) for non-loop playback: the lookahead window never
|
|
134
|
+
* generates events at or beyond this tick, so audio (metronome clicks, clips)
|
|
135
|
+
* can't be scheduled past the playback end and sound a beat into the next
|
|
136
|
+
* (nonexistent) bar. Null = unbounded. Set from Transport.play()'s endTime; the
|
|
137
|
+
* loop path is unaffected (loopEnd already bounds it). */
|
|
138
|
+
setPlayEnd(endTick) {
|
|
139
|
+
this._playEnd = endTick == null ? null : Math.round(endTick);
|
|
140
|
+
}
|
|
131
141
|
/** Reset scheduling cursor. Takes seconds (from Clock), converts to ticks. */
|
|
132
142
|
reset(timeSeconds) {
|
|
133
143
|
this._rightEdge = this._tempoMap.secondsToTicks(timeSeconds);
|
|
@@ -160,9 +170,10 @@ var Scheduler = class {
|
|
|
160
170
|
}
|
|
161
171
|
return;
|
|
162
172
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
this._rightEdge
|
|
173
|
+
const bound = this._playEnd !== null && targetTick > this._playEnd ? this._playEnd : targetTick;
|
|
174
|
+
if (bound > this._rightEdge) {
|
|
175
|
+
this._generateAndConsume(this._rightEdge, bound);
|
|
176
|
+
this._rightEdge = bound;
|
|
166
177
|
}
|
|
167
178
|
}
|
|
168
179
|
_generateAndConsume(fromTick, toTick) {
|
|
@@ -711,6 +722,8 @@ var MeterMap = class {
|
|
|
711
722
|
// src/audio/master-node.ts
|
|
712
723
|
var MasterNode = class {
|
|
713
724
|
constructor(audioContext) {
|
|
725
|
+
this._destination = null;
|
|
726
|
+
this._effectsInput = null;
|
|
714
727
|
this._gainNode = audioContext.createGain();
|
|
715
728
|
}
|
|
716
729
|
get input() {
|
|
@@ -719,6 +732,37 @@ var MasterNode = class {
|
|
|
719
732
|
get output() {
|
|
720
733
|
return this._gainNode;
|
|
721
734
|
}
|
|
735
|
+
/** Connect the master output to its final destination (audioContext.destination) */
|
|
736
|
+
connectOutput(destination) {
|
|
737
|
+
this._destination = destination;
|
|
738
|
+
this._gainNode.connect(destination);
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Insert an effects chain between the master gain and the destination.
|
|
742
|
+
* Only the destination edge is severed (targeted disconnect), so parallel
|
|
743
|
+
* taps on the master output (analyzers, recorders) keep working.
|
|
744
|
+
* The caller is responsible for routing the chain's output onward.
|
|
745
|
+
*/
|
|
746
|
+
connectEffects(effectsInput) {
|
|
747
|
+
if (this._effectsInput) {
|
|
748
|
+
this._gainNode.disconnect(this._effectsInput);
|
|
749
|
+
} else if (this._destination) {
|
|
750
|
+
this._gainNode.disconnect(this._destination);
|
|
751
|
+
}
|
|
752
|
+
this._gainNode.connect(effectsInput);
|
|
753
|
+
this._effectsInput = effectsInput;
|
|
754
|
+
}
|
|
755
|
+
/** Remove the effects chain and restore direct routing to the destination */
|
|
756
|
+
disconnectEffects() {
|
|
757
|
+
if (!this._effectsInput) {
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
this._gainNode.disconnect(this._effectsInput);
|
|
761
|
+
if (this._destination) {
|
|
762
|
+
this._gainNode.connect(this._destination);
|
|
763
|
+
}
|
|
764
|
+
this._effectsInput = null;
|
|
765
|
+
}
|
|
722
766
|
setVolume(value) {
|
|
723
767
|
this._gainNode.gain.value = value;
|
|
724
768
|
}
|
|
@@ -728,6 +772,8 @@ var MasterNode = class {
|
|
|
728
772
|
} catch (err) {
|
|
729
773
|
console.warn("[waveform-playlist] MasterNode.dispose: error disconnecting: " + String(err));
|
|
730
774
|
}
|
|
775
|
+
this._destination = null;
|
|
776
|
+
this._effectsInput = null;
|
|
731
777
|
}
|
|
732
778
|
};
|
|
733
779
|
|
|
@@ -1321,6 +1367,9 @@ var _Transport = class _Transport {
|
|
|
1321
1367
|
const currentTime = this._clock.getTime();
|
|
1322
1368
|
this._scheduler.reset(currentTime);
|
|
1323
1369
|
this._endTime = endTime;
|
|
1370
|
+
this._scheduler.setPlayEnd(
|
|
1371
|
+
endTime !== void 0 ? this._tempoMap.secondsToTicks(endTime) : null
|
|
1372
|
+
);
|
|
1324
1373
|
this._clock.start();
|
|
1325
1374
|
const currentTick = this._tempoMap.secondsToTicks(currentTime);
|
|
1326
1375
|
this._clipPlayer.onPositionJump(currentTick);
|
|
@@ -1354,6 +1403,7 @@ var _Transport = class _Transport {
|
|
|
1354
1403
|
this._silenceAll();
|
|
1355
1404
|
this._playing = false;
|
|
1356
1405
|
this._endTime = void 0;
|
|
1406
|
+
this._scheduler.setPlayEnd(null);
|
|
1357
1407
|
if (wasPlaying) {
|
|
1358
1408
|
this._emit("stop");
|
|
1359
1409
|
}
|
|
@@ -1372,12 +1422,14 @@ var _Transport = class _Transport {
|
|
|
1372
1422
|
this._clock.seekTo(time);
|
|
1373
1423
|
this._scheduler.reset(time);
|
|
1374
1424
|
this._endTime = void 0;
|
|
1425
|
+
this._scheduler.setPlayEnd(null);
|
|
1375
1426
|
if (wasPlaying && !wasCountingIn) {
|
|
1376
1427
|
this._clock.start();
|
|
1377
1428
|
const seekTick = this._tempoMap.secondsToTicks(time);
|
|
1378
1429
|
this._clipPlayer.onPositionJump(seekTick);
|
|
1379
1430
|
this._timer.start();
|
|
1380
1431
|
}
|
|
1432
|
+
this._emit("seek", { seconds: time });
|
|
1381
1433
|
}
|
|
1382
1434
|
getCurrentTime() {
|
|
1383
1435
|
if (this._countingIn) {
|
|
@@ -1687,6 +1739,20 @@ var _Transport = class _Transport {
|
|
|
1687
1739
|
get masterOutputNode() {
|
|
1688
1740
|
return this._masterNode.output;
|
|
1689
1741
|
}
|
|
1742
|
+
/**
|
|
1743
|
+
* Insert an effects chain on the master bus, between the master gain and
|
|
1744
|
+
* audioContext.destination. Accepts any AudioNode chain (Tone.js effects,
|
|
1745
|
+
* WAM plugins, native nodes). The caller is responsible for connecting the
|
|
1746
|
+
* chain's output to audioContext.destination. Calling again replaces the
|
|
1747
|
+
* previous chain. Parallel taps on `masterOutputNode` are unaffected.
|
|
1748
|
+
*/
|
|
1749
|
+
connectMasterOutput(node) {
|
|
1750
|
+
this._masterNode.connectEffects(node);
|
|
1751
|
+
}
|
|
1752
|
+
/** Remove the master effects chain and restore direct routing to audioContext.destination. */
|
|
1753
|
+
disconnectMasterOutput() {
|
|
1754
|
+
this._masterNode.disconnectEffects();
|
|
1755
|
+
}
|
|
1690
1756
|
// --- Events ---
|
|
1691
1757
|
on(event, cb) {
|
|
1692
1758
|
if (!this._listeners.has(event)) {
|
|
@@ -1740,7 +1806,7 @@ var _Transport = class _Transport {
|
|
|
1740
1806
|
}
|
|
1741
1807
|
_initAudioGraph(audioContext) {
|
|
1742
1808
|
this._masterNode = new MasterNode(audioContext);
|
|
1743
|
-
this._masterNode.
|
|
1809
|
+
this._masterNode.connectOutput(audioContext.destination);
|
|
1744
1810
|
const toAudioTime = (transportTime) => this._clock.toAudioTime(transportTime);
|
|
1745
1811
|
this._clipPlayer = new ClipPlayer(
|
|
1746
1812
|
audioContext,
|
|
@@ -1795,6 +1861,9 @@ var _Transport = class _Transport {
|
|
|
1795
1861
|
this._countingIn = true;
|
|
1796
1862
|
this._playing = true;
|
|
1797
1863
|
this._endTime = endTime;
|
|
1864
|
+
this._scheduler.setPlayEnd(
|
|
1865
|
+
endTime !== void 0 ? this._tempoMap.secondsToTicks(endTime) : null
|
|
1866
|
+
);
|
|
1798
1867
|
const playPositionTick = this._tempoMap.secondsToTicks(currentTime);
|
|
1799
1868
|
const meter = this._meterMap.getMeter(playPositionTick);
|
|
1800
1869
|
const totalBeats = meter.numerator * this._countInBars;
|