Don't waste time deinterleaving peaks.

This commit is contained in:
Jonathan Moore Liles 2008-04-17 11:12:22 -05:00
parent 9cbc39addd
commit 1b5459fe2b
4 changed files with 23 additions and 19 deletions

View File

@ -77,11 +77,13 @@ Audio_File::read_peaks( float fpp, nframes_t start, nframes_t end, int *peaks, P
*pbuf = new Peak[ *peaks * *channels ]; *pbuf = new Peak[ *peaks * *channels ];
/* deintereave peaks */ memcpy( *pbuf, pk.peakbuf(), *peaks * *channels * sizeof( Peak ) );
int k = 0;
for ( int i = 0; i < *channels; i++ ) /* /\* deintereave peaks *\/ */
for ( int j = i; j < *peaks * *channels; j += *channels ) /* int k = 0; */
(*pbuf)[ k++ ] = pk.peakbuf()[ j ]; /* 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

@ -626,16 +626,18 @@ Region::draw ( void )
int ch = (h() - Fl::box_dh( box() )) / channels; int ch = (h() - Fl::box_dh( box() )) / channels;
/* scale it */
for ( int j = peaks * channels; j--; )
{
pbuf[ j ].min *= _scale;
pbuf[ j ].max *= _scale;
}
for ( int i = 0; i < channels; ++i ) for ( int i = 0; i < channels; ++i )
{ {
Peak *pb = pbuf + (peaks * i); // Peak *pb = pbuf + (peaks * i);
/* scale it */
for ( int j = peaks; j--; )
{
pb[ j ].min *= _scale;
pb[ j ].max *= _scale;
}
/* int fw = timeline->ts_to_x( fade.length ); */ /* int fw = timeline->ts_to_x( fade.length ); */
@ -651,7 +653,7 @@ Region::draw ( void )
(y() + Fl::box_dy( box() )) + (i * ch), (y() + Fl::box_dy( box() )) + (i * ch),
W, W,
ch, ch,
pb, peaks, pbuf + i, peaks, channels,
selected() ? fl_invert_color( _color ) : _color ); selected() ? fl_invert_color( _color ) : _color );
} }

View File

@ -43,7 +43,7 @@ bool Waveform::logarithmic = true;
/** draw a portion of /clip/'s waveform. coordinates are the portion to draw */ /** draw a portion of /clip/'s waveform. coordinates are the portion to draw */
void void
Waveform::draw ( int X, int Y, int W, int H, Waveform::draw ( int X, int Y, int W, int H,
Peak *pbuf, int peaks, Peak *pbuf, int peaks, int skip,
Fl_Color color ) Fl_Color color )
{ {
fl_push_clip( X, Y, W, H ); fl_push_clip( X, Y, W, H );
@ -62,7 +62,7 @@ Waveform::draw ( int X, int Y, int W, int H,
if ( Waveform::fill ) if ( Waveform::fill )
{ {
j = start; j = start;
for ( int x = X; x < X + W; ++x, ++j ) for ( int x = X; x < X + W; ++x, j += skip )
{ {
const Peak p = pbuf[ j ]; const Peak p = pbuf[ j ];
@ -106,7 +106,7 @@ Waveform::draw ( int X, int Y, int W, int H,
fl_begin_line(); fl_begin_line();
j = start; j = start;
for ( int x = X; x < X + W; ++x, ++j ) for ( int x = X; x < X + W; ++x, j += skip )
{ {
const Peak p = pbuf[ j ]; const Peak p = pbuf[ j ];
@ -118,7 +118,7 @@ Waveform::draw ( int X, int Y, int W, int H,
fl_begin_line(); fl_begin_line();
j = start; j = start;
for ( int x = X; x < X + W; ++x, ++j ) for ( int x = X; x < X + W; ++x, j += skip )
{ {
const Peak p = pbuf[ j ]; const Peak p = pbuf[ j ];

View File

@ -36,7 +36,7 @@ public:
static bool logarithmic; static bool logarithmic;
static void draw ( int X, int Y, int W, int H, static void draw ( int X, int Y, int W, int H,
Peak *pbuf, int peaks, Peak *pbuf, int peaks, int skip,
Fl_Color color ); Fl_Color color );
}; };