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