comparison transform/FeatureExtractionModelTransformer.cpp @ 1008:d9e0e59a1581

When using an aggregate model to pass data to a transform, zero-pad the shorter input to the duration of the longer rather than truncating the longer. (This is better behaviour for e.g. MATCH, and in any case the code was previously truncating incorrectly and ending up with garbage data at the end.)
author Chris Cannam
date Fri, 14 Nov 2014 13:51:33 +0000
parents 65494d0d9ded
children b14064bd1f97
comparison
equal deleted inserted replaced
1006:d954e03274e8 1008:d9e0e59a1581
677 // channelCount is either m_input.getModel()->channelCount or 1 677 // channelCount is either m_input.getModel()->channelCount or 1
678 678
679 if (frequencyDomain) { 679 if (frequencyDomain) {
680 for (int ch = 0; ch < channelCount; ++ch) { 680 for (int ch = 0; ch < channelCount; ++ch) {
681 int column = (blockFrame - startFrame) / stepSize; 681 int column = (blockFrame - startFrame) / stepSize;
682 fftModels[ch]->getValuesAt(column, reals, imaginaries); 682 if (fftModels[ch]->getValuesAt(column, reals, imaginaries)) {
683 for (int i = 0; i <= blockSize/2; ++i) { 683 for (int i = 0; i <= blockSize/2; ++i) {
684 buffers[ch][i*2] = reals[i]; 684 buffers[ch][i*2] = reals[i];
685 buffers[ch][i*2+1] = imaginaries[i]; 685 buffers[ch][i*2+1] = imaginaries[i];
686 } 686 }
687 } else {
688 for (int i = 0; i <= blockSize/2; ++i) {
689 buffers[ch][i*2] = 0.f;
690 buffers[ch][i*2+1] = 0.f;
691 }
692 }
687 error = fftModels[ch]->getError(); 693 error = fftModels[ch]->getError();
688 if (error != "") { 694 if (error != "") {
689 cerr << "FeatureExtractionModelTransformer::run: Abandoning, error is " << error << endl; 695 cerr << "FeatureExtractionModelTransformer::run: Abandoning, error is " << error << endl;
690 m_abandoned = true; 696 m_abandoned = true;
691 m_message = error; 697 m_message = error;