Fix math errors in normalizer and waveform colorer.

pull/3/head
Jonathan Moore Liles 2008-03-09 18:16:51 -05:00
parent 90a5568a20
commit bb61dde7fb
2 changed files with 71 additions and 71 deletions

View File

@ -303,10 +303,10 @@ Peaks::normalization_factor( float fpp, nframes_t start, nframes_t end ) const
Peak p = peak( start, end );
s = fabs( 1.0f / p.max );
s = 1.0f / fabs( p.max );
if ( s * p.min < -1.0 )
s = 1 / fabs( p.max );
s = 1.0f / fabs( p.min );
return s;
}

View File

@ -39,9 +39,9 @@ bool Waveform::vary_color = true;
* outlined, filled, polygonal, rectified. */
/** draw a portion of /clip/'s waveform. coordinates are the portion to draw */
void
Waveform::draw ( int ox, int X, int Y, int W, int H, Audio_File *_clip, int channel, float fpp, nframes_t _start, nframes_t _end, float _scale, Fl_Color color )
{
void
Waveform::draw ( int ox, int X, int Y, int W, int H, Audio_File *_clip, int channel, float fpp, nframes_t _start, nframes_t _end, float _scale, Fl_Color color )
{
fl_push_clip( X, Y, W, H );
int j;
@ -70,14 +70,14 @@ bool Waveform::vary_color = true;
const float diff = fabs( p.max - p.min );
if ( diff > 2.0f )
fl_color( FL_RED );
else
if ( Waveform::vary_color )
fl_color( fl_color_average( FL_WHITE, color, min( 1.0f, diff ) ) );
fl_color( fl_color_average( FL_WHITE, color, diff / 2.0f ) );
else
fl_color( color );
if ( diff > 1.0f )
fl_color( FL_RED );
const int ty = mid + (halfheight * p.min);
const int by = mid + (halfheight * p.max );
fl_line( x, ty, x, by );
@ -133,4 +133,4 @@ bool Waveform::vary_color = true;
}
fl_pop_clip();
}
}