Mercurial > hg > audiodb
changeset 218:016303fc3e1b refactoring
Compute durations more correctly.
We have the last point now, so we can compute its duration too. (Remove
"-1" from end conditions of for() loops.)
author | mas01cr |
---|---|
date | Tue, 04 Dec 2007 16:48:23 +0000 |
parents | 685eb707b660 |
children | d1c912ff8286 |
files | query.cpp |
diffstat | 1 files changed, 7 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/query.cpp Tue Dec 04 12:47:49 2007 +0000 +++ b/query.cpp Tue Dec 04 16:48:23 2007 +0000 @@ -208,6 +208,9 @@ } } +// FIXME: this is not the right name; we're not actually setting up +// the database, but copying various bits of it out of mmap()ed tables +// in order to reduce seeks. void audioDB::set_up_db(double **snp, double **spp, unsigned int *dvp) { *dvp = dbH->length / (dbH->dim * sizeof(double)); *snp = new double[*dvp]; @@ -314,7 +317,7 @@ insertTimeStamps(numVectors, timesFile, timesdata); // Calculate durations of points - for(k=0; k<numVectors-1; k++) { + for(k=0; k<numVectors; k++) { querydurs[k] = timesdata[2*k+1] - timesdata[2*k]; meanQdur += querydurs[k]; } @@ -326,7 +329,7 @@ assert(meanDBdur); for(k=0; k<dbH->numFiles; k++){ meanDBdur[k]=0.0; - for(j=0; j<trackTable[k]-1 ; j++) { + for(j=0; j<trackTable[k]; j++) { meanDBdur[k]+=timesTable[2*j+1]-timesTable[2*j]; } meanDBdur[k]/=j; @@ -657,7 +660,7 @@ insertTimeStamps(numVectors, timesFile, timesdata); // Calculate durations of points - for(k=0; k<numVectors-1; k++){ + for(k=0; k<numVectors; k++){ querydurs[k] = timesdata[2*k+1] - timesdata[2*k]; meanQdur += querydurs[k]; } @@ -669,7 +672,7 @@ assert(meanDBdur); for(k=0; k<dbH->numFiles; k++){ meanDBdur[k]=0.0; - for(j=0; j<trackTable[k]-1 ; j++) { + for(j=0; j<trackTable[k]; j++) { meanDBdur[k]+=timesTable[2*j+1]-timesTable[2*j]; } meanDBdur[k]/=j;