Mercurial > hg > sonic-annotator
comparison runner/MIDIFeatureWriter.cpp @ 137:65a488d8c1bb midi
Might help to actually commit these files
author | Chris Cannam |
---|---|
date | Mon, 13 Oct 2014 11:28:24 +0100 |
parents | |
children | 9b94545a7fdc |
comparison
equal
deleted
inserted
replaced
136:2260947be4aa | 137:65a488d8c1bb |
---|---|
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 Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London. | |
7 Copyright 2007-2014 QMUL. | |
8 | |
9 This program is free software; you can redistribute it and/or | |
10 modify it under the terms of the GNU General Public License as | |
11 published by the Free Software Foundation; either version 2 of the | |
12 License, or (at your option) any later version. See the file | |
13 COPYING included with this distribution for more information. | |
14 */ | |
15 | |
16 #include "MIDIFeatureWriter.h" | |
17 | |
18 using namespace std; | |
19 using Vamp::Plugin; | |
20 using Vamp::PluginBase; | |
21 | |
22 #include "base/Exceptions.h" | |
23 #include "data/fileio/MIDIFileWriter.h" | |
24 | |
25 MIDIFeatureWriter::MIDIFeatureWriter() : | |
26 FileFeatureWriter(SupportOneFilePerTrackTransform | | |
27 SupportOneFilePerTrack | | |
28 SupportOneFileTotal, | |
29 "mid") | |
30 { | |
31 } | |
32 | |
33 MIDIFeatureWriter::~MIDIFeatureWriter() | |
34 { | |
35 } | |
36 | |
37 MIDIFeatureWriter::ParameterList | |
38 MIDIFeatureWriter::getSupportedParameters() const | |
39 { | |
40 ParameterList pl = FileFeatureWriter::getSupportedParameters(); | |
41 return pl; | |
42 } | |
43 | |
44 void | |
45 MIDIFeatureWriter::setParameters(map<string, string> ¶ms) | |
46 { | |
47 FileFeatureWriter::setParameters(params); | |
48 } | |
49 | |
50 void | |
51 MIDIFeatureWriter::setTrackMetadata(QString, TrackMetadata) | |
52 { | |
53 cerr << "MIDIFeatureWriter::setTrackMetadata: not supported (yet?)" << endl; | |
54 } | |
55 | |
56 void | |
57 MIDIFeatureWriter::write(QString trackId, | |
58 const Transform &transform, | |
59 const Plugin::OutputDescriptor& output, | |
60 const Plugin::FeatureList& features, | |
61 std::string summaryType) | |
62 { | |
63 QString filename = getOutputFilename(trackId, transform.getIdentifier()); | |
64 if (filename == "") { | |
65 throw FailedToOpenOutputStream(trackId, transform.getIdentifier()); | |
66 } | |
67 | |
68 //!!! implement! | |
69 } | |
70 | |
71 void | |
72 MIDIFeatureWriter::finish() | |
73 { | |
74 for (NoteMap::const_iterator i = m_notes.begin(); i != m_notes.end(); ++i) { | |
75 | |
76 QString filename = i->first; | |
77 NoteList notes = i->second; | |
78 float rate = m_rates[filename]; | |
79 | |
80 TrivialNoteExportable exportable(notes); | |
81 | |
82 { | |
83 MIDIFileWriter writer(filename, &exportable, rate); | |
84 if (!writer.isOK()) { | |
85 cerr << "ERROR: Failed to create MIDI writer: " | |
86 << writer.getError() << endl; | |
87 throw FileOperationFailed(filename, "create MIDI writer"); | |
88 } | |
89 writer.write(); | |
90 } | |
91 } | |
92 } | |
93 |