Mercurial > hg > sonic-annotator
comparison runner/MIDIFeatureWriter.cpp @ 196:082c3f21f49e
Simple MIDI writer test
author | Chris Cannam |
---|---|
date | Tue, 01 Sep 2015 15:51:07 +0100 |
parents | 977b7007071f |
children | 3b7ec45abd1c |
comparison
equal
deleted
inserted
replaced
195:3f7c65f26559 | 196:082c3f21f49e |
---|---|
20 using Vamp::PluginBase; | 20 using Vamp::PluginBase; |
21 | 21 |
22 #include "base/Exceptions.h" | 22 #include "base/Exceptions.h" |
23 #include "data/fileio/MIDIFileWriter.h" | 23 #include "data/fileio/MIDIFileWriter.h" |
24 | 24 |
25 //#define DEBUG_MIDI_FEATURE_WRITER 1 | |
26 | |
25 MIDIFeatureWriter::MIDIFeatureWriter() : | 27 MIDIFeatureWriter::MIDIFeatureWriter() : |
26 FileFeatureWriter(SupportOneFilePerTrackTransform | | 28 FileFeatureWriter(SupportOneFilePerTrackTransform | |
27 SupportOneFilePerTrack | | 29 SupportOneFilePerTrack | |
28 SupportOneFileTotal, | 30 SupportOneFileTotal, |
29 "mid") | 31 "mid") |
35 } | 37 } |
36 | 38 |
37 string | 39 string |
38 MIDIFeatureWriter::getDescription() const | 40 MIDIFeatureWriter::getDescription() const |
39 { | 41 { |
40 return "Write features to MIDI files. All features are written as MIDI notes. If a feature has at least one value, its first value will be used as the note pitch, the second value (if present) for velocity. If a feature has units of Hz, then its pitch will be converted from frequency to an integer value in MIDI range, otherwise it will be written directly. Multiple (up to 16) transforms can be written to a single MIDI file, where they will be given separate MIDI channel numbers."; | 42 return "Write features to MIDI files. All features are written as MIDI notes. If a feature has at least one value, its first value will be used as the note pitch, the second value (if present) for velocity. If a feature has units of Hz, then its pitch will be converted from frequency to an integer value in MIDI range, otherwise it will simply be rounded to the nearest integer and written directly. Multiple (up to 16) transforms can be written to a single MIDI file, where they will be given separate MIDI channel numbers."; |
41 } | 43 } |
42 | 44 |
43 MIDIFeatureWriter::ParameterList | 45 MIDIFeatureWriter::ParameterList |
44 MIDIFeatureWriter::getSupportedParameters() const | 46 MIDIFeatureWriter::getSupportedParameters() const |
45 { | 47 { |
106 | 108 |
107 int duration = 1; | 109 int duration = 1; |
108 if (feature.hasDuration) { | 110 if (feature.hasDuration) { |
109 duration = Vamp::RealTime::realTime2Frame(feature.duration, sampleRate); | 111 duration = Vamp::RealTime::realTime2Frame(feature.duration, sampleRate); |
110 } | 112 } |
113 | |
114 #ifdef DEBUG_MIDI_FEATURE_WRITER | |
115 cerr << "feature timestamp = " << feature.timestamp << ", sampleRate = " << sampleRate << ", frame = " << frame << endl; | |
116 cerr << "feature duration = " << feature.duration << ", sampleRate = " << sampleRate << ", duration = " << duration << endl; | |
117 #endif | |
111 | 118 |
112 int pitch = 60; | 119 int pitch = 60; |
113 if (feature.values.size() > 0) { | 120 if (feature.values.size() > 0) { |
114 float pval = feature.values[0]; | 121 float pval = feature.values[0]; |
115 if (freq) { | 122 if (freq) { |