If AutomationPattern has a single tick at 0, set it's length to 1 bar.

This commit is contained in:
Veratil
2020-04-26 10:14:29 -05:00
parent 31996fee7a
commit aec0dd3b3e
2 changed files with 15 additions and 13 deletions

View File

@@ -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);
}
@@ -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();
@@ -251,10 +256,7 @@ void AutomationPattern::removeValue( const MidiTime & time )
}
generateTangents(it, 3);
if( getTrack() && getTrack()->type() == Track::HiddenAutomationTrack )
{
updateLength();
}
updateLength();
emit dataChanged();
}

View File

@@ -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.