diff --git a/src/core/SampleClip.cpp b/src/core/SampleClip.cpp index 11aabc2ff..007265c0c 100644 --- a/src/core/SampleClip.cpp +++ b/src/core/SampleClip.cpp @@ -179,26 +179,21 @@ void SampleClip::setSampleBuffer(std::shared_ptr sb) void SampleClip::setSampleFile(const QString& sf) { - int length = 0; - + // Remove any prior offset in the clip + setStartTimeOffset(0); if (!sf.isEmpty()) { - //Otherwise set it to the sample's length m_sample = Sample(gui::SampleLoader::createBufferFromFile(sf)); - length = sampleLength(); + updateLength(); } - - if (length == 0) + else { - //If there is no sample, make the clip a bar long + // If there is no sample, make the clip a bar long float nom = Engine::getSong()->getTimeSigModel().getNumerator(); float den = Engine::getSong()->getTimeSigModel().getDenominator(); - length = DefaultTicksPerBar * (nom / den); + changeLength(DefaultTicksPerBar * (nom / den)); } - changeLength(length); - setStartTimeOffset(0); - emit sampleChanged(); emit playbackPositionChanged(); }