Mercurial > hg > m4-sa
changeset 69:0ef80ae6493c
Sonic Annotator correctly reports the number of bytes written to a feature file even if it's less than expected.
author | gyorgyf |
---|---|
date | Fri, 24 Feb 2012 12:32:39 +0000 |
parents | 5e432835d7e1 |
children | 8fa569b9a8f1 |
files | runner/BinaryFeatureWriter.cpp runner/BinaryFeatureWriter.h runner/main.cpp sonic-annotator version.h |
diffstat | 5 files changed, 28 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/runner/BinaryFeatureWriter.cpp Fri Feb 24 11:23:06 2012 +0000 +++ b/runner/BinaryFeatureWriter.cpp Fri Feb 24 12:32:39 2012 +0000 @@ -236,7 +236,8 @@ if (binary->newtransform) { binary->newtransform = false; output_binCount = output.binCount; - feature_count = 0; + feature_count = 0; + element_count = 0; binary->transform = &transform; ofs << endl << "{" @@ -284,8 +285,10 @@ // write the feature data feature_count += featureList.size(); for (size_t i = 0; i < featureList.size(); ++i) { - for (size_t j = 0; j < featureList[i].values.size(); ++j) + for (size_t j = 0; j < featureList[i].values.size(); ++j) { ofs.write( (const char*) &featureList[i].values[j], sizeof(featureList[i].values[j]) ); + element_count++; + } } // ofs << endl; @@ -328,7 +331,13 @@ ofs << ",\"feature_count\":" << feature_count << ",\"data_size\":" - << feature_count * output_binCount * sizeof(float); - ofs.seekp(t); + // << feature_count * output_binCount * sizeof(float); + << element_count * sizeof(float); + ofs.seekp(t); + if (element_count != feature_count * output_binCount) + cerr << "ERROR: The number of feature values written is different from the expected value given by the output bin count and the number of features returned by the plugin. \n" + << "Otput bin count: " << output_binCount << ", Feature count: " << feature_count << ", Expected elements: " << feature_count * output_binCount + << ", Written elements: " << element_count << ", Resulting float32 data size: " << element_count * sizeof(float) << " bytes." + << endl; // FileFeatureWriter::finish(); }
--- a/runner/BinaryFeatureWriter.h Fri Feb 24 11:23:06 2012 +0000 +++ b/runner/BinaryFeatureWriter.h Fri Feb 24 12:32:39 2012 +0000 @@ -66,9 +66,10 @@ OutputStream *binary; bool openBinaryFile(); - long feature_count; - long data_size_pos; - long output_binCount; + long feature_count; // number of features per output + long data_size_pos; // temporary storage for file positioning + long output_binCount; // element count of each feature + long element_count; // total number of elements (e.g. float numbers) written per output }; #endif
--- a/runner/main.cpp Fri Feb 24 11:23:06 2012 +0000 +++ b/runner/main.cpp Fri Feb 24 12:32:39 2012 +0000 @@ -241,6 +241,16 @@ cerr << " transform against all files separately." << endl; cerr << endl; */ + cerr << " -c, --channels Default number of channels in audio files." << endl; + cerr << " If an audio file has differnt number of channels than this parameter" << endl; + cerr << " the file will be down (or up) mixed to procuce consistent output." << endl; + cerr << endl; + + cerr << " -sr, --samplingrate Resample all audio files to this sampling rate." << endl; + cerr << " This will override other configurations, such as the transform's" << endl; + cerr << " requested sampling rate and consistently use that same sampling rate" << endl; + cerr << " for all files and transforms." << endl; + cerr << endl; cerr << " -r, --recursive If any of the <audio> arguments is found to be a local" << endl; cerr << " directory, search the tree starting at that directory" << endl;