Finish making Peaks use Clip
This commit is contained in:
parent
bb0b511122
commit
d36804ea4e
2
Clip.C
2
Clip.C
|
@ -46,7 +46,7 @@ Clip::Clip ( const char *filename ) : _peaks( this )
|
|||
|
||||
sf_close( in );
|
||||
|
||||
_peaks.open( filename );
|
||||
_peaks.open();
|
||||
}
|
||||
|
||||
|
||||
|
|
28
Peaks.C
28
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;
|
||||
}
|
||||
|
|
6
Peaks.H
6
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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue