comparison runner/MIDIFeatureWriter.h @ 143:ad425b9096bd

Merge from branch 'midi'
author Chris Cannam
date Mon, 13 Oct 2014 13:53:09 +0100
parents 9b94545a7fdc
children b3d73c08b6ce
comparison
equal deleted inserted replaced
138:ee56e3e9eeb5 143:ad425b9096bd
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
7 Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London.
8 Copyright 2007-2014 QMUL.
9
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2 of the
13 License, or (at your option) any later version. See the file
14 COPYING included with this distribution for more information.
15 */
16
17 #ifndef _MIDI_FEATURE_WRITER_H_
18 #define _MIDI_FEATURE_WRITER_H_
19
20 #include "transform/FileFeatureWriter.h"
21 #include "data/model/NoteData.h"
22
23 class MIDIFileWriter;
24
25 class MIDIFeatureWriter : public FileFeatureWriter
26 {
27 public:
28 MIDIFeatureWriter();
29 virtual ~MIDIFeatureWriter();
30
31 virtual ParameterList getSupportedParameters() const;
32 virtual void setParameters(map<string, string> &params);
33
34 virtual void setTrackMetadata(QString trackid, TrackMetadata metadata);
35
36 virtual void write(QString trackid,
37 const Transform &transform,
38 const Vamp::Plugin::OutputDescriptor &output,
39 const Vamp::Plugin::FeatureList &features,
40 std::string summaryType = "");
41
42 virtual void finish();
43
44 virtual QString getWriterTag() const { return "midi"; }
45
46 private:
47 class TrivialNoteExportable : public NoteExportable {
48 public:
49 TrivialNoteExportable(NoteList notes) : m_notes(notes) { }
50 virtual NoteList getNotes() const {
51 return m_notes;
52 }
53 virtual NoteList getNotesWithin(int, int) const {
54 // Not required by MIDIFileWriter, not supported
55 return NoteList();
56 }
57 private:
58 NoteList m_notes;
59 };
60
61 typedef map<QString, NoteList> NoteMap; // output filename -> notes
62 NoteMap m_notes;
63
64 typedef map<QString, set<TransformId> > FileTransformMap;
65 FileTransformMap m_fileTransforms;
66
67 typedef map<QString, float> SampleRateMap; // NoteData uses sample timing
68 SampleRateMap m_rates;
69
70 typedef map<TransformId, int> ChannelMap;
71 ChannelMap m_channels;
72
73 typedef map<QString, int> NextChannelMap;
74 NextChannelMap m_nextChannels;
75 };
76
77 #endif
78