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(); *channels = this->channels();
*pbuf = new Peak[ *peaks * *channels ]; *pbuf = pk.peakbuf();
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 ]; */
return true; 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.min = 0;
p.max = 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 ) const Peak pp = *pb;
p.max = pbuf[ k ].max;
if ( pbuf[ k ].min < p.min ) if ( pp.max > p.max )
p.min = pbuf[ k ].min; 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, pbuf + i, peaks, channels,
selected() ? fl_invert_color( _color ) : _color ); selected() ? fl_invert_color( _color ) : _color );
} }
delete[] pbuf;
} }
timeline->draw_measure_lines( rx, Y, rw, H, _box_color ); timeline->draw_measure_lines( rx, Y, rw, H, _box_color );