This commit is contained in:
Jonathan Moore Liles 2008-04-17 10:19:04 -05:00
parent 3b40b8a093
commit 55b2907aec
3 changed files with 22 additions and 9 deletions

View File

@ -46,7 +46,7 @@ Peaks::peakbuffer Peaks::_peakbuf;
/** Prepare a buffer of peaks from /s/ to /e/ for reading. Must be
* called before any calls to operator[] */
int
Peaks::fill_buffer ( float fpp, int s, int e ) const
Peaks::fill_buffer ( float fpp, nframes_t s, nframes_t e ) const
{
_fpp = fpp;
@ -208,7 +208,7 @@ Peaks::read_source_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize )
}
int
Peaks::read_peaks ( int s, int e, int npeaks, int chunksize ) const
Peaks::read_peaks ( nframes_t s, nframes_t e, int npeaks, int chunksize ) const
{
printf( "reading peaks %d @ %d\n", npeaks, chunksize );

View File

@ -62,7 +62,7 @@ class Peaks
mutable float _fpp;
int read_peaks ( int s, int e, int npeaks, int chunksize ) const;
int read_peaks ( nframes_t s, nframes_t e, int npeaks, int chunksize ) const;
int read_source_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize ) const;
int read_source_peaks ( Peak *peaks, int npeaks, int chunksize ) const;
int read_peakfile_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize ) const;
@ -89,7 +89,7 @@ public:
Peak *peakbuf ( void ) const { return Peaks::_peakbuf.buf->data; }
void clip ( Audio_File *c ) { _clip = c; }
int fill_buffer ( float fpp, int s, int e ) const;
int fill_buffer ( float fpp, nframes_t s, nframes_t e ) const;
void downsample ( Peak *peaks, int s, int e, float *mhi, float *mlo ) const;
void read ( int X, float *hi, float *lo ) const;

View File

@ -569,6 +569,12 @@ Region::draw ( int X, int Y, int W, int H )
if ( ! shown() )
return;
/* intersect clip with region */
/* FIXME: wouldn't it be better to get rid of the useless X Y W H arguments and
just intersect with the real clipping region? */
fl_clip_box( x(), y(), w(), h(), X, Y, W, H );
if ( ! ( W > 0 && H > 0 ) )
/* WTF? */
return;
@ -596,7 +602,7 @@ Region::draw ( int X, int Y, int W, int H )
{
offset = timeline->x_to_ts( OX - ox );
rw = timeline->ts_to_x( (_r->end - _r->start) - offset );
rw -= OX - ox;
}
rw = min( rw, _track->w() );
@ -614,13 +620,14 @@ Region::draw ( int X, int Y, int W, int H )
// const nframes_t start = _r->start + offset + timeline->x_to_ts( X - rx );
nframes_t start = _r->start + offset;
/* if ( X - rx > 0 ) */
/* start += timeline->x_to_ts( X - rx ); */
/* compensate for ??? */
if ( X - rx > 0 )
start += timeline->x_to_ts( X - rx );
printf( "offset=%lu start=%lu\n", offset, start, X, rx );
if ( _clip->read_peaks( timeline->fpp(),
start,
start + timeline->x_to_ts( W ),
start + timeline->x_to_ts( min( rw, W ) ),
&peaks, &pbuf, &channels ) )
{
@ -653,7 +660,13 @@ Region::draw ( int X, int Y, int W, int H )
/* pb[ j ].max *= g; */
/* } */
Waveform::draw( max( X, rx ), (y() + Fl::box_dy( box() )) + (i * ch), min( W, rw ), ch,
const int nx = max( X, rx );
const int nw = min( nx + W, nx + rw ) - nx;
Waveform::draw( nx,
(y() + Fl::box_dy( box() )) + (i * ch),
nw,
ch,
pb, peaks,
selected() ? fl_invert_color( _color ) : _color );
}