Skip to content

Visualize Your Ideas With Code

feat: audio offset

aarthificial88f40aa93bb2
diff --git a/src/components/timeline/AudioTrack.tsx b/src/components/timeline/AudioTrack.tsx
index c761600f..830fda9a 100644
--- a/src/components/timeline/AudioTrack.tsx
+++ b/src/components/timeline/AudioTrack.tsx
@@ -20,10 +20,12 @@ export function AudioTrack() {
const samplesPerSeconds = audio.sample_rate / audio.samples_per_pixel;
const step = Math.ceil(density / 256);
const start = Math.floor(
- player.project.framesToSeconds(startFrame) * samplesPerSeconds,
+ (player.project.framesToSeconds(startFrame) + player.audio.offset) *
+ samplesPerSeconds,
);
const end = Math.floor(
- player.project.framesToSeconds(endFrame) * samplesPerSeconds,
+ (player.project.framesToSeconds(endFrame) + player.audio.offset) *
+ samplesPerSeconds,
);
context.clearRect(0, 0, viewLength, 64);
diff --git a/src/components/timeline/Timeline.tsx b/src/components/timeline/Timeline.tsx
index 20252e0c..b7058c1d 100644
--- a/src/components/timeline/Timeline.tsx
+++ b/src/components/timeline/Timeline.tsx
@@ -155,7 +155,7 @@ export function Timeline() {
<TimestampTrack />
<SceneTrack />
<LabelTrack />
- <AudioTrack />
+ {player.audio && <AudioTrack />}
</div>
<div ref={playheadRef} className={styles.playheadPreview} />
<Playhead />