diff --git a/include/SampleClip.h b/include/SampleClip.h index cbd3ac5d5..ea7853386 100644 --- a/include/SampleClip.h +++ b/include/SampleClip.h @@ -54,7 +54,6 @@ public: SampleClip& operator=( const SampleClip& that ) = delete; void changeLength( const TimePos & _length ) override; - void changeLengthToSampleLength(); const QString& sampleFile() const; bool hasSampleFileLoaded(const QString & filename) const; diff --git a/src/core/SampleClip.cpp b/src/core/SampleClip.cpp index 5c04287c4..11aabc2ff 100644 --- a/src/core/SampleClip.cpp +++ b/src/core/SampleClip.cpp @@ -152,12 +152,6 @@ void SampleClip::changeLength( const TimePos & _length ) Clip::changeLength(std::max(static_cast(_length), 1)); } -void SampleClip::changeLengthToSampleLength() -{ - int length = m_sample.sampleSize() / Engine::framesPerTick(); - changeLength(length); -} - const QString& SampleClip::sampleFile() const @@ -261,6 +255,14 @@ void SampleClip::setIsPlaying(bool isPlaying) void SampleClip::updateLength() { + // If the clip has already been manually resized, don't automatically resize it. + // Unless we are in a pattern, where you can't resize stuff manually + if (getAutoResize() || !getResizable()) + { + changeLength(sampleLength()); + setStartTimeOffset(0); + } + emit sampleChanged(); Engine::getSong()->setModified(); diff --git a/src/gui/clips/SampleClipView.cpp b/src/gui/clips/SampleClipView.cpp index b281e5304..df3726cbf 100644 --- a/src/gui/clips/SampleClipView.cpp +++ b/src/gui/clips/SampleClipView.cpp @@ -192,11 +192,7 @@ void SampleClipView::mouseDoubleClickEvent( QMouseEvent * ) if (selectedAudioFile.isEmpty()) { return; } - if (m_clip->hasSampleFileLoaded(selectedAudioFile)) - { - m_clip->changeLengthToSampleLength(); - } - else + if (!m_clip->hasSampleFileLoaded(selectedAudioFile)) { auto sampleBuffer = SampleLoader::createBufferFromFile(selectedAudioFile); if (sampleBuffer != SampleBuffer::emptyBuffer()) @@ -204,6 +200,7 @@ void SampleClipView::mouseDoubleClickEvent( QMouseEvent * ) m_clip->setSampleBuffer(sampleBuffer); } } + m_clip->updateLength(); }