More tweaking.

This commit is contained in:
Jonathan Moore Liles 2008-02-16 18:35:53 -06:00
parent 8905484cb1
commit 4129714315
5 changed files with 40 additions and 14 deletions

12
Peaks.C
View File

@ -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 );

View File

@ -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;

View File

@ -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 );

View File

@ -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;

4
main.C
View File

@ -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();