Browse Source

Cleanup peak code to use Clip for reading.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
f27a222e47
2 changed files with 7 additions and 22 deletions
  1. +6
    -20
      Peaks.C
  2. +1
    -2
      Peaks.H

+ 6
- 20
Peaks.C View File

@@ -79,9 +79,8 @@ Peaks::downsample ( int s, int e, float *mhi, float *mlo ) const
}


static
int
sf_read_peaks ( SNDFILE *in, Peak *peaks, int npeaks, int chunksize )
Peaks::clip_read_peaks ( Peak *peaks, int npeaks, int chunksize ) const
{
float *fbuf = new float[ chunksize ];

@@ -91,7 +90,7 @@ sf_read_peaks ( SNDFILE *in, Peak *peaks, int npeaks, int chunksize )
for ( i = 0; i < npeaks; ++i )
{
/* read in a buffer */
len = sf_read_float( in, fbuf, chunksize );
len = _clip->read( fbuf, chunksize );

Peak &p = peaks[ i ];
p.min = 0;
@@ -126,22 +125,14 @@ Peaks::read_peaks ( int s, int e, int npeaks, int chunksize ) const
peakbuf.buf = (peakdata*)realloc( peakbuf.buf, sizeof( peakdata ) + (peakbuf.size * sizeof( Peak )) );
}

memset( peakbuf.buf->data, 0, peakbuf.size * sizeof( Peak ) );

SNDFILE *in;
SF_INFO si;

memset( &si, 0, sizeof( si ) );

in = sf_open( _clip->name(), SFM_READ, &si );

sf_seek( in, s, SEEK_SET );
_clip->open();
_clip->seek( s );

peakbuf.offset = s;
peakbuf.buf->chunksize = chunksize;
peakbuf.len = sf_read_peaks( in, peakbuf.buf->data, npeaks, chunksize );
peakbuf.len = clip_read_peaks( peakbuf.buf->data, npeaks, chunksize );

sf_close( in );
_clip->close();
}


@@ -263,11 +254,6 @@ Peaks::make_peaks ( const char *filename, int chunksize )

in = sf_open( filename, SFM_READ, &si );

if ( si.channels != 1 )
abort();
if ( si.samplerate != timeline.sample_rate )
abort();

FILE *fp = fopen( peakname( filename ), "w" );

if ( fp == NULL )


+ 1
- 2
Peaks.H View File

@@ -63,6 +63,7 @@ class Peaks
size_t _len;

void read_peaks ( int s, int e, int npeaks, int chunksize ) const;
int clip_read_peaks ( Peak *peaks, int npeaks, int chunksize ) const;

public:

@@ -71,9 +72,7 @@ public:
_peaks = new peakdata;

_peaks->chunksize = 0;
// _peaks->data = NULL;
_len = 0;

_clip = c;
}



Loading…
Cancel
Save