Avoid re-reading peaks unnecessarily when drawing loops.

This commit is contained in:
Jonathan Moore Liles 2008-07-01 23:10:47 -05:00
parent dfaf04645c
commit 98613d4d61
1 changed files with 21 additions and 6 deletions

View File

@ -492,6 +492,8 @@ Audio_Region::draw ( void )
int xo = 0; int xo = 0;
nframes_t ostart = 0, oend = 0;
do { do {
int channels; int channels;
@ -538,17 +540,30 @@ Audio_Region::draw ( void )
const int total_peaks_needed = min( timeline->ts_to_x( _clip->length() - start ), rw ); const int total_peaks_needed = min( timeline->ts_to_x( _clip->length() - start ), rw );
const nframes_t end = start + timeline->x_to_ts( loop_peaks_needed ); const nframes_t end = start + timeline->x_to_ts( loop_peaks_needed );
if ( _clip->read_peaks( timeline->fpp(), if ( start != ostart || end != oend )
start, {
end, if ( _clip->read_peaks( timeline->fpp(),
&peaks, &pbuf, &channels ) && start,
peaks ) end,
&peaks, &pbuf, &channels ) )
{
Waveform::scale( pbuf, peaks * channels, _scale );
ostart = start;
oend = end;
}
}
else
{
// DMESSAGE( "using cached peaks" );
}
if ( peaks )
{ {
assert( pbuf ); assert( pbuf );
int ch = (h() - Fl::box_dh( box() )) / channels; int ch = (h() - Fl::box_dh( box() )) / channels;
Waveform::scale( pbuf, peaks * channels, _scale );
for ( int i = 0; i < channels; ++i ) for ( int i = 0; i < channels; ++i )
{ {