diff --git a/Clip.C b/Clip.C index 7323984..491e101 100644 --- a/Clip.C +++ b/Clip.C @@ -46,7 +46,7 @@ Clip::Clip ( const char *filename ) : _peaks( this ) sf_close( in ); - _peaks.open( filename ); + _peaks.open(); } diff --git a/Peaks.C b/Peaks.C index ddf2c46..b0d6a41 100644 --- a/Peaks.C +++ b/Peaks.C @@ -179,11 +179,13 @@ peakname ( const char *filename ) } bool -Peaks::open ( const char *filename ) +Peaks::open ( void ) { + const char *filename = _clip->name(); + int fd; - make_peaks( filename, 256 ); + make_peaks( 256 ); if ( ( fd = ::open( peakname( filename ), O_RDONLY ) ) < 0 ) return false; @@ -208,24 +210,16 @@ Peaks::open ( const char *filename ) return true; } - -void -long_to_float( long *buf, int len ) -{ - for ( int i = len; i--; ) - *((float*)buf) = *buf / 32768; -} - /** returns false if peak file for /filename/ is out of date */ bool -Peaks::current ( const char *filename ) +Peaks::current ( void ) const { int sfd, pfd; - if ( ( sfd = ::open( filename, O_RDONLY ) ) < 0 ) + if ( ( sfd = ::open( _clip->name(), O_RDONLY ) ) < 0 ) return true; - if ( ( pfd = ::open( peakname( filename ), O_RDONLY ) ) < 0 ) + if ( ( pfd = ::open( peakname( _clip->name() ), O_RDONLY ) ) < 0 ) return false; struct stat sst, pst; @@ -242,9 +236,11 @@ Peaks::current ( const char *filename ) /** build peaks file for /filename/ if necessary */ bool -Peaks::make_peaks ( const char *filename, int chunksize ) +Peaks::make_peaks ( int chunksize ) { - if ( current( filename ) ) + const char *filename = _clip->name(); + + if ( current() ) return true; if ( ! _clip->open() ) @@ -272,4 +268,6 @@ Peaks::make_peaks ( const char *filename, int chunksize ) _clip->close(); fclose( fp ); + + return true; } diff --git a/Peaks.H b/Peaks.H index b44e3c9..42e030d 100644 --- a/Peaks.H +++ b/Peaks.H @@ -80,10 +80,10 @@ public: void downsample ( int s, int e, float *mhi, float *mlo ) const; void read ( int X, float *hi, float *lo ) const; - bool open ( const char *filename ); + bool open ( void ); - bool current ( const char *filename ); - bool make_peaks ( const char *filename, int chunksize ); + bool current ( void ) const; + bool make_peaks ( int chunksize ); Peak & operator[] ( int X ) const;