Don't fail in render_tempomap on the first beat of the first bar.

This commit is contained in:
Jonathan Moore Liles 2008-05-16 18:44:08 -05:00
parent f42b12d323
commit 65b6d544ad
1 changed files with 10 additions and 7 deletions

View File

@ -416,6 +416,9 @@ Timeline::render_tempomap( nframes_t start, nframes_t length, measure_line_callb
/* FIXME: don't we need to sort so that Time_Points always preceed Tempo_Points? */ /* FIXME: don't we need to sort so that Time_Points always preceed Tempo_Points? */
if ( ! _tempomap.size() )
return pos;
for ( list <const Sequence_Widget *>::const_iterator i = _tempomap.begin(); for ( list <const Sequence_Widget *>::const_iterator i = _tempomap.begin();
i != _tempomap.end(); ++i ) i != _tempomap.end(); ++i )
{ {
@ -448,7 +451,6 @@ Timeline::render_tempomap( nframes_t start, nframes_t length, measure_line_callb
next = (*n)->start() - ( ( (*n)->start() - (*i)->start() ) % frames_per_beat ); next = (*n)->start() - ( ( (*n)->start() - (*i)->start() ) % frames_per_beat );
} }
for ( ; f < next; ++bbt.beat, f += frames_per_beat ) for ( ; f < next; ++bbt.beat, f += frames_per_beat )
{ {
@ -465,18 +467,19 @@ Timeline::render_tempomap( nframes_t start, nframes_t length, measure_line_callb
cb( f, bbt, arg ); cb( f, bbt, arg );
} }
if ( f + frames_per_beat >= end ) /* ugliness to avoid failing out at -1 */
if ( end >= frames_per_beat )
{
if ( f >= end - frames_per_beat )
goto done;
}
else if ( f + frames_per_beat >= end )
goto done; goto done;
} }
} }
done: done:
if ( ! f )
/* no points? */
return pos;
pos.frame = f; pos.frame = f;
pos.tempo = bpm; pos.tempo = bpm;
pos.beats_per_bar = sig.beats_per_bar; pos.beats_per_bar = sig.beats_per_bar;