Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/core/AutomationClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ void AutomationClip::updateLength()
// checks if it has been resized from either direction.
if (getAutoResize())
{
if ( m_autoTrack != nullptr && m_autoTrack->trackContainer() == Engine::patternStore() )
{
// If inside a pattern, the clip is always the lenght of it.
changeLength(TimePos::ticksPerBar() * Engine::patternStore()->lengthOfPattern(m_autoTrack->getClipNum(this)));
return;
}
// Using 1 bar as the min length for an un-resized clip.
// This does not prevent the user from resizing the clip to be less than a bar later on.
changeLength(std::max(TimePos::ticksPerBar(), static_cast<tick_t>(timeMapLength())));
Expand Down
2 changes: 1 addition & 1 deletion src/core/PatternStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ bar_t PatternStore::lengthOfPattern(int pattern) const
for (Track * t : tl)
{
// Don't create Clips here if they don't exist
if (pattern < t->numOfClips())
if (pattern < t->numOfClips() && t->type() == Track::Type::Instrument)
{
maxLength = std::max(maxLength, t->getClip(pattern)->length());
}
Expand Down
6 changes: 6 additions & 0 deletions src/core/SampleClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <QDomElement>
#include <QFileInfo>

#include "PatternStore.h"
#include "PathUtil.h"
#include "SampleClipView.h"
#include "SampleTrack.h"
Expand Down Expand Up @@ -227,6 +228,11 @@ void SampleClip::updateLength()
// If the clip has already been manually resized, don't automatically resize it.
if (getAutoResize())
{
if (getTrack()->trackContainer() == Engine::patternStore())
{
changeLength(TimePos::ticksPerBar() * Engine::patternStore()->lengthOfPattern(getTrack()->getClipNum(this)));
return;
}
changeLength(sampleLength());
setStartTimeOffset(0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/clips/AutomationClipView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ void AutomationClipView::paintEvent( QPaintEvent * )
// pixels per bar
const float ppb = fixedClips() ?
( parentWidget()->width() - 2 * BORDER_WIDTH )
/ (float) m_clip->timeMapLength().getBar() :
/ (float) m_clip->length().getBar() :
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LostRobotMusic has made a PR that caches track lengths. #6741
I hope I'll be reviewing that soon.

@LostRobotMusic any input regarding this?

pixelsPerBar();

const auto min = m_clip->firstObject()->minValue<float>();
Expand Down
9 changes: 6 additions & 3 deletions src/gui/editors/PatternEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,14 @@ void PatternEditor::updateMaxSteps()
m_maxClipLength = 0;
for (const auto& track : tl)
{
if (track->type() == Track::Type::Instrument)
auto clip = track->getClip(m_ps->currentPattern());
if (track->type() == Track::Type::Automation || track->type() == Track::Type::Sample)
{
auto mClip = static_cast<MidiClip*>(track->getClip(m_ps->currentPattern()));
m_maxClipLength = std::max(m_maxClipLength, static_cast<tick_t>(mClip->length()));
// The length of automation and sample clips is updated here.
// "Why here ?" will you ask. The answer is: Because.
clip->updateLength();
}
m_maxClipLength = std::max(m_maxClipLength, static_cast<tick_t>(clip->length()));
}
updatePixelsPerBar();
}
Expand Down
2 changes: 1 addition & 1 deletion src/tracks/MidiClip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void MidiClip::updateLength()
// If the clip hasn't already been manually resized, automatically resize it.
if (getAutoResize())
{
if (m_clipType == Type::BeatClip)
if (m_instrumentTrack->trackContainer()->type() == TrackContainer::Type::Pattern)
{
changeLength(beatClipLength());
updatePatternTrack();
Expand Down
Loading