comparison runner/BinaryFeatureWriter.cpp @ 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
comparison
equal deleted inserted replaced
68:5e432835d7e1 69:0ef80ae6493c
234 */ 234 */
235 235
236 if (binary->newtransform) { 236 if (binary->newtransform) {
237 binary->newtransform = false; 237 binary->newtransform = false;
238 output_binCount = output.binCount; 238 output_binCount = output.binCount;
239 feature_count = 0; 239 feature_count = 0;
240 element_count = 0;
240 binary->transform = &transform; 241 binary->transform = &transform;
241 242
242 ofs << endl << "{" 243 ofs << endl << "{"
243 << "\"track_id\":\"" << trackid << "\"," 244 << "\"track_id\":\"" << trackid << "\","
244 << "\"transform_id\":\"" << transform.getIdentifier() << "\"," 245 << "\"transform_id\":\"" << transform.getIdentifier() << "\","
282 // BUG: File corruption after about 34000 runs due to beat spectrum plugin returning less data than advertised !!! 283 // BUG: File corruption after about 34000 runs due to beat spectrum plugin returning less data than advertised !!!
283 284
284 // write the feature data 285 // write the feature data
285 feature_count += featureList.size(); 286 feature_count += featureList.size();
286 for (size_t i = 0; i < featureList.size(); ++i) { 287 for (size_t i = 0; i < featureList.size(); ++i) {
287 for (size_t j = 0; j < featureList[i].values.size(); ++j) 288 for (size_t j = 0; j < featureList[i].values.size(); ++j) {
288 ofs.write( (const char*) &featureList[i].values[j], sizeof(featureList[i].values[j]) ); 289 ofs.write( (const char*) &featureList[i].values[j], sizeof(featureList[i].values[j]) );
290 element_count++;
291 }
289 } 292 }
290 // ofs << endl; 293 // ofs << endl;
291 294
292 // // write time stamp data 295 // // write time stamp data
293 // for (int i = 0; i < featureList.size(); ++i) { 296 // for (int i = 0; i < featureList.size(); ++i) {
326 ofs.seekp(data_size_pos); 329 ofs.seekp(data_size_pos);
327 // fill in the missing information in the transform python dict that is required to read the output into an array 330 // fill in the missing information in the transform python dict that is required to read the output into an array
328 ofs << ",\"feature_count\":" 331 ofs << ",\"feature_count\":"
329 << feature_count 332 << feature_count
330 << ",\"data_size\":" 333 << ",\"data_size\":"
331 << feature_count * output_binCount * sizeof(float); 334 // << feature_count * output_binCount * sizeof(float);
332 ofs.seekp(t); 335 << element_count * sizeof(float);
336 ofs.seekp(t);
337 if (element_count != feature_count * output_binCount)
338 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"
339 << "Otput bin count: " << output_binCount << ", Feature count: " << feature_count << ", Expected elements: " << feature_count * output_binCount
340 << ", Written elements: " << element_count << ", Resulting float32 data size: " << element_count * sizeof(float) << " bytes."
341 << endl;
333 // FileFeatureWriter::finish(); 342 // FileFeatureWriter::finish();
334 } 343 }