Improve peak reading efficiency.

This commit is contained in:
Jonathan Moore Liles 2008-04-17 11:30:20 -05:00
parent 1b5459fe2b
commit e86123de78
3 changed files with 10 additions and 17 deletions

View File

@ -75,15 +75,7 @@ Audio_File::read_peaks( float fpp, nframes_t start, nframes_t end, int *peaks, P
*channels = this->channels();
*pbuf = new Peak[ *peaks * *channels ];
memcpy( *pbuf, pk.peakbuf(), *peaks * *channels * sizeof( Peak ) );
/* /\* deintereave peaks *\/ */
/* int k = 0; */
/* for ( int i = 0; i < *channels; i++ ) */
/* for ( int j = i; j < *peaks * *channels; j += *channels ) */
/* (*pbuf)[ k++ ] = pk.peakbuf()[ j ]; */
*pbuf = pk.peakbuf();
return true;
}

View File

@ -129,12 +129,16 @@ Peaks::read_peakfile_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize
p.min = 0;
p.max = 0;
for ( int k = j; k < len * channels; k += channels )
const Peak *pb = pbuf + j;
for ( int k = len * channels; k--; pb += channels )
{
if ( pbuf[ k ].max > p.max )
p.max = pbuf[ k ].max;
if ( pbuf[ k ].min < p.min )
p.min = pbuf[ k ].min;
const Peak pp = *pb;
if ( pp.max > p.max )
p.max = pp.max;
if ( pp.min < p.min )
p.min = pp.min;
}
}

View File

@ -656,9 +656,6 @@ Region::draw ( void )
pbuf + i, peaks, channels,
selected() ? fl_invert_color( _color ) : _color );
}
delete[] pbuf;
}
timeline->draw_measure_lines( rx, Y, rw, H, _box_color );