@dawcore/transport 0.0.6 → 0.0.8
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 +1 -4
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +45 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -7
package/README.md
CHANGED
|
@@ -20,10 +20,7 @@ Native Web Audio transport for multi-track audio scheduling, looping, tempo, and
|
|
|
20
20
|
npm install @dawcore/transport
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
npm install @waveform-playlist/core @waveform-playlist/engine
|
|
26
|
-
```
|
|
23
|
+
No runtime dependencies. When using `NativePlayoutAdapter` (bridge to `@waveform-playlist/engine`), install `@waveform-playlist/core` and `@waveform-playlist/engine` alongside.
|
|
27
24
|
|
|
28
25
|
## Quick Start
|
|
29
26
|
|
package/dist/index.d.mts
CHANGED
|
@@ -508,6 +508,10 @@ declare class NativePlayoutAdapter implements PlayoutAdapter {
|
|
|
508
508
|
setCountInMode(mode: CountInMode): void;
|
|
509
509
|
setRecording(recording: boolean): void;
|
|
510
510
|
isCountingIn(): boolean;
|
|
511
|
+
setTempo(bpm: number, atTick?: number): void;
|
|
512
|
+
setMeter(numerator: number, denominator: number, atTick?: number): void;
|
|
513
|
+
ticksToSeconds(tick: number): number;
|
|
514
|
+
secondsToTicks(seconds: number): number;
|
|
511
515
|
dispose(): void;
|
|
512
516
|
}
|
|
513
517
|
|
package/dist/index.d.ts
CHANGED
|
@@ -508,6 +508,10 @@ declare class NativePlayoutAdapter implements PlayoutAdapter {
|
|
|
508
508
|
setCountInMode(mode: CountInMode): void;
|
|
509
509
|
setRecording(recording: boolean): void;
|
|
510
510
|
isCountingIn(): boolean;
|
|
511
|
+
setTempo(bpm: number, atTick?: number): void;
|
|
512
|
+
setMeter(numerator: number, denominator: number, atTick?: number): void;
|
|
513
|
+
ticksToSeconds(tick: number): number;
|
|
514
|
+
secondsToTicks(seconds: number): number;
|
|
511
515
|
dispose(): void;
|
|
512
516
|
}
|
|
513
517
|
|
package/dist/index.js
CHANGED
|
@@ -793,28 +793,25 @@ var ClipPlayer = class {
|
|
|
793
793
|
}
|
|
794
794
|
generate(fromTick, toTick) {
|
|
795
795
|
const events = [];
|
|
796
|
-
const fromSample = this._sampleTimeline.ticksToSamples(fromTick);
|
|
797
|
-
const toSample = this._sampleTimeline.ticksToSamples(toTick);
|
|
798
796
|
for (const [trackId, state] of this._tracks) {
|
|
799
797
|
for (const clip of state.clips) {
|
|
800
798
|
if (clip.durationSamples === 0) continue;
|
|
801
799
|
if (!clip.audioBuffer) continue;
|
|
802
|
-
const
|
|
803
|
-
if (
|
|
804
|
-
if (
|
|
800
|
+
const clipTick = clip.startTick !== void 0 ? clip.startTick : this._sampleTimeline.samplesToTicks(clip.startSample);
|
|
801
|
+
if (clipTick < fromTick) continue;
|
|
802
|
+
if (clipTick >= toTick) continue;
|
|
805
803
|
const fadeInDurationSamples = clip.fadeIn ? clip.fadeIn.duration ?? 0 : 0;
|
|
806
804
|
const fadeOutDurationSamples = clip.fadeOut ? clip.fadeOut.duration ?? 0 : 0;
|
|
807
805
|
let durationSamples = clip.durationSamples;
|
|
808
|
-
if (this._loopEnabled &&
|
|
809
|
-
durationSamples = this._loopEndSamples -
|
|
806
|
+
if (this._loopEnabled && clip.startSample + durationSamples > this._loopEndSamples) {
|
|
807
|
+
durationSamples = this._loopEndSamples - clip.startSample;
|
|
810
808
|
}
|
|
811
|
-
const clipTick = this._sampleTimeline.samplesToTicks(clipStartSample);
|
|
812
809
|
events.push({
|
|
813
810
|
trackId,
|
|
814
811
|
clipId: clip.id,
|
|
815
812
|
audioBuffer: clip.audioBuffer,
|
|
816
813
|
tick: clipTick,
|
|
817
|
-
startSample:
|
|
814
|
+
startSample: clip.startSample,
|
|
818
815
|
offsetSamples: clip.offsetSamples,
|
|
819
816
|
durationSamples,
|
|
820
817
|
gain: clip.gain,
|
|
@@ -887,30 +884,30 @@ var ClipPlayer = class {
|
|
|
887
884
|
for (const clip of state.clips) {
|
|
888
885
|
if (clip.durationSamples === 0) continue;
|
|
889
886
|
if (!clip.audioBuffer) continue;
|
|
890
|
-
const
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
if (durationSamples <= 0) continue;
|
|
900
|
-
const fadeOutDurationSamples = clip.fadeOut ? clip.fadeOut.duration ?? 0 : 0;
|
|
901
|
-
this.consume({
|
|
902
|
-
trackId,
|
|
903
|
-
clipId: clip.id,
|
|
904
|
-
audioBuffer: clip.audioBuffer,
|
|
905
|
-
tick: newTick,
|
|
906
|
-
startSample: newSample,
|
|
907
|
-
offsetSamples,
|
|
908
|
-
durationSamples,
|
|
909
|
-
gain: clip.gain,
|
|
910
|
-
fadeInDurationSamples: 0,
|
|
911
|
-
fadeOutDurationSamples
|
|
912
|
-
});
|
|
887
|
+
const clipTick = clip.startTick !== void 0 ? clip.startTick : this._sampleTimeline.samplesToTicks(clip.startSample);
|
|
888
|
+
if (clipTick >= newTick) continue;
|
|
889
|
+
const clipEndSample = clip.startSample + clip.durationSamples;
|
|
890
|
+
if (clipEndSample <= newSample) continue;
|
|
891
|
+
const offsetIntoClipSamples = newSample - clip.startSample;
|
|
892
|
+
const offsetSamples = clip.offsetSamples + offsetIntoClipSamples;
|
|
893
|
+
let durationSamples = clipEndSample - newSample;
|
|
894
|
+
if (this._loopEnabled && newSample + durationSamples > this._loopEndSamples) {
|
|
895
|
+
durationSamples = this._loopEndSamples - newSample;
|
|
913
896
|
}
|
|
897
|
+
if (durationSamples <= 0) continue;
|
|
898
|
+
const fadeOutDurationSamples = clip.fadeOut ? clip.fadeOut.duration ?? 0 : 0;
|
|
899
|
+
this.consume({
|
|
900
|
+
trackId,
|
|
901
|
+
clipId: clip.id,
|
|
902
|
+
audioBuffer: clip.audioBuffer,
|
|
903
|
+
tick: newTick,
|
|
904
|
+
startSample: newSample,
|
|
905
|
+
offsetSamples,
|
|
906
|
+
durationSamples,
|
|
907
|
+
gain: clip.gain,
|
|
908
|
+
fadeInDurationSamples: 0,
|
|
909
|
+
fadeOutDurationSamples
|
|
910
|
+
});
|
|
914
911
|
}
|
|
915
912
|
}
|
|
916
913
|
}
|
|
@@ -1902,6 +1899,22 @@ var NativePlayoutAdapter = class {
|
|
|
1902
1899
|
isCountingIn() {
|
|
1903
1900
|
return this._transport.isCountingIn();
|
|
1904
1901
|
}
|
|
1902
|
+
setTempo(bpm, atTick) {
|
|
1903
|
+
this._transport.setTempo(bpm, atTick !== void 0 ? atTick : void 0);
|
|
1904
|
+
}
|
|
1905
|
+
setMeter(numerator, denominator, atTick) {
|
|
1906
|
+
this._transport.setMeter(
|
|
1907
|
+
numerator,
|
|
1908
|
+
denominator,
|
|
1909
|
+
atTick !== void 0 ? atTick : void 0
|
|
1910
|
+
);
|
|
1911
|
+
}
|
|
1912
|
+
ticksToSeconds(tick) {
|
|
1913
|
+
return this._transport.tickToTime(tick);
|
|
1914
|
+
}
|
|
1915
|
+
secondsToTicks(seconds) {
|
|
1916
|
+
return this._transport.timeToTick(seconds);
|
|
1917
|
+
}
|
|
1905
1918
|
dispose() {
|
|
1906
1919
|
this._transport.dispose();
|
|
1907
1920
|
}
|