comparison rdf/RDFFeatureWriter.h @ 498:fdf5930b7ccc

* Bring FeatureWriter and RDFFeatureWriter into the fold (from Runner) so that we can use them to export features from SV as well
author Chris Cannam
date Fri, 28 Nov 2008 13:47:11 +0000
parents
children 3376dc26dece
comparison
equal deleted inserted replaced
497:b6dc6c7f402c 498:fdf5930b7ccc
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6
7 Sonic Annotator
8 A utility for batch feature extraction from audio files.
9
10 Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London.
11 Copyright 2007-2008 QMUL.
12
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version. See the file
17 COPYING included with this distribution for more information.
18 */
19
20 #ifndef _RDF_FEATURE_WRITER_H_
21 #define _RDF_FEATURE_WRITER_H_
22
23 #include <string>
24 #include <map>
25 #include <set>
26
27 #include <QString>
28
29 #include "transform/FileFeatureWriter.h"
30
31 #include "PluginRDFDescription.h"
32
33 using std::string;
34 using std::map;
35 using std::set;
36 using std::pair;
37
38 class QTextStream;
39 class QFile;
40
41 class RDFFeatureWriter : public FileFeatureWriter
42 {
43 public:
44 RDFFeatureWriter();
45 virtual ~RDFFeatureWriter();
46
47 virtual ParameterList getSupportedParameters() const;
48 virtual void setParameters(map<string, string> &params);
49
50 virtual void write(QString trackid,
51 const Transform &transform,
52 const Vamp::Plugin::OutputDescriptor &output,
53 const Vamp::Plugin::FeatureList &features,
54 std::string summaryType = "");
55
56 virtual void finish();
57
58 private:
59 typedef map<QString, PluginRDFDescription> RDFDescriptionMap; // by plugin id
60 RDFDescriptionMap m_rdfDescriptions;
61
62 void writePrefixes(QTextStream *);
63 void writeSignalDescription(QTextStream *, QString);
64 void writeLocalFeatureTypes(QTextStream *,
65 const Transform &,
66 const Vamp::Plugin::OutputDescriptor &,
67 PluginRDFDescription &);
68
69 void writeSparseRDF(QTextStream *stream,
70 const Transform &transform,
71 const Vamp::Plugin::OutputDescriptor &output,
72 const Vamp::Plugin::FeatureList &features,
73 PluginRDFDescription &desc,
74 QString timelineURI);
75
76 void writeDenseRDF(QTextStream *stream,
77 const Transform &transform,
78 const Vamp::Plugin::OutputDescriptor &output,
79 const Vamp::Plugin::FeatureList &features,
80 PluginRDFDescription &desc,
81 QString signalURI,
82 QString timelineURI);
83
84 set<QString> m_startedTrackIds;
85
86 map<QTextStream *, set<Transform> > m_startedStreamTransforms;
87
88 map<QString, QString> m_trackTimelineURIs;
89 map<QString, QString> m_trackSignalURIs;
90
91 map<Transform, QString> m_transformURIs;
92 map<Transform, QString> m_syntheticEventTypeURIs;
93 map<Transform, QString> m_syntheticSignalTypeURIs;
94
95 typedef pair<QString, Transform> StringTransformPair;
96 typedef pair<QTextStream *, QString> StreamBuffer;
97 map<StringTransformPair, StreamBuffer> m_openDenseFeatures; // signal URI + transform -> stream + text
98 QString m_suri;
99
100 bool m_plain;
101
102 uint64_t m_count;
103 };
104
105 #endif