comparison plugins/Notes.cpp @ 31:2e979622bd93

Update plugin version numbers, remove API version back compatibility (API v1 is now so long out of date)
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 09 Jul 2012 15:44:07 +0100
parents 7fd8f7a0b088
children 8a20f3488d88
comparison
equal deleted inserted replaced
30:7fd8f7a0b088 31:2e979622bd93
22 using std::string; 22 using std::string;
23 using std::vector; 23 using std::vector;
24 using std::cerr; 24 using std::cerr;
25 using std::endl; 25 using std::endl;
26 26
27 Notes::Notes(float inputSampleRate, unsigned int apiVersion) : 27 Notes::Notes(float inputSampleRate) :
28 Plugin(inputSampleRate), 28 Plugin(inputSampleRate),
29 m_apiVersion(apiVersion),
30 m_ibuf(0), 29 m_ibuf(0),
31 m_fftgrain(0), 30 m_fftgrain(0),
32 m_onset(0), 31 m_onset(0),
33 m_pv(0), 32 m_pv(0),
34 m_peakpick(0), 33 m_peakpick(0),
43 m_maxpitch(95), 42 m_maxpitch(95),
44 m_wrapRange(false), 43 m_wrapRange(false),
45 m_avoidLeaps(false), 44 m_avoidLeaps(false),
46 m_prevPitch(-1) 45 m_prevPitch(-1)
47 { 46 {
48 if (apiVersion == 1) {
49 cerr << "vamp-aubio: WARNING: using compatibility version 1 of the Vamp API for note\n"
50 << "tracker plugin: upgrade your host to v2 for proper duration support" << endl;
51 } else {
52 cerr << "vamp-aubio: NOTE: using v2 API for true durations" << endl;
53 }
54 } 47 }
55 48
56 Notes::~Notes() 49 Notes::~Notes()
57 { 50 {
58 if (m_onsetdet) del_aubio_onset(m_onsetdet); 51 if (m_onsetdet) del_aubio_onset(m_onsetdet);
89 } 82 }
90 83
91 int 84 int
92 Notes::getPluginVersion() const 85 Notes::getPluginVersion() const
93 { 86 {
94 if (m_apiVersion == 1) return 2; 87 return 4;
95 return 3;
96 } 88 }
97 89
98 string 90 string
99 Notes::getCopyright() const 91 Notes::getCopyright() const
100 { 92 {
328 d.identifier = "notes"; 320 d.identifier = "notes";
329 d.name = "Notes"; 321 d.name = "Notes";
330 d.unit = "Hz"; 322 d.unit = "Hz";
331 d.hasFixedBinCount = true; 323 d.hasFixedBinCount = true;
332 324
333 if (m_apiVersion == 1) { 325 d.binCount = 2;
334 d.binCount = 3; 326 d.binNames.push_back("Frequency");
335 d.binNames.push_back("Frequency"); 327 d.binNames.push_back("Velocity");
336 d.binNames.push_back("Duration"); 328 d.hasDuration = true;
337 d.binNames.push_back("Velocity");
338 } else {
339 d.binCount = 2;
340 d.binNames.push_back("Frequency");
341 d.binNames.push_back("Velocity");
342 d.hasDuration = true;
343 }
344 329
345 d.hasKnownExtents = false; 330 d.hasKnownExtents = false;
346 d.isQuantized = false; 331 d.isQuantized = false;
347 d.sampleType = OutputDescriptor::VariableSampleRate; 332 d.sampleType = OutputDescriptor::VariableSampleRate;
348 d.sampleRate = 0; 333 d.sampleRate = 0;
446 feature.hasTimestamp = true; 431 feature.hasTimestamp = true;
447 if (m_currentOnset < m_delay) m_currentOnset = m_delay; 432 if (m_currentOnset < m_delay) m_currentOnset = m_delay;
448 feature.timestamp = m_currentOnset - m_delay; 433 feature.timestamp = m_currentOnset - m_delay;
449 feature.values.push_back(freq); 434 feature.values.push_back(freq);
450 435
451 if (m_apiVersion == 1) { 436 feature.values.push_back
452 feature.values.push_back 437 (Vamp::RealTime::realTime2Frame
453 (Vamp::RealTime::realTime2Frame 438 (offTime, lrintf(m_inputSampleRate)) -
454 (offTime, lrintf(m_inputSampleRate)) - 439 Vamp::RealTime::realTime2Frame
455 Vamp::RealTime::realTime2Frame 440 (m_currentOnset, lrintf(m_inputSampleRate)));
456 (m_currentOnset, lrintf(m_inputSampleRate))); 441 feature.hasDuration = false;
457 feature.hasDuration = false;
458 } else {
459 feature.hasDuration = true;
460 feature.duration = offTime - m_currentOnset;
461 }
462 442
463 feature.values.push_back(m_currentLevel); 443 feature.values.push_back(m_currentLevel);
464 fs[0].push_back(feature); 444 fs[0].push_back(feature);
465 } 445 }
466 446