Browse Source

Optimize waveform drawing some.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
ed9a1aaf5b
2 changed files with 13 additions and 21 deletions
  1. +7
    -9
      Timeline/Peaks.C
  2. +6
    -12
      Timeline/Waveform.C

+ 7
- 9
Timeline/Peaks.C View File

@@ -124,21 +124,19 @@ Peaks::read_peakfile_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize
/* get the peak for each channel */
for ( int j = 0; j < channels; ++j )
{
Peak &p = pk[ j ];
Peak *p = &pk[ j ];

p.min = 0;
p.max = 0;
p->min = 0;
p->max = 0;

const Peak *pb = pbuf + j;

for ( int k = len * channels; k--; pb += channels )
{
const Peak pp = *pb;

if ( pp.max > p.max )
p.max = pp.max;
if ( pp.min < p.min )
p.min = pp.min;
if ( pb->max > p->max )
p->max = pb->max;
if ( pb->min < p->min )
p->min = pb->min;
}

}


+ 6
- 12
Timeline/Waveform.C View File

@@ -82,8 +82,8 @@ Waveform::draw ( int X, int Y, int W, int H,
else
fl_color( color );

const int ty = mid + (halfheight * p.min);
const int by = mid + (halfheight * p.max );
const int ty = mid + ( halfheight * p.min );
const int by = mid + ( halfheight * p.max );
fl_line( x, ty, x, by );

/* if ( outline ) */
@@ -96,6 +96,8 @@ Waveform::draw ( int X, int Y, int W, int H,
}
}

const int ty = Y + halfheight;

if ( Waveform::outline )
{

@@ -107,11 +109,7 @@ Waveform::draw ( int X, int Y, int W, int H,

j = start;
for ( int x = X; x < X + W; ++x, j += skip )
{
const Peak p = pbuf[ j ];

fl_vertex( x, Y + (H / 2) + ((float)H / 2 * p.min ));
}
fl_vertex( x, ty + ( halfheight * pbuf[ j ].min ) );

fl_end_line();

@@ -119,11 +117,7 @@ Waveform::draw ( int X, int Y, int W, int H,

j = start;
for ( int x = X; x < X + W; ++x, j += skip )
{
const Peak p = pbuf[ j ];

fl_vertex( x, Y + (H / 2) + ((float)H / 2 * p.max ));
}
fl_vertex( x, ty + ( halfheight * pbuf[ j ].max ) );

fl_end_line();



Loading…
Cancel
Save