From 4e3dd937e213c98b24658ce73647b0006fa6880c Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Sun, 16 Jul 2017 23:58:16 -0500 Subject: [PATCH] Fixing audio pops when stacking multiple clips with different offsets (pretty big issue for some people, just depending on your source framerates and position/start of clips). --- src/FrameMapper.cpp | 2 +- src/Timeline.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/FrameMapper.cpp b/src/FrameMapper.cpp index 3e548d42..f10b3597 100644 --- a/src/FrameMapper.cpp +++ b/src/FrameMapper.cpp @@ -346,7 +346,7 @@ tr1::shared_ptr FrameMapper::GetOrCreateFrame(long int number) tr1::shared_ptr new_frame; // Init some basic properties about this frame (keep sample rate and # channels the same as the original reader for now) - int samples_in_frame = Frame::GetSamplesPerFrame(number, target, reader->info.sample_rate, reader->info.channels); + int samples_in_frame = Frame::GetSamplesPerFrame(number + timeline_frame_offset, target, reader->info.sample_rate, reader->info.channels); try { // Debug output diff --git a/src/Timeline.cpp b/src/Timeline.cpp index 28aec740..7a36174e 100644 --- a/src/Timeline.cpp +++ b/src/Timeline.cpp @@ -130,6 +130,11 @@ void Timeline::apply_mapper_to_clip(Clip* clip) // Update timeline offset float time_diff = 0 - clip->Position() + clip->Start(); int clip_offset = -round(time_diff * info.fps.ToFloat()); + + if (clip_offset != 0) + // Reduce negative offset by 1 (since we want to avoid frame 0) + clip_offset += 1; + clip_mapped_reader->SetTimelineFrameOffset(clip_offset); // Update clip reader