comparison Tempogram.cpp @ 8:4e429b9f2b4d

* Fixed memory leak bug. Issue with calculating size of spectrogram array. * Fixed bug in Tempogram::reset() where specData wasn't reinitialised.
author Carl Bussey <c.bussey@se10.qmul.ac.uk>
date Thu, 07 Aug 2014 17:25:24 +0100
parents 21147df9cb2d
children be59b4a73f49
comparison
equal deleted inserted replaced
7:21147df9cb2d 8:4e429b9f2b4d
267 { 267 {
268 // Clear buffers, reset stored values, etc 268 // Clear buffers, reset stored values, etc
269 cleanupForGRF(); 269 cleanupForGRF();
270 ncTimestamps.clear(); 270 ncTimestamps.clear();
271 specData.clear(); 271 specData.clear();
272 specData = vector< vector<float> >(m_blockSize/2 + 1);
272 } 273 }
273 274
274 Tempogram::FeatureSet 275 Tempogram::FeatureSet
275 Tempogram::process(const float *const *inputBuffers, Vamp::RealTime timestamp) 276 Tempogram::process(const float *const *inputBuffers, Vamp::RealTime timestamp)
276 { 277 {
277
278 size_t n = m_blockSize/2 + 1; 278 size_t n = m_blockSize/2 + 1;
279 279
280 FeatureSet featureSet; 280 FeatureSet featureSet;
281 Feature feature; 281 Feature feature;
282 282
335 } 335 }
336 336
337 WindowFunction::hanning(hannWindowtN, tN); 337 WindowFunction::hanning(hannWindowtN, tN);
338 Spectrogram * spectrogramProcessor = new Spectrogram(numberOfBlocks, tN, thopSize); 338 Spectrogram * spectrogramProcessor = new Spectrogram(numberOfBlocks, tN, thopSize);
339 vector< vector<float> > tempogram = spectrogramProcessor->audioToMagnitudeSpectrogram(&noveltyCurve[0], hannWindowtN); 339 vector< vector<float> > tempogram = spectrogramProcessor->audioToMagnitudeSpectrogram(&noveltyCurve[0], hannWindowtN);
340
341 cout << "About to delete..." << endl;
342 delete spectrogramProcessor; 340 delete spectrogramProcessor;
343 cout << "Deleted!" << endl;
344 spectrogramProcessor = NULL; 341 spectrogramProcessor = NULL;
345 342
346 int timePointer = thopSize-tN/2; 343 int timePointer = thopSize-tN/2;
347 int tempogramLength = tempogram[0].size(); 344 int tempogramLength = tempogram[0].size();
348 345
349 for (int block = 0; block < tempogramLength; block++){ 346 for (int block = 0; block < tempogramLength; block++){
350 Feature feature; 347 Feature feature;
351 348
352 int timeMS = floor(1000*(m_stepSize*timePointer)/m_inputSampleRate + 0.5); 349 int timeMS = floor(1000*(m_stepSize*timePointer)/m_inputSampleRate + 0.5);
353
354 cout << timeMS << endl;
355 350
356 for(int k = 0; k < tN/2 + 1; k++){ 351 for(int k = 0; k < tN/2 + 1; k++){
357 feature.values.push_back(tempogram[k][block]); 352 feature.values.push_back(tempogram[k][block]);
358 } 353 }
359 feature.hasTimestamp = true; 354 feature.hasTimestamp = true;