comparison rdf/RDFExporter.cpp @ 1040:a1cd5abcb38b cxx11

Introduce and use a samplerate type
author Chris Cannam
date Wed, 04 Mar 2015 12:01:04 +0000
parents fb6313da1df6
children 7a23dfe65d66
comparison
equal deleted inserted replaced
1039:b14064bd1f97 1040:a1cd5abcb38b
76 std::string summaryType; // nil 76 std::string summaryType; // nil
77 77
78 Vamp::Plugin::FeatureList features; 78 Vamp::Plugin::FeatureList features;
79 features.push_back(Vamp::Plugin::Feature()); 79 features.push_back(Vamp::Plugin::Feature());
80 Vamp::Plugin::Feature &f = features[0]; 80 Vamp::Plugin::Feature &f = features[0];
81 int sr = m_model->getSampleRate(); 81 sv_samplerate_t sr = m_model->getSampleRate();
82 82
83 { 83 {
84 RegionModel *m = dynamic_cast<RegionModel *>(m_model); 84 RegionModel *m = dynamic_cast<RegionModel *>(m_model);
85 if (m) { 85 if (m) {
86 f.hasTimestamp = true; 86 f.hasTimestamp = true;
87 f.hasDuration = true; 87 f.hasDuration = true;
88 const RegionModel::PointList &pl(m->getPoints()); 88 const RegionModel::PointList &pl(m->getPoints());
89 for (RegionModel::PointList::const_iterator i = pl.begin(); 89 for (RegionModel::PointList::const_iterator i = pl.begin();
90 i != pl.end(); ++i) { 90 i != pl.end(); ++i) {
91 f.timestamp = Vamp::RealTime::frame2RealTime(i->frame, sr); 91 f.timestamp = RealTime::frame2RealTime(i->frame, sr).toVampRealTime();
92 f.duration = Vamp::RealTime::frame2RealTime(i->duration, sr); 92 f.duration = RealTime::frame2RealTime(i->duration, sr).toVampRealTime();
93 f.values.clear(); 93 f.values.clear();
94 f.values.push_back(i->value); 94 f.values.push_back(i->value);
95 f.label = i->label.toStdString(); 95 f.label = i->label.toStdString();
96 m_fw->write(trackId, transform, output, features, summaryType); 96 m_fw->write(trackId, transform, output, features, summaryType);
97 } 97 }
104 f.hasTimestamp = true; 104 f.hasTimestamp = true;
105 f.hasDuration = true; 105 f.hasDuration = true;
106 const NoteModel::PointList &pl(m->getPoints()); 106 const NoteModel::PointList &pl(m->getPoints());
107 for (NoteModel::PointList::const_iterator i = pl.begin(); 107 for (NoteModel::PointList::const_iterator i = pl.begin();
108 i != pl.end(); ++i) { 108 i != pl.end(); ++i) {
109 f.timestamp = Vamp::RealTime::frame2RealTime(i->frame, sr); 109 f.timestamp = RealTime::frame2RealTime(i->frame, sr).toVampRealTime();
110 f.duration = Vamp::RealTime::frame2RealTime(i->duration, sr); 110 f.duration = RealTime::frame2RealTime(i->duration, sr).toVampRealTime();
111 f.values.clear(); 111 f.values.clear();
112 f.values.push_back(i->value); 112 f.values.push_back(i->value);
113 f.values.push_back(i->level); 113 f.values.push_back(i->level);
114 f.label = i->label.toStdString(); 114 f.label = i->label.toStdString();
115 m_fw->write(trackId, transform, output, features, summaryType); 115 m_fw->write(trackId, transform, output, features, summaryType);
123 f.hasTimestamp = true; 123 f.hasTimestamp = true;
124 f.hasDuration = false; 124 f.hasDuration = false;
125 const SparseOneDimensionalModel::PointList &pl(m->getPoints()); 125 const SparseOneDimensionalModel::PointList &pl(m->getPoints());
126 for (SparseOneDimensionalModel::PointList::const_iterator i = pl.begin(); 126 for (SparseOneDimensionalModel::PointList::const_iterator i = pl.begin();
127 i != pl.end(); ++i) { 127 i != pl.end(); ++i) {
128 f.timestamp = Vamp::RealTime::frame2RealTime(i->frame, sr); 128 f.timestamp = RealTime::frame2RealTime(i->frame, sr).toVampRealTime();
129 f.values.clear(); 129 f.values.clear();
130 f.label = i->label.toStdString(); 130 f.label = i->label.toStdString();
131 m_fw->write(trackId, transform, output, features, summaryType); 131 m_fw->write(trackId, transform, output, features, summaryType);
132 } 132 }
133 return; 133 return;
139 f.hasTimestamp = true; 139 f.hasTimestamp = true;
140 f.hasDuration = false; 140 f.hasDuration = false;
141 const SparseTimeValueModel::PointList &pl(m->getPoints()); 141 const SparseTimeValueModel::PointList &pl(m->getPoints());
142 for (SparseTimeValueModel::PointList::const_iterator i = pl.begin(); 142 for (SparseTimeValueModel::PointList::const_iterator i = pl.begin();
143 i != pl.end(); ++i) { 143 i != pl.end(); ++i) {
144 f.timestamp = Vamp::RealTime::frame2RealTime(i->frame, sr); 144 f.timestamp = RealTime::frame2RealTime(i->frame, sr).toVampRealTime();
145 f.values.clear(); 145 f.values.clear();
146 f.values.push_back(i->value); 146 f.values.push_back(i->value);
147 f.label = i->label.toStdString(); 147 f.label = i->label.toStdString();
148 m_fw->write(trackId, transform, output, features, summaryType); 148 m_fw->write(trackId, transform, output, features, summaryType);
149 } 149 }
157 f.hasDuration = false; 157 f.hasDuration = false;
158 const TextModel::PointList &pl(m->getPoints()); 158 const TextModel::PointList &pl(m->getPoints());
159 m_fw->setFixedEventTypeURI("af:Text"); 159 m_fw->setFixedEventTypeURI("af:Text");
160 for (TextModel::PointList::const_iterator i = pl.begin(); 160 for (TextModel::PointList::const_iterator i = pl.begin();
161 i != pl.end(); ++i) { 161 i != pl.end(); ++i) {
162 f.timestamp = Vamp::RealTime::frame2RealTime(i->frame, sr); 162 f.timestamp = RealTime::frame2RealTime(i->frame, sr).toVampRealTime();
163 f.values.clear(); 163 f.values.clear();
164 f.values.push_back(i->height); 164 f.values.push_back(i->height);
165 f.label = i->label.toStdString(); 165 f.label = i->label.toStdString();
166 m_fw->write(trackId, transform, output, features, summaryType); 166 m_fw->write(trackId, transform, output, features, summaryType);
167 } 167 }