Mercurial > hg > segmenter-vamp-plugin
changeset 67:37af1c80fb94
Don't allocate on stack, these frame sizes are large and the time saving irrelevant
author | Chris Cannam |
---|---|
date | Tue, 03 Dec 2013 11:13:58 +0000 |
parents | 96474fb2bbe6 |
children | e9e8b0f107df |
files | segmentino/Segmentino.cpp |
diffstat | 1 files changed, 12 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/segmentino/Segmentino.cpp Tue Dec 03 10:19:04 2013 +0000 +++ b/segmentino/Segmentino.cpp Tue Dec 03 11:13:58 2013 +0000 @@ -63,11 +63,6 @@ using std::cout; using std::endl; -#ifndef __GNUC__ -#include <alloca.h> -#endif - - // Result Struct typedef struct Part { int n; @@ -604,18 +599,18 @@ } const int fl = m_d->dfConfig.frameLength; -#ifndef __GNUC__ - double *dfinput = (double *)alloca(fl * sizeof(double)); -#else - double dfinput[fl]; -#endif + int sampleOffset = ((m_chromaFramesizeFactor-1) * fl) / 2; + double *dfinput = new double[fl]; + // Since chroma needs a much longer frame size, we only ever use the very // beginning of the frame for beat tracking. for (int i = 0; i < fl; ++i) dfinput[i] = inputBuffers[0][i]; double output = m_d->df->processTimeDomain(dfinput); + delete[] dfinput; + if (m_d->dfOutput.empty()) m_d->origin = timestamp; // std::cerr << "df[" << m_d->dfOutput.size() << "] is " << output << std::endl; @@ -638,19 +633,19 @@ // Window the full time domain, data, FFT it and process chroma stuff. - #ifndef __GNUC__ - float *windowedBuffers = (float *)alloca(m_chromadata->blockSize * sizeof(float)); - #else - float windowedBuffers[m_chromadata->blockSize]; - #endif + float *windowedBuffers = new float[m_chromadata->blockSize]; + m_chromadata->window.cut(&inputBuffers[0][0], &windowedBuffers[0]); // adjust timestamp (we want the middle of the frame) - timestamp = timestamp + Vamp::RealTime::frame2RealTime(sampleOffset, lrintf(m_inputSampleRate)); + timestamp = timestamp + + Vamp::RealTime::frame2RealTime(sampleOffset, lrintf(m_inputSampleRate)); m_chromadata->baseProcess(&windowedBuffers[0], timestamp); - + + delete[] windowedBuffers; } + m_pluginFrameCount++; FeatureSet fs;