Make region normalization possible again.

This commit is contained in:
Jonathan Moore Liles 2008-05-01 02:13:58 -05:00
parent aba6910629
commit 9814d34ac6
3 changed files with 20 additions and 20 deletions

View File

@ -331,27 +331,19 @@ Peaks::make_peaks ( int chunksize )
/** return normalization factor for range of samples from /start/ to
/end/ (uses known peak data if possible */
/* float */
/* Peaks::normalization_factor( float fpp, nframes_t start, nframes_t end ) const */
/* { */
/* float s; */
float
//Peaks::normalization_factor( float fpp, nframes_t start, nframes_t end ) const
Peak::normalization_factor( void ) const
{
float s;
/* // fill_buffer( fpp, start, end ); */
s = 1.0f / fabs( this->max );
/* /\* if ( end - start < _peaks->chunksize * 4 ) *\/ */
/* /\* fill_buffer( _clip->length() / 4, start, end ); *\/ */
/* /\* else *\/ */
/* /\* fill_buffer( _clip->length(), start, end ); *\/ */
if ( s * this->min < -1.0 )
s = 1.0f / fabs( this->min );
/* Peak p = peak( start, end ); */
/* s = 1.0f / fabs( p.max ); */
/* if ( s * p.min < -1.0 ) */
/* s = 1.0f / fabs( p.min ); */
/* return s; */
/* } */
return s;
}

View File

@ -26,6 +26,9 @@
struct Peak {
float min;
float max;
float normalization_factor ( void ) const;
};
class Audio_File;
@ -94,7 +97,7 @@ public:
void downsample ( Peak *peaks, int s, int e, float *mhi, float *mlo ) const;
void read ( int X, float *hi, float *lo ) const;
bool open ( void );
float normalization_factor( float fpp, nframes_t start, nframes_t end ) const;
// float normalization_factor( float fpp, nframes_t start, nframes_t end ) ;
bool current ( void ) const;
bool make_peaks ( int chunksize );

View File

@ -742,8 +742,13 @@ Region::normalize ( void )
printf( "normalize: start=%lu end=%lu\n", _r->start, _r->end );
/* FIXME: figure out a way to do this via the peak server */
/* _scale = _clip->peaks( 0 )->normalization_factor( timeline->fpp(), _r->start, _r->end ); */
int peaks, channels;
Peak *pbuf;
if ( _clip->read_peaks( length(), _r->start, _r->end, &peaks, &pbuf, &channels ) &&
peaks )
_scale = pbuf->normalization_factor();
}