From 649b65b0781d69c5daebdd4ab2de877eb9f3b508 Mon Sep 17 00:00:00 2001 From: Shmuel H Date: Thu, 9 Nov 2017 09:08:56 +0200 Subject: [PATCH] SampleRecordHandle: Apply start offset to reocrded TCO. Previously, begining record in any position would result the data being in the end of the TCO. @see https://github.com/LMMS/lmms/pull/3947#issuecomment-342985355 Thanks to @-BaraMGB :) --- src/core/SampleRecordHandle.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/SampleRecordHandle.cpp b/src/core/SampleRecordHandle.cpp index cf9342b9e08..c77d24711a2 100644 --- a/src/core/SampleRecordHandle.cpp +++ b/src/core/SampleRecordHandle.cpp @@ -50,9 +50,15 @@ SampleRecordHandle::~SampleRecordHandle() { if( !m_buffers.empty() ) { + auto sampleStart = m_tco->sampleBuffer ()->startFrame (); + SampleBuffer* sb; createSampleBuffer( &sb ); m_tco->setSampleBuffer( sb ); + + // Apply the sample buffer offset from the start of the TCO. + MidiTime startTimeOffset = (tick_t)( sampleStart / Engine::framesPerTick()); + m_tco->setStartTimeOffset (startTimeOffset); } while( !m_buffers.empty() )