annotate runner/DefaultFeatureWriter.cpp @ 125:685e5cf3cb1d

Adjustments to help text; test file:// URLs
author Chris Cannam
date Thu, 09 Oct 2014 10:41:40 +0100
parents 92911f967a16
children ee56e3e9eeb5
rev   line source
Chris@0 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@0 4 Sonic Annotator
Chris@0 5 A utility for batch feature extraction from audio files.
Chris@0 6 Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London.
Chris@0 7 Copyright 2007-2008 QMUL.
Chris@0 8
Chris@0 9 This program is free software; you can redistribute it and/or
Chris@0 10 modify it under the terms of the GNU General Public License as
Chris@0 11 published by the Free Software Foundation; either version 2 of the
Chris@0 12 License, or (at your option) any later version. See the file
Chris@0 13 COPYING included with this distribution for more information.
Chris@0 14 */
Chris@0 15
Chris@0 16 #include <iostream>
Chris@0 17 #include <map>
Chris@0 18
Chris@0 19 using namespace std;
Chris@0 20
Chris@0 21 #include "DefaultFeatureWriter.h"
Chris@0 22
Chris@0 23 void DefaultFeatureWriter::write(QString trackid,
Chris@0 24 const Transform &transform,
Chris@0 25 const Vamp::Plugin::OutputDescriptor& output,
Chris@0 26 const Vamp::Plugin::FeatureList& featureList,
Chris@0 27 std::string summaryType)
Chris@0 28 {
Chris@0 29 // generic XML output
Chris@0 30
Chris@0 31 /*
Chris@0 32
Chris@0 33 <feature>
Chris@0 34 <name>output.name</name>
Chris@0 35 <timestamp>feature.timestamp</timestamp>
Chris@0 36 <values>output.binName[0]:feature.value[0]...</values>
Chris@0 37 <label>feature.label</label>
Chris@0 38 </feature>
Chris@0 39
Chris@0 40 */
Chris@0 41
Chris@0 42 for (int i = 0; i < featureList.size(); ++i)
Chris@0 43 {
Chris@0 44 if (summaryType == "") {
Chris@0 45 cout << "<feature>" << endl;
Chris@0 46 } else {
Chris@0 47 cout << "<summary type=\"" << summaryType << "\">" << endl;
Chris@0 48 }
Chris@0 49 cout << "\t<name>" << output.name << "</name>" << endl;
Chris@0 50 if (featureList[i].hasTimestamp) {
Chris@0 51 cout << "\t<timestamp>" << featureList[i].timestamp << "</timestamp>" << endl;
Chris@0 52 }
Chris@0 53 if (featureList[i].hasDuration) {
Chris@0 54 cout << "\t<duration>" << featureList[i].duration << "</duration>" << endl;
Chris@0 55 }
Chris@0 56 if (featureList[i].values.size() > 0)
Chris@0 57 {
Chris@0 58 cout << "\t<values>";
Chris@0 59 for (int j = 0; j < featureList[i].values.size(); ++j)
Chris@0 60 {
Chris@0 61 if (j > 0)
Chris@0 62 cout << " ";
Chris@0 63 if (output.binNames.size() > 0)
Chris@0 64 cout << output.binNames[j] << ":";
Chris@0 65 cout << featureList[i].values[j];
Chris@0 66 }
Chris@0 67 cout << "</values>" << endl;
Chris@0 68 }
Chris@0 69 if (featureList[i].label.length() > 0)
Chris@0 70 cout << "\t<label>" << featureList[i].label << "</label>" << endl;
Chris@0 71 if (summaryType == "") {
Chris@0 72 cout << "</feature>" << endl;
Chris@0 73 } else {
Chris@0 74 cout << "</summary>" << endl;
Chris@0 75 }
Chris@0 76 }
Chris@0 77 }