Mercurial > hg > qm-vamp-plugins
comparison plugins/BarBeatTrack.cpp @ 90:52c6817a414e
* Add a beat spectral difference output to bar detector
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Fri, 27 Feb 2009 10:24:07 +0000 |
parents | f4a2f5aa743c |
children | 385bec9df059 |
comparison
equal
deleted
inserted
replaced
89:f4a2f5aa743c | 90:52c6817a414e |
---|---|
232 beatcounts.hasFixedBinCount = true; | 232 beatcounts.hasFixedBinCount = true; |
233 beatcounts.binCount = 1; | 233 beatcounts.binCount = 1; |
234 beatcounts.sampleType = OutputDescriptor::VariableSampleRate; | 234 beatcounts.sampleType = OutputDescriptor::VariableSampleRate; |
235 beatcounts.sampleRate = 1.0 / m_stepSecs; | 235 beatcounts.sampleRate = 1.0 / m_stepSecs; |
236 | 236 |
237 OutputDescriptor beatsd; | |
238 beatsd.identifier = "beatsd"; | |
239 beatsd.name = "Beat Spectral Difference"; | |
240 beatsd.description = "Beat spectral difference function used for bar-line detection"; | |
241 beatsd.unit = ""; | |
242 beatsd.hasFixedBinCount = true; | |
243 beatsd.binCount = 1; | |
244 beatsd.sampleType = OutputDescriptor::VariableSampleRate; | |
245 beatsd.sampleRate = 1.0 / m_stepSecs; | |
246 | |
237 list.push_back(beat); | 247 list.push_back(beat); |
238 list.push_back(bars); | 248 list.push_back(bars); |
239 list.push_back(beatcounts); | 249 list.push_back(beatcounts); |
250 list.push_back(beatsd); | |
240 | 251 |
241 return list; | 252 return list; |
242 } | 253 } |
243 | 254 |
244 BarBeatTracker::FeatureSet | 255 BarBeatTracker::FeatureSet |
316 | 327 |
317 vector<int> downbeats; | 328 vector<int> downbeats; |
318 size_t downLength = 0; | 329 size_t downLength = 0; |
319 const float *downsampled = m_d->downBeat->getBufferedAudio(downLength); | 330 const float *downsampled = m_d->downBeat->getBufferedAudio(downLength); |
320 m_d->downBeat->findDownBeats(downsampled, downLength, beats, downbeats); | 331 m_d->downBeat->findDownBeats(downsampled, downLength, beats, downbeats); |
332 | |
333 vector<double> beatsd; | |
334 m_d->downBeat->getBeatSD(beatsd); | |
321 | 335 |
322 // std::cerr << "BarBeatTracker: found downbeats at: "; | 336 // std::cerr << "BarBeatTracker: found downbeats at: "; |
323 // for (int i = 0; i < downbeats.size(); ++i) std::cerr << downbeats[i] << " " << std::endl; | 337 // for (int i = 0; i < downbeats.size(); ++i) std::cerr << downbeats[i] << " " << std::endl; |
324 | 338 |
325 FeatureSet returnFeatures; | 339 FeatureSet returnFeatures; |
358 returnFeatures[0].push_back(feature); // labelled beats | 372 returnFeatures[0].push_back(feature); // labelled beats |
359 | 373 |
360 feature.values.push_back(beat + 1); | 374 feature.values.push_back(beat + 1); |
361 returnFeatures[2].push_back(feature); // beat function | 375 returnFeatures[2].push_back(feature); // beat function |
362 | 376 |
377 if (i > 0 && i <= beatsd.size()) { | |
378 feature.values.clear(); | |
379 feature.values.push_back(beatsd[i-1]); | |
380 feature.label = ""; | |
381 returnFeatures[3].push_back(feature); // beat spectral difference | |
382 } | |
383 | |
363 if (beat == 0) { | 384 if (beat == 0) { |
364 feature.values.clear(); | 385 feature.values.clear(); |
365 sprintf(label, "%d", bar); | 386 sprintf(label, "%d", bar); |
366 feature.label = label; | 387 feature.label = label; |
367 returnFeatures[1].push_back(feature); // bars | 388 returnFeatures[1].push_back(feature); // bars |