@@ -46,7 +46,7 @@ Peaks::peakbuffer Peaks::_peakbuf; | |||||
/** Prepare a buffer of peaks from /s/ to /e/ for reading. Must be | /** Prepare a buffer of peaks from /s/ to /e/ for reading. Must be | ||||
* called before any calls to operator[] */ | * called before any calls to operator[] */ | ||||
int | 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; | _fpp = fpp; | ||||
@@ -208,7 +208,7 @@ Peaks::read_source_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize ) | |||||
} | } | ||||
int | 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 ); | printf( "reading peaks %d @ %d\n", npeaks, chunksize ); | ||||
@@ -62,7 +62,7 @@ class Peaks | |||||
mutable float _fpp; | 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, nframes_t s, int npeaks, int chunksize ) const; | ||||
int read_source_peaks ( Peak *peaks, 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; | 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; } | Peak *peakbuf ( void ) const { return Peaks::_peakbuf.buf->data; } | ||||
void clip ( Audio_File *c ) { _clip = c; } | 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 downsample ( Peak *peaks, int s, int e, float *mhi, float *mlo ) const; | ||||
void read ( int X, float *hi, float *lo ) const; | void read ( int X, float *hi, float *lo ) const; | ||||
@@ -569,6 +569,12 @@ Region::draw ( int X, int Y, int W, int H ) | |||||
if ( ! shown() ) | if ( ! shown() ) | ||||
return; | 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 ) ) | if ( ! ( W > 0 && H > 0 ) ) | ||||
/* WTF? */ | /* WTF? */ | ||||
return; | return; | ||||
@@ -596,7 +602,7 @@ Region::draw ( int X, int Y, int W, int H ) | |||||
{ | { | ||||
offset = timeline->x_to_ts( OX - ox ); | 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() ); | 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 ); | // const nframes_t start = _r->start + offset + timeline->x_to_ts( X - rx ); | ||||
nframes_t start = _r->start + offset; | 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 ); | printf( "offset=%lu start=%lu\n", offset, start, X, rx ); | ||||
if ( _clip->read_peaks( timeline->fpp(), | if ( _clip->read_peaks( timeline->fpp(), | ||||
start, | start, | ||||
start + timeline->x_to_ts( W ), | |||||
start + timeline->x_to_ts( min( rw, W ) ), | |||||
&peaks, &pbuf, &channels ) ) | &peaks, &pbuf, &channels ) ) | ||||
{ | { | ||||
@@ -653,7 +660,13 @@ Region::draw ( int X, int Y, int W, int H ) | |||||
/* pb[ j ].max *= g; */ | /* 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, | pb, peaks, | ||||
selected() ? fl_invert_color( _color ) : _color ); | selected() ? fl_invert_color( _color ) : _color ); | ||||
} | } | ||||