From eb81e6b9d6b5471cda9eb1143f60d57890d5585e Mon Sep 17 00:00:00 2001 From: Vesa Date: Thu, 6 Mar 2014 10:37:27 +0200 Subject: [PATCH] AutomationPattern: fix values after last value --- src/core/AutomationPattern.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/core/AutomationPattern.cpp b/src/core/AutomationPattern.cpp index 8f928a8d1..adebac163 100644 --- a/src/core/AutomationPattern.cpp +++ b/src/core/AutomationPattern.cpp @@ -163,17 +163,10 @@ const AutomatableModel * AutomationPattern::firstObject() const -//TODO: Improve this MidiTime AutomationPattern::length() const { - tick_t max_length = 0; - - for( timeMap::const_iterator it = m_timeMap.begin(); - it != m_timeMap.end(); ++it ) - { - max_length = qMax( max_length, it.key() ); - } - return MidiTime( qMax( MidiTime( max_length ).getTact() + 1, 1 ), 0 ); + timeMap::const_iterator it = m_timeMap.end(); + return MidiTime( qMax( MidiTime( (it-1).key() ).getTact() + 1, 1 ), 0 ); } @@ -313,6 +306,10 @@ float AutomationPattern::valueAt( const MidiTime & _time ) const { return 0; } + if( v == m_timeMap.end() ) + { + return (v-1).value(); + } return valueAt( v-1, _time - (v-1).key() ); }