@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/dist/index.mjs
CHANGED
|
@@ -756,28 +756,25 @@ var ClipPlayer = class {
|
|
|
756
756
|
}
|
|
757
757
|
generate(fromTick, toTick) {
|
|
758
758
|
const events = [];
|
|
759
|
-
const fromSample = this._sampleTimeline.ticksToSamples(fromTick);
|
|
760
|
-
const toSample = this._sampleTimeline.ticksToSamples(toTick);
|
|
761
759
|
for (const [trackId, state] of this._tracks) {
|
|
762
760
|
for (const clip of state.clips) {
|
|
763
761
|
if (clip.durationSamples === 0) continue;
|
|
764
762
|
if (!clip.audioBuffer) continue;
|
|
765
|
-
const
|
|
766
|
-
if (
|
|
767
|
-
if (
|
|
763
|
+
const clipTick = clip.startTick !== void 0 ? clip.startTick : this._sampleTimeline.samplesToTicks(clip.startSample);
|
|
764
|
+
if (clipTick < fromTick) continue;
|
|
765
|
+
if (clipTick >= toTick) continue;
|
|
768
766
|
const fadeInDurationSamples = clip.fadeIn ? clip.fadeIn.duration ?? 0 : 0;
|
|
769
767
|
const fadeOutDurationSamples = clip.fadeOut ? clip.fadeOut.duration ?? 0 : 0;
|
|
770
768
|
let durationSamples = clip.durationSamples;
|
|
771
|
-
if (this._loopEnabled &&
|
|
772
|
-
durationSamples = this._loopEndSamples -
|
|
769
|
+
if (this._loopEnabled && clip.startSample + durationSamples > this._loopEndSamples) {
|
|
770
|
+
durationSamples = this._loopEndSamples - clip.startSample;
|
|
773
771
|
}
|
|
774
|
-
const clipTick = this._sampleTimeline.samplesToTicks(clipStartSample);
|
|
775
772
|
events.push({
|
|
776
773
|
trackId,
|
|
777
774
|
clipId: clip.id,
|
|
778
775
|
audioBuffer: clip.audioBuffer,
|
|
779
776
|
tick: clipTick,
|
|
780
|
-
startSample:
|
|
777
|
+
startSample: clip.startSample,
|
|
781
778
|
offsetSamples: clip.offsetSamples,
|
|
782
779
|
durationSamples,
|
|
783
780
|
gain: clip.gain,
|
|
@@ -850,30 +847,30 @@ var ClipPlayer = class {
|
|
|
850
847
|
for (const clip of state.clips) {
|
|
851
848
|
if (clip.durationSamples === 0) continue;
|
|
852
849
|
if (!clip.audioBuffer) continue;
|
|
853
|
-
const
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
if (durationSamples <= 0) continue;
|
|
863
|
-
const fadeOutDurationSamples = clip.fadeOut ? clip.fadeOut.duration ?? 0 : 0;
|
|
864
|
-
this.consume({
|
|
865
|
-
trackId,
|
|
866
|
-
clipId: clip.id,
|
|
867
|
-
audioBuffer: clip.audioBuffer,
|
|
868
|
-
tick: newTick,
|
|
869
|
-
startSample: newSample,
|
|
870
|
-
offsetSamples,
|
|
871
|
-
durationSamples,
|
|
872
|
-
gain: clip.gain,
|
|
873
|
-
fadeInDurationSamples: 0,
|
|
874
|
-
fadeOutDurationSamples
|
|
875
|
-
});
|
|
850
|
+
const clipTick = clip.startTick !== void 0 ? clip.startTick : this._sampleTimeline.samplesToTicks(clip.startSample);
|
|
851
|
+
if (clipTick >= newTick) continue;
|
|
852
|
+
const clipEndSample = clip.startSample + clip.durationSamples;
|
|
853
|
+
if (clipEndSample <= newSample) continue;
|
|
854
|
+
const offsetIntoClipSamples = newSample - clip.startSample;
|
|
855
|
+
const offsetSamples = clip.offsetSamples + offsetIntoClipSamples;
|
|
856
|
+
let durationSamples = clipEndSample - newSample;
|
|
857
|
+
if (this._loopEnabled && newSample + durationSamples > this._loopEndSamples) {
|
|
858
|
+
durationSamples = this._loopEndSamples - newSample;
|
|
876
859
|
}
|
|
860
|
+
if (durationSamples <= 0) continue;
|
|
861
|
+
const fadeOutDurationSamples = clip.fadeOut ? clip.fadeOut.duration ?? 0 : 0;
|
|
862
|
+
this.consume({
|
|
863
|
+
trackId,
|
|
864
|
+
clipId: clip.id,
|
|
865
|
+
audioBuffer: clip.audioBuffer,
|
|
866
|
+
tick: newTick,
|
|
867
|
+
startSample: newSample,
|
|
868
|
+
offsetSamples,
|
|
869
|
+
durationSamples,
|
|
870
|
+
gain: clip.gain,
|
|
871
|
+
fadeInDurationSamples: 0,
|
|
872
|
+
fadeOutDurationSamples
|
|
873
|
+
});
|
|
877
874
|
}
|
|
878
875
|
}
|
|
879
876
|
}
|
|
@@ -1865,6 +1862,22 @@ var NativePlayoutAdapter = class {
|
|
|
1865
1862
|
isCountingIn() {
|
|
1866
1863
|
return this._transport.isCountingIn();
|
|
1867
1864
|
}
|
|
1865
|
+
setTempo(bpm, atTick) {
|
|
1866
|
+
this._transport.setTempo(bpm, atTick !== void 0 ? atTick : void 0);
|
|
1867
|
+
}
|
|
1868
|
+
setMeter(numerator, denominator, atTick) {
|
|
1869
|
+
this._transport.setMeter(
|
|
1870
|
+
numerator,
|
|
1871
|
+
denominator,
|
|
1872
|
+
atTick !== void 0 ? atTick : void 0
|
|
1873
|
+
);
|
|
1874
|
+
}
|
|
1875
|
+
ticksToSeconds(tick) {
|
|
1876
|
+
return this._transport.tickToTime(tick);
|
|
1877
|
+
}
|
|
1878
|
+
secondsToTicks(seconds) {
|
|
1879
|
+
return this._transport.timeToTick(seconds);
|
|
1880
|
+
}
|
|
1868
1881
|
dispose() {
|
|
1869
1882
|
this._transport.dispose();
|
|
1870
1883
|
}
|