| @@ -331,27 +331,19 @@ Peaks::make_peaks ( int chunksize ) | |||||
| /** return normalization factor for range of samples from /start/ to | /** return normalization factor for range of samples from /start/ to | ||||
| /end/ (uses known peak data if possible */ | /end/ (uses known peak data if possible */ | ||||
| /* float */ | |||||
| /* Peaks::normalization_factor( float fpp, nframes_t start, nframes_t end ) const */ | |||||
| /* { */ | |||||
| /* float s; */ | |||||
| /* // fill_buffer( fpp, start, end ); */ | |||||
| /* /\* if ( end - start < _peaks->chunksize * 4 ) *\/ */ | |||||
| /* /\* fill_buffer( _clip->length() / 4, start, end ); *\/ */ | |||||
| /* /\* else *\/ */ | |||||
| /* /\* fill_buffer( _clip->length(), start, end ); *\/ */ | |||||
| /* Peak p = peak( start, end ); */ | |||||
| float | |||||
| //Peaks::normalization_factor( float fpp, nframes_t start, nframes_t end ) const | |||||
| Peak::normalization_factor( void ) const | |||||
| { | |||||
| float s; | |||||
| /* s = 1.0f / fabs( p.max ); */ | |||||
| s = 1.0f / fabs( this->max ); | |||||
| /* if ( s * p.min < -1.0 ) */ | |||||
| /* s = 1.0f / fabs( p.min ); */ | |||||
| if ( s * this->min < -1.0 ) | |||||
| s = 1.0f / fabs( this->min ); | |||||
| /* return s; */ | |||||
| /* } */ | |||||
| return s; | |||||
| } | |||||
| @@ -26,6 +26,9 @@ | |||||
| struct Peak { | struct Peak { | ||||
| float min; | float min; | ||||
| float max; | float max; | ||||
| float normalization_factor ( void ) const; | |||||
| }; | }; | ||||
| class Audio_File; | class Audio_File; | ||||
| @@ -94,7 +97,7 @@ public: | |||||
| 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; | ||||
| bool open ( void ); | 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 current ( void ) const; | ||||
| bool make_peaks ( int chunksize ); | bool make_peaks ( int chunksize ); | ||||
| @@ -742,8 +742,13 @@ Region::normalize ( void ) | |||||
| printf( "normalize: start=%lu end=%lu\n", _r->start, _r->end ); | printf( "normalize: start=%lu end=%lu\n", _r->start, _r->end ); | ||||
| /* FIXME: figure out a way to do this via the peak server */ | /* 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(); | |||||
| } | } | ||||