Chris@145
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@145
|
2
|
Chris@145
|
3 /*
|
Chris@145
|
4 Sonic Annotator
|
Chris@145
|
5 A utility for batch feature extraction from audio files.
|
Chris@145
|
6
|
Chris@145
|
7 Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London.
|
Chris@145
|
8 Copyright 2007-2014 QMUL.
|
Chris@145
|
9
|
Chris@145
|
10 This program is free software; you can redistribute it and/or
|
Chris@145
|
11 modify it under the terms of the GNU General Public License as
|
Chris@145
|
12 published by the Free Software Foundation; either version 2 of the
|
Chris@145
|
13 License, or (at your option) any later version. See the file
|
Chris@145
|
14 COPYING included with this distribution for more information.
|
Chris@145
|
15 */
|
Chris@145
|
16
|
Chris@145
|
17 #ifndef _JAMS_FEATURE_WRITER_H_
|
Chris@145
|
18 #define _JAMS_FEATURE_WRITER_H_
|
Chris@145
|
19
|
Chris@145
|
20 #include "transform/FileFeatureWriter.h"
|
Chris@145
|
21
|
Chris@145
|
22 #include "rdf/PluginRDFDescription.h"
|
Chris@145
|
23
|
Chris@145
|
24 class JAMSFileWriter;
|
Chris@145
|
25
|
Chris@145
|
26 class JAMSFeatureWriter : public FileFeatureWriter
|
Chris@145
|
27 {
|
Chris@145
|
28 public:
|
Chris@145
|
29 JAMSFeatureWriter();
|
Chris@145
|
30 virtual ~JAMSFeatureWriter();
|
Chris@145
|
31
|
Chris@145
|
32 string getDescription() const;
|
Chris@145
|
33
|
Chris@145
|
34 virtual ParameterList getSupportedParameters() const;
|
Chris@145
|
35 virtual void setParameters(map<string, string> ¶ms);
|
Chris@145
|
36
|
Chris@145
|
37 virtual void setTrackMetadata(QString trackid, TrackMetadata metadata);
|
Chris@145
|
38
|
Chris@145
|
39 virtual void write(QString trackid,
|
Chris@145
|
40 const Transform &transform,
|
Chris@145
|
41 const Vamp::Plugin::OutputDescriptor &output,
|
Chris@145
|
42 const Vamp::Plugin::FeatureList &features,
|
Chris@145
|
43 std::string summaryType = "");
|
Chris@145
|
44
|
Chris@145
|
45 virtual void finish();
|
Chris@145
|
46
|
Chris@145
|
47 virtual QString getWriterTag() const { return "json"; }
|
Chris@145
|
48
|
Chris@145
|
49 private:
|
Chris@145
|
50 enum Task {
|
Chris@145
|
51 UnknownTask,
|
Chris@145
|
52 BeatTask,
|
Chris@145
|
53 OnsetTask,
|
Chris@145
|
54 ChordTask,
|
Chris@145
|
55 SegmentTask,
|
Chris@145
|
56 KeyTask,
|
Chris@145
|
57 NoteTask,
|
Chris@145
|
58 MelodyTask,
|
Chris@145
|
59 PitchTask,
|
Chris@145
|
60 };
|
Chris@145
|
61
|
Chris@145
|
62 typedef map<QString, PluginRDFDescription> RDFDescriptionMap; // by plugin id
|
Chris@145
|
63 RDFDescriptionMap m_rdfDescriptions;
|
Chris@145
|
64
|
Chris@167
|
65 typedef QString TrackId;
|
Chris@167
|
66 typedef pair<TrackId, Transform> DataId;
|
Chris@145
|
67
|
Chris@167
|
68 typedef map<TrackId, TrackMetadata> TrackMetadataMap;
|
Chris@167
|
69 TrackMetadataMap m_trackMetadata;
|
Chris@167
|
70
|
Chris@167
|
71 typedef set<TrackId> TrackIds;
|
Chris@167
|
72 typedef map<QTextStream *, TrackIds> StreamTrackMap;
|
Chris@167
|
73 StreamTrackMap m_streamTracks;
|
Chris@167
|
74
|
Chris@167
|
75 typedef set<Task> Tasks;
|
Chris@167
|
76 typedef map<QTextStream *, Tasks> StreamTaskMap;
|
Chris@167
|
77 StreamTaskMap m_streamTasks;
|
Chris@167
|
78
|
Chris@167
|
79 typedef set<DataId> DataIds;
|
Chris@167
|
80 typedef map<QTextStream *, DataIds> StreamDataMap;
|
Chris@167
|
81 StreamDataMap m_streamData;
|
Chris@167
|
82
|
Chris@167
|
83 typedef map<DataId, QString> DataMap;
|
Chris@152
|
84 DataMap m_data;
|
Chris@152
|
85
|
Chris@167
|
86 typedef map<TransformId, Task> TaskMap;
|
Chris@145
|
87 TaskMap m_tasks;
|
Chris@145
|
88
|
Chris@145
|
89 void loadRDFDescription(const Transform &);
|
Chris@145
|
90 void identifyTask(const Transform &);
|
Chris@145
|
91
|
Chris@145
|
92 QString getTaskKey(Task);
|
Chris@145
|
93
|
Chris@165
|
94 QString writeTransformToObjectContents(const Transform &);
|
Chris@165
|
95
|
Chris@145
|
96 bool m_network;
|
Chris@145
|
97 bool m_networkRetrieved;
|
Chris@145
|
98 };
|
Chris@145
|
99
|
Chris@145
|
100 #endif
|
Chris@145
|
101
|