Skip to content

Commit

Permalink
If AutomationPattern has a single tick at 0, set it's length to 1 bar.
Browse files Browse the repository at this point in the history
  • Loading branch information
Veratil committed Apr 26, 2020
1 parent 31996fe commit aec0dd3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
26 changes: 14 additions & 12 deletions src/core/AutomationPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,19 @@ const AutomationPattern::objectVector& AutomationPattern::objects() const

MidiTime AutomationPattern::timeMapLength() const
{
if( m_timeMap.isEmpty() ) return 0;
MidiTime one_bar = MidiTime(1, 0);
if (m_timeMap.isEmpty())
{
return one_bar;
}
timeMap::const_iterator it = m_timeMap.end();
return MidiTime( MidiTime( (it-1).key() ).nextFullBar(), 0 );
tick_t last_tick = static_cast<tick_t>((it-1).key());
bar_t last_bar = qMax(0, MidiTime(last_tick).nextFullBar() - 1);
if (last_bar == 0 && last_tick == 0)
{
return one_bar;
}
return MidiTime(last_bar, last_tick);
}


Expand Down Expand Up @@ -223,12 +233,7 @@ MidiTime AutomationPattern::putValue( const MidiTime & time,
}
generateTangents( it, 3 );

// we need to maximize our length in case we're part of a hidden
// automation track as the user can't resize this pattern
if( getTrack() && getTrack()->type() == Track::HiddenAutomationTrack )
{
updateLength();
}
updateLength();

emit dataChanged();

Expand All @@ -251,10 +256,7 @@ void AutomationPattern::removeValue( const MidiTime & time )
}
generateTangents(it, 3);

if( getTrack() && getTrack()->type() == Track::HiddenAutomationTrack )
{
updateLength();
}
updateLength();

emit dataChanged();
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void TrackContentObject::movePosition( const MidiTime & pos )

/*! \brief Change the length of this TrackContentObject
*
* If the track content object's length has chaanged, update it. We
* If the track content object's length has changed, update it. We
* also add a journal entry for undo and update the display.
*
* \param _length The new length of the track content object.
Expand Down

0 comments on commit aec0dd3

Please sign in to comment.