comparison runner/MIDIFeatureWriter.cpp @ 324:ef03350baec7

Switch some more cerrs to SVCERRs
author Chris Cannam
date Fri, 18 May 2018 11:27:02 +0100
parents 3b7ec45abd1c
children e39307a8d22d
comparison
equal deleted inserted replaced
323:50461005ffcb 324:ef03350baec7
18 using namespace std; 18 using namespace std;
19 using Vamp::Plugin; 19 using Vamp::Plugin;
20 using Vamp::PluginBase; 20 using Vamp::PluginBase;
21 21
22 #include "base/Exceptions.h" 22 #include "base/Exceptions.h"
23 #include "base/Debug.h"
23 #include "data/fileio/MIDIFileWriter.h" 24 #include "data/fileio/MIDIFileWriter.h"
24 25
25 //#define DEBUG_MIDI_FEATURE_WRITER 1 26 //#define DEBUG_MIDI_FEATURE_WRITER 1
26 27
27 MIDIFeatureWriter::MIDIFeatureWriter() : 28 MIDIFeatureWriter::MIDIFeatureWriter() :
56 } 57 }
57 58
58 void 59 void
59 MIDIFeatureWriter::setTrackMetadata(QString, TrackMetadata) 60 MIDIFeatureWriter::setTrackMetadata(QString, TrackMetadata)
60 { 61 {
61 cerr << "MIDIFeatureWriter::setTrackMetadata: not supported (yet?)" << endl; 62 SVCERR << "MIDIFeatureWriter::setTrackMetadata: not supported (yet?)" << endl;
62 } 63 }
63 64
64 void 65 void
65 MIDIFeatureWriter::write(QString trackId, 66 MIDIFeatureWriter::write(QString trackId,
66 const Transform &transform, 67 const Transform &transform,
110 if (feature.hasDuration) { 111 if (feature.hasDuration) {
111 duration = Vamp::RealTime::realTime2Frame(feature.duration, sampleRate); 112 duration = Vamp::RealTime::realTime2Frame(feature.duration, sampleRate);
112 } 113 }
113 114
114 #ifdef DEBUG_MIDI_FEATURE_WRITER 115 #ifdef DEBUG_MIDI_FEATURE_WRITER
115 cerr << "feature timestamp = " << feature.timestamp << ", sampleRate = " << sampleRate << ", frame = " << frame << endl; 116 SVCERR << "feature timestamp = " << feature.timestamp << ", sampleRate = " << sampleRate << ", frame = " << frame << endl;
116 cerr << "feature duration = " << feature.duration << ", sampleRate = " << sampleRate << ", duration = " << duration << endl; 117 SVCERR << "feature duration = " << feature.duration << ", sampleRate = " << sampleRate << ", duration = " << duration << endl;
117 #endif 118 #endif
118 119
119 int pitch = 60; 120 int pitch = 60;
120 if (feature.values.size() > 0) { 121 if (feature.values.size() > 0) {
121 float pval = feature.values[0]; 122 float pval = feature.values[0];
156 TrivialNoteExportable exportable(notes); 157 TrivialNoteExportable exportable(notes);
157 158
158 { 159 {
159 MIDIFileWriter writer(filename, &exportable, rate); 160 MIDIFileWriter writer(filename, &exportable, rate);
160 if (!writer.isOK()) { 161 if (!writer.isOK()) {
161 cerr << "ERROR: Failed to create MIDI writer: " 162 SVCERR << "ERROR: Failed to create MIDI writer: "
162 << writer.getError() << endl; 163 << writer.getError() << endl;
163 throw FileOperationFailed(filename, "create MIDI writer"); 164 throw FileOperationFailed(filename, "create MIDI writer");
164 } 165 }
165 166
166 writer.write(); 167 writer.write();
167 168
168 if (!writer.isOK()) { 169 if (!writer.isOK()) {
169 cerr << "ERROR: Failed to write to MIDI file: " 170 SVCERR << "ERROR: Failed to write to MIDI file: "
170 << writer.getError() << endl; 171 << writer.getError() << endl;
171 throw FileOperationFailed(filename, "MIDI write"); 172 throw FileOperationFailed(filename, "MIDI write");
172 } 173 }
173 } 174 }
174 } 175 }
175 176