Browse Source

Improve peak reading efficiency.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
22030e41b6
3 changed files with 22 additions and 14 deletions
  1. +8
    -7
      Engine/Peak_Server.C
  2. +13
    -7
      Engine/Peaks.C
  3. +1
    -0
      Engine/Peaks.H

+ 8
- 7
Engine/Peak_Server.C View File

@@ -127,19 +127,20 @@ Peak_Server::handle_request ( int s, const char *buf, int l )

int npeaks = pk->fill_buffer( fpp, start, end );

/* deinterlace and transmit */
int channels = af->channels();

/* FIXME: really inefficient */
Peak *pbuf = new Peak[ npeaks * channels ];

/* deinterlace */
int k = 0;
for ( int i = 0; i < channels; i++ )
for ( int j = i; j < npeaks * channels; j += channels )
send( s, pk->peakbuf() + j, sizeof( Peak ), 0 );
pbuf[ k++ ] = pk->peakbuf()[ j ];

/* transmit */
send( s, pbuf, sizeof( Peak ) * npeaks * channels, 0 );

/* for ( int i = 0; i < af->channels(); ++i ) */
/* { */
/* send( s, pk->peakbuf(), npeaks * sizeof( Peak ), 0 ); */
/* } */
delete pbuf;

break;
}


+ 13
- 7
Engine/Peaks.C View File

@@ -147,7 +147,7 @@ Peaks::read_peakfile_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize
}

int
Peaks::read_source_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize ) const
Peaks::read_source_peaks ( Peak *peaks, int npeaks, int chunksize ) const
{
int channels = _clip->channels();

@@ -155,9 +155,6 @@ Peaks::read_source_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize )

size_t len;

_clip->open();
_clip->seek( s );

int i;
for ( i = 0; i < npeaks; ++i )
{
@@ -190,6 +187,17 @@ Peaks::read_source_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize )

delete fbuf;

return i;
}

int
Peaks::read_source_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize ) const
{
_clip->open();
_clip->seek( s );

int i = read_source_peaks( peaks, npeaks, chunksize );

_clip->close();

return i;
@@ -340,10 +348,8 @@ Peaks::make_peaks ( int chunksize )
Peak peaks[ _clip->channels() ];

size_t len;
nframes_t s = 0;
do {
len = read_source_peaks( peaks, s, 1, chunksize );
s += len * chunksize;
len = read_source_peaks( peaks, 1, chunksize );
fwrite( peaks, sizeof( peaks ), 1, fp );
}
while ( len );


+ 1
- 0
Engine/Peaks.H View File

@@ -64,6 +64,7 @@ class Peaks

void read_peaks ( int s, int e, int npeaks, int chunksize ) const;
int read_source_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize ) const;
int read_source_peaks ( Peak *peaks, int npeaks, int chunksize ) const;
int read_peakfile_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize ) const;

const char *peakname ( const char *filename ) const;


Loading…
Cancel
Save