Mercurial > hg > vamp-tempogram
comparison TempogramPlugin.cpp @ 28:723af5b3303a
* Fixed tempogram via ACT bin names etc
author | Carl Bussey <c.bussey@se10.qmul.ac.uk> |
---|---|
date | Thu, 21 Aug 2014 11:07:20 +0100 |
parents | ff6110f1144b |
children | 1ad47a9afc2e |
comparison
equal
deleted
inserted
replaced
27:a3a37c8dcee7 | 28:723af5b3303a |
---|---|
25 m_tempogramHopSize(pow((float)2,m_tempogramLog2HopSize)), | 25 m_tempogramHopSize(pow((float)2,m_tempogramLog2HopSize)), |
26 m_tempogramMinBPM(30), //parameter | 26 m_tempogramMinBPM(30), //parameter |
27 m_tempogramMaxBPM(480), //parameter | 27 m_tempogramMaxBPM(480), //parameter |
28 m_tempogramMinBin(0), //set in initialise() | 28 m_tempogramMinBin(0), //set in initialise() |
29 m_tempogramMaxBin(0), //set in initialise() | 29 m_tempogramMaxBin(0), //set in initialise() |
30 m_tempogramMinLag(0), | |
31 m_tempogramMaxLag(0), | |
30 m_cyclicTempogramMinBPM(30), //reset in initialise() | 32 m_cyclicTempogramMinBPM(30), //reset in initialise() |
31 m_cyclicTempogramNumberOfOctaves(0), //set in initialise() | 33 m_cyclicTempogramNumberOfOctaves(0), //set in initialise() |
32 m_cyclicTempogramOctaveDivider(30) //parameter | 34 m_cyclicTempogramOctaveDivider(30) //parameter |
33 | 35 |
34 // Also be sure to set your plugin parameters (presumably stored | 36 // Also be sure to set your plugin parameters (presumably stored |
360 d3.identifier = "tempogramACT"; | 362 d3.identifier = "tempogramACT"; |
361 d3.name = "Tempogram via ACT"; | 363 d3.name = "Tempogram via ACT"; |
362 d3.description = "Tempogram via ACT"; | 364 d3.description = "Tempogram via ACT"; |
363 d3.unit = "BPM"; | 365 d3.unit = "BPM"; |
364 d3.hasFixedBinCount = true; | 366 d3.hasFixedBinCount = true; |
365 d3.binCount = m_tempogramMaxBin - m_tempogramMinBin + 1; | 367 d3.binCount = m_tempogramMaxLag - m_tempogramMinLag + 1; |
366 d3.hasKnownExtents = false; | 368 d3.hasKnownExtents = false; |
367 d3.isQuantized = false; | 369 d3.isQuantized = false; |
368 d3.sampleType = OutputDescriptor::FixedSampleRate; | 370 d3.sampleType = OutputDescriptor::FixedSampleRate; |
369 d_sampleRate = tempogramInputSampleRate/m_tempogramHopSize; | 371 d_sampleRate = tempogramInputSampleRate/m_tempogramHopSize; |
370 d3.sampleRate = d_sampleRate > 0.0 && !isnan(d_sampleRate) ? d_sampleRate : 0.0; | 372 d3.sampleRate = d_sampleRate > 0.0 && !isnan(d_sampleRate) ? d_sampleRate : 0.0; |
371 for(int i = m_tempogramMinBin; i <= (int)m_tempogramMaxBin; i++){ | 373 for(int lag = m_tempogramMaxLag; lag >= (int)m_tempogramMinLag; lag--){ |
372 float w = ((float)i/m_tempogramFftLength)*(tempogramInputSampleRate); | 374 d3.binNames.push_back(floatToString(60/(m_inputStepSize*(lag/m_inputSampleRate)))); |
373 d3.binNames.push_back(floatToString(w*60)); | |
374 } | 375 } |
375 d3.hasDuration = false; | 376 d3.hasDuration = false; |
376 list.push_back(d3); | 377 list.push_back(d3); |
377 | 378 |
378 OutputDescriptor d4; | 379 OutputDescriptor d4; |
472 //compute spectrogram from novelty curve data (i.e., tempogram) | 473 //compute spectrogram from novelty curve data (i.e., tempogram) |
473 Tempogram tempogramDFT = spectrogramProcessor.process(&noveltyCurve[0], numberOfBlocks, hannWindow); | 474 Tempogram tempogramDFT = spectrogramProcessor.process(&noveltyCurve[0], numberOfBlocks, hannWindow); |
474 delete []hannWindow; | 475 delete []hannWindow; |
475 hannWindow = 0; | 476 hannWindow = 0; |
476 | 477 |
477 AutocorrelationProcessor autocorrelationProcessor(m_tempogramWindowLength, m_tempogramHopSize); | |
478 Tempogram tempogramACT = autocorrelationProcessor.process(&noveltyCurve[0], numberOfBlocks); | |
479 | |
480 int tempogramLength = tempogramDFT.size(); | 478 int tempogramLength = tempogramDFT.size(); |
481 | 479 |
482 //push tempogram data to featureset 0 and set timestamps. | 480 //push tempogram data to featureset 0 and set timestamps. |
483 for (int block = 0; block < tempogramLength; block++){ | 481 for (int block = 0; block < tempogramLength; block++){ |
484 Feature tempogramDFTFeature; | 482 Feature tempogramDFTFeature; |
483 | |
484 assert(tempogramDFT[block].size() == (m_tempogramFftLength/2 + 1)); | |
485 for(int k = m_tempogramMinBin; k <= (int)m_tempogramMaxBin; k++){ | |
486 tempogramDFTFeature.values.push_back(tempogramDFT[block][k]); | |
487 } | |
488 tempogramDFTFeature.hasTimestamp = false; | |
489 featureSet[1].push_back(tempogramDFTFeature); | |
490 } | |
491 | |
492 AutocorrelationProcessor autocorrelationProcessor(m_tempogramWindowLength, m_tempogramHopSize); | |
493 Tempogram tempogramACT = autocorrelationProcessor.process(&noveltyCurve[0], numberOfBlocks); | |
494 | |
495 for (int block = 0; block < tempogramLength; block++){ | |
485 Feature tempogramACTFeature; | 496 Feature tempogramACTFeature; |
486 | 497 |
487 assert(tempogramDFT[block].size() == (m_tempogramFftLength/2 + 1)); | 498 for(int k = m_tempogramMaxLag; k >= (int)m_tempogramMinLag; k--){ |
488 for(int k = m_tempogramMinBin; k < (int)m_tempogramMaxBin; k++){ | |
489 tempogramDFTFeature.values.push_back(tempogramDFT[block][k]); | |
490 tempogramACTFeature.values.push_back(tempogramACT[block][k]); | 499 tempogramACTFeature.values.push_back(tempogramACT[block][k]); |
491 } | 500 } |
492 tempogramDFTFeature.hasTimestamp = false; | |
493 tempogramACTFeature.hasTimestamp = false; | 501 tempogramACTFeature.hasTimestamp = false; |
494 featureSet[1].push_back(tempogramDFTFeature); | |
495 featureSet[2].push_back(tempogramACTFeature); | 502 featureSet[2].push_back(tempogramACTFeature); |
496 } | 503 } |
497 | 504 |
498 //Calculate cyclic tempogram | 505 //Calculate cyclic tempogram |
499 vector< vector<unsigned int> > logBins = calculateTempogramNearestNeighbourLogBins(); | 506 vector< vector<unsigned int> > logBins = calculateTempogramNearestNeighbourLogBins(); |
570 m_tempogramMinBPM = 30; | 577 m_tempogramMinBPM = 30; |
571 m_tempogramMaxBPM = 480; | 578 m_tempogramMaxBPM = 480; |
572 } | 579 } |
573 | 580 |
574 float tempogramInputSampleRate = (float)m_inputSampleRate/m_inputStepSize; | 581 float tempogramInputSampleRate = (float)m_inputSampleRate/m_inputStepSize; |
575 m_tempogramMinBin = (max(floor(((m_tempogramMinBPM/60)/tempogramInputSampleRate)*m_tempogramFftLength), (float)0.0)); | 582 m_tempogramMinBin = (max((int)floor(((m_tempogramMinBPM/60)/tempogramInputSampleRate)*m_tempogramFftLength), 0)); |
576 m_tempogramMaxBin = (min(ceil(((m_tempogramMaxBPM/60)/tempogramInputSampleRate)*m_tempogramFftLength), (float)m_tempogramFftLength/2)); | 583 m_tempogramMaxBin = (min((int)ceil(((m_tempogramMaxBPM/60)/tempogramInputSampleRate)*m_tempogramFftLength), (int)(m_tempogramFftLength/2))); |
584 | |
585 m_tempogramMinLag = max((int)ceil((60/(m_inputStepSize * m_tempogramMaxBPM))*m_inputSampleRate), 0); | |
586 m_tempogramMaxLag = min((int)floor((60/(m_inputStepSize * m_tempogramMinBPM))*m_inputSampleRate), (int)m_tempogramWindowLength); | |
577 | 587 |
578 if (m_tempogramMinBPM > m_cyclicTempogramMinBPM) m_cyclicTempogramMinBPM = m_tempogramMinBPM; //m_cyclicTempogram can't be less than default = 30 | 588 if (m_tempogramMinBPM > m_cyclicTempogramMinBPM) m_cyclicTempogramMinBPM = m_tempogramMinBPM; //m_cyclicTempogram can't be less than default = 30 |
579 float cyclicTempogramMaxBPM = 480; | 589 float cyclicTempogramMaxBPM = 480; |
580 if (m_tempogramMaxBPM < cyclicTempogramMaxBPM) cyclicTempogramMaxBPM = m_tempogramMaxBPM; | 590 if (m_tempogramMaxBPM < cyclicTempogramMaxBPM) cyclicTempogramMaxBPM = m_tempogramMaxBPM; |
581 | 591 |