Chris@137
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@137
|
2
|
Chris@137
|
3 /*
|
Chris@137
|
4 Sonic Annotator
|
Chris@137
|
5 A utility for batch feature extraction from audio files.
|
Chris@137
|
6
|
Chris@137
|
7 Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London.
|
Chris@137
|
8 Copyright 2007-2014 QMUL.
|
Chris@137
|
9
|
Chris@137
|
10 This program is free software; you can redistribute it and/or
|
Chris@137
|
11 modify it under the terms of the GNU General Public License as
|
Chris@137
|
12 published by the Free Software Foundation; either version 2 of the
|
Chris@137
|
13 License, or (at your option) any later version. See the file
|
Chris@137
|
14 COPYING included with this distribution for more information.
|
Chris@137
|
15 */
|
Chris@137
|
16
|
Chris@345
|
17 #ifndef MIDI_FEATURE_WRITER_H
|
Chris@345
|
18 #define MIDI_FEATURE_WRITER_H
|
Chris@137
|
19
|
Chris@137
|
20 #include "transform/FileFeatureWriter.h"
|
Chris@345
|
21 #include "base/NoteData.h"
|
Chris@345
|
22 #include "base/NoteExportable.h"
|
Chris@137
|
23
|
Chris@137
|
24 class MIDIFileWriter;
|
Chris@137
|
25
|
Chris@137
|
26 class MIDIFeatureWriter : public FileFeatureWriter
|
Chris@137
|
27 {
|
Chris@137
|
28 public:
|
Chris@137
|
29 MIDIFeatureWriter();
|
Chris@137
|
30 virtual ~MIDIFeatureWriter();
|
Chris@137
|
31
|
Chris@144
|
32 string getDescription() const;
|
Chris@144
|
33
|
Chris@137
|
34 virtual ParameterList getSupportedParameters() const;
|
Chris@137
|
35 virtual void setParameters(map<string, string> ¶ms);
|
Chris@137
|
36
|
Chris@137
|
37 virtual void setTrackMetadata(QString trackid, TrackMetadata metadata);
|
Chris@137
|
38
|
Chris@137
|
39 virtual void write(QString trackid,
|
Chris@137
|
40 const Transform &transform,
|
Chris@137
|
41 const Vamp::Plugin::OutputDescriptor &output,
|
Chris@137
|
42 const Vamp::Plugin::FeatureList &features,
|
Chris@137
|
43 std::string summaryType = "");
|
Chris@137
|
44
|
Chris@137
|
45 virtual void finish();
|
Chris@137
|
46
|
Chris@137
|
47 virtual QString getWriterTag() const { return "midi"; }
|
Chris@137
|
48
|
Chris@137
|
49 private:
|
Chris@137
|
50 class TrivialNoteExportable : public NoteExportable {
|
Chris@137
|
51 public:
|
Chris@137
|
52 TrivialNoteExportable(NoteList notes) : m_notes(notes) { }
|
Chris@137
|
53 virtual NoteList getNotes() const {
|
Chris@137
|
54 return m_notes;
|
Chris@137
|
55 }
|
Chris@345
|
56 virtual NoteList getNotesActiveAt(sv_frame_t) const {
|
Chris@345
|
57 // Not required by MIDIFileWriter, not supported
|
Chris@345
|
58 return NoteList();
|
Chris@345
|
59 }
|
Chris@345
|
60 virtual NoteList getNotesStartingWithin(sv_frame_t, sv_frame_t) const {
|
Chris@137
|
61 // Not required by MIDIFileWriter, not supported
|
Chris@137
|
62 return NoteList();
|
Chris@137
|
63 }
|
Chris@137
|
64 private:
|
Chris@137
|
65 NoteList m_notes;
|
Chris@137
|
66 };
|
Chris@137
|
67
|
Chris@137
|
68 typedef map<QString, NoteList> NoteMap; // output filename -> notes
|
Chris@137
|
69 NoteMap m_notes;
|
Chris@140
|
70
|
Chris@175
|
71 typedef map<QString, set<Transform> > FileTransformMap;
|
Chris@140
|
72 FileTransformMap m_fileTransforms;
|
Chris@137
|
73
|
Chris@331
|
74 typedef map<QString, sv_samplerate_t> SampleRateMap; // NoteData uses sample timing
|
Chris@137
|
75 SampleRateMap m_rates;
|
Chris@137
|
76
|
Chris@175
|
77 typedef map<Transform, int> ChannelMap;
|
Chris@137
|
78 ChannelMap m_channels;
|
Chris@137
|
79
|
Chris@140
|
80 typedef map<QString, int> NextChannelMap;
|
Chris@140
|
81 NextChannelMap m_nextChannels;
|
Chris@137
|
82 };
|
Chris@137
|
83
|
Chris@137
|
84 #endif
|
Chris@137
|
85
|