Mercurial > hg > svcore
diff 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 |
line wrap: on
line diff
--- a/transform/FeatureExtractionModelTransformer.cpp Wed Oct 15 17:02:48 2014 +0100 +++ b/transform/FeatureExtractionModelTransformer.cpp Fri Nov 14 13:51:33 2014 +0000 @@ -679,11 +679,17 @@ if (frequencyDomain) { for (int ch = 0; ch < channelCount; ++ch) { int column = (blockFrame - startFrame) / stepSize; - fftModels[ch]->getValuesAt(column, reals, imaginaries); - for (int i = 0; i <= blockSize/2; ++i) { - buffers[ch][i*2] = reals[i]; - buffers[ch][i*2+1] = imaginaries[i]; - } + if (fftModels[ch]->getValuesAt(column, reals, imaginaries)) { + for (int i = 0; i <= blockSize/2; ++i) { + buffers[ch][i*2] = reals[i]; + buffers[ch][i*2+1] = imaginaries[i]; + } + } else { + for (int i = 0; i <= blockSize/2; ++i) { + buffers[ch][i*2] = 0.f; + buffers[ch][i*2+1] = 0.f; + } + } error = fftModels[ch]->getError(); if (error != "") { cerr << "FeatureExtractionModelTransformer::run: Abandoning, error is " << error << endl;