diff --git a/Peaks.C b/Peaks.C index 0b7a4a7..cb1e889 100644 --- a/Peaks.C +++ b/Peaks.C @@ -70,8 +70,16 @@ Peaks::operator[] ( int X ) const /* Is there a better way to return this? */ static Peak p; - int start = X * timeline.fpp; - int end = (X + 1) * timeline.fpp; + if ( timeline.fpp < _peaks->chunksize ) + { + printf( "we need to a smaller chunksize! examine the source!\n" ); + } + + int start = timeline.x_to_ts( X ) / _peaks->chunksize; + int end = timeline.x_to_ts( X + 1 ) / _peaks->chunksize; + +/* int start = X * timeline.fpp; */ +/* int end = (X + 1) * timeline.fpp; */ downsample( start, end, &p.max, &p.min ); diff --git a/Region.C b/Region.C index 1cb52df..0b70100 100644 --- a/Region.C +++ b/Region.C @@ -71,14 +71,25 @@ Region::trim ( enum trim_e t, int X ) case LEFT: { int d = X - x(); - _start += d; +// _start += d; + if ( d < 0 && + _start < timeline.x_to_ts( x() + d ) ) + { + _start = 0; + break; + } + else + _start = timeline.x_to_ts( x() + d ); +// _start += timeline.x_to_ts( d ); + resize( x() + d, y(), w() - d, h() ); break; } case RIGHT: { int d = (x() + w()) - X; - _end = _start + w() - d; +// _end = _start + w() - d; + _end = timeline.x_to_ts( _start + w() - d ); resize( x(), y(), w() - d, h() ); break; } @@ -204,6 +215,8 @@ Region::handle ( int m ) timeline.scroll->position( pos, timeline.scroll->yposition() ); } + _offset = timeline.x_to_ts( x() ); + return 1; default: return 0; diff --git a/Region.H b/Region.H index 895eb56..3874a0c 100644 --- a/Region.H +++ b/Region.H @@ -28,6 +28,8 @@ class Region : public Waveform Track *_track; + nframes_t _offset; + enum trim_e { NO, LEFT, RIGHT }; void trim ( enum trim_e t, int X ); diff --git a/Waveform.C b/Waveform.C index b4a4f5d..78a8cf4 100644 --- a/Waveform.C +++ b/Waveform.C @@ -77,12 +77,13 @@ Waveform::draw ( int X, int Y, int W, int H ) // int start = (_start + (X - x())) * 2; - j = 0; - for ( int x = X; x < X + W; ++x ) - { + int start = timeline.ts_to_x( _start ) + (X - x() ); + j = start; + for ( int x = X; x < X + W; ++x, ++j ) + { // read_peaks( x, &hi, &lo ); - Peak p = (*_clip->peaks())[ x ]; + Peak p = (*_clip->peaks())[ j ]; int mid = Y + (H / 2); @@ -107,9 +108,10 @@ Waveform::draw ( int X, int Y, int W, int H ) fl_begin_line(); - for ( int x = X; x < X + W; ++x ) + j = start; + for ( int x = X; x < X + W; ++x, ++j ) { - Peak p = (*_clip->peaks())[ x ]; + Peak p = (*_clip->peaks())[ j ]; p.min *= _scale; @@ -120,9 +122,10 @@ Waveform::draw ( int X, int Y, int W, int H ) fl_begin_line(); - for ( int x = X; x < X + W; ++x ) + j = start; + for ( int x = X; x < X + W; ++x, ++j ) { - Peak p = (*_clip->peaks())[ x ]; + Peak p = (*_clip->peaks())[ j ]; p.max *= _scale; diff --git a/main.C b/main.C index 4acd6e9..d458a48 100644 --- a/main.C +++ b/main.C @@ -122,8 +122,8 @@ main ( int argc, char **argv ) Fl_Slider *zoom_slider = new Fl_Slider( 0, 0, 800, 24 ); zoom_slider->type( 1 ); zoom_slider->callback( cb_zoom, 0 ); - zoom_slider->range( 1, 256 ); - zoom_slider->value( 1 ); + zoom_slider->range( 1, 256 * 256 ); + zoom_slider->value( 256 ); main_window->end(); main_window->show();