Mercurial > hg > audiodb
changeset 153:00928c833187 powertable
dump/restore support for the power table.
author | mas01cr |
---|---|
date | Wed, 31 Oct 2007 18:22:23 +0000 |
parents | b1cbd2b78a18 |
children | 97f704a32bf2 |
files | audioDB.cpp |
diffstat | 1 files changed, 40 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/audioDB.cpp Wed Oct 31 16:53:25 2007 +0000 +++ b/audioDB.cpp Wed Oct 31 18:22:23 2007 +0000 @@ -995,18 +995,27 @@ error("error changing working directory", output, "chdir"); } - int fLfd, tLfd = 0, kLfd; - FILE *fLFile, *tLFile = 0, *kLFile; + int fLfd, tLfd = 0, pLfd = 0, kLfd; + FILE *fLFile, *tLFile = 0, *pLFile = 0, *kLFile; if ((fLfd = open("featureList.txt", O_CREAT|O_RDWR|O_EXCL, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) < 0) { error("error creating featureList file", "featureList.txt", "open"); } + int times = dbH->flags & O2_FLAG_TIMES; if (times) { if ((tLfd = open("timesList.txt", O_CREAT|O_RDWR|O_EXCL, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) < 0) { error("error creating timesList file", "timesList.txt", "open"); } } + + int power = dbH->flags & O2_FLAG_POWER; + if (power) { + if ((pLfd = open("powerList.txt", O_CREAT|O_RDWR|O_EXCL, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) < 0) { + error("error creating powerList file", "powerList.txt", "open"); + } + } + if ((kLfd = open("keyList.txt", O_CREAT|O_RDWR|O_EXCL, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) < 0) { error("error creating keyList file", "keyList.txt", "open"); } @@ -1016,10 +1025,13 @@ if (times) { tLFile = fdopen(tLfd, "w"); } + if (power) { + pLFile = fdopen(pLfd, "w"); + } kLFile = fdopen(kLfd, "w"); char *fName = new char[256]; - int ffd; + int ffd, pfd; FILE *tFile; unsigned pos = 0; for(unsigned k = 0; k < dbH->numFiles; k++) { @@ -1053,6 +1065,22 @@ fprintf(tLFile, "%s\n", fName); } + if (power) { + uint32_t one = 1; + snprintf(fName, 256, "%05d.power", k); + if ((pfd = open(fName, O_CREAT|O_RDWR|O_EXCL, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) < 0) { + error("error creating power file", fName, "open"); + } + if ((write(pfd, &one, sizeof(uint32_t))) < 0) { + error("error writing one", fName, "write"); + } + if ((write(pfd, powerTable + pos, trackTable[k] * sizeof(double))) < 0) { + error("error writing data", fName, "write"); + } + fprintf(pLFile, "%s\n", fName); + close(pfd); + } + pos += trackTable[k]; cout << fileTable+k*O2_FILETABLESIZE << " " << trackTable[k] << endl; } @@ -1070,10 +1098,16 @@ if(dbH->flags & O2_FLAG_L2NORM) { fprintf(scriptFile, "\"${AUDIODB}\" -d \"$1\" -L\n"); } + if(power) { + fprintf(scriptFile, "\"${AUDIODB}\" -d \"$1\" -P\n"); + } fprintf(scriptFile, "\"${AUDIODB}\" -d \"$1\" -B -F featureList.txt -K keyList.txt"); if(times) { fprintf(scriptFile, " -T timesList.txt"); } + if(power) { + fprintf(scriptFile, " -W powerList.txt"); + } fprintf(scriptFile, "\n"); fclose(scriptFile); @@ -1085,6 +1119,9 @@ if(times) { fclose(tLFile); } + if(power) { + fclose(pLFile); + } fclose(kLFile); delete[] fName;