comparison runner/DefaultFeatureWriter.cpp @ 1:92911f967a16

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