Mercurial > hg > qm-vamp-plugins
changeset 6:d00c1bad7332
* Make BeatDetect ask for its input in the frequency domain -- it can be
a bit faster if the host does FFT using e.g. FFTW instead of our rather
slower implementation, and also this means we don't have to worry about
handling non-power-of-two FFT sizes.
* Updates to copyright notes &c
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Mon, 15 May 2006 12:07:44 +0000 |
parents | b033ac01902b |
children | 641ce27165bd |
files | plugins/BeatDetect.cpp plugins/BeatDetect.h plugins/TonalChangeDetect.cpp |
diffstat | 3 files changed, 23 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/BeatDetect.cpp Fri Apr 14 09:38:09 2006 +0000 +++ b/plugins/BeatDetect.cpp Mon May 15 12:07:44 2006 +0000 @@ -67,7 +67,7 @@ string BeatDetector::getMaker() const { - return "Queen Mary, University of London"; + return "Christian Landone and Matthew Davies, Queen Mary, University of London"; } int @@ -161,7 +161,9 @@ size_t BeatDetector::getPreferredStepSize() const { - return size_t(m_inputSampleRate * m_stepSecs + 0.0001); + size_t step = size_t(m_inputSampleRate * m_stepSecs + 0.0001); + std::cerr << "BeatDetector::getPreferredStepSize: input sample rate is " << m_inputSampleRate << ", step size is " << step << std::endl; + return step; } size_t @@ -210,14 +212,25 @@ return FeatureSet(); } - // convert float* to double* - double *tempBuffer = new double[m_d->dfConfig.frameLength]; - for (size_t i = 0; i < m_d->dfConfig.frameLength; ++i) { - tempBuffer[i] = inputBuffers[0][i]; + size_t len = m_d->dfConfig.frameLength / 2; + + double *magnitudes = new double[len]; + double *phases = new double[len]; + + // We only support a single input channel + + for (size_t i = 0; i < len; ++i) { + + magnitudes[i] = sqrt(inputBuffers[0][i*2 ] * inputBuffers[0][i*2 ] + + inputBuffers[0][i*2+1] * inputBuffers[0][i*2+1]); + + phases[i] = atan2(-inputBuffers[0][i*2+1], inputBuffers[0][i*2]); } - double output = m_d->df->process(tempBuffer); - delete[] tempBuffer; + double output = m_d->df->process(magnitudes, phases); + + delete[] magnitudes; + delete[] phases; m_d->dfOutput.push_back(output);
--- a/plugins/BeatDetect.h Fri Apr 14 09:38:09 2006 +0000 +++ b/plugins/BeatDetect.h Mon May 15 12:07:44 2006 +0000 @@ -23,7 +23,7 @@ bool initialise(size_t channels, size_t stepSize, size_t blockSize); void reset(); - InputDomain getInputDomain() const { return TimeDomain; } + InputDomain getInputDomain() const { return FrequencyDomain; } std::string getName() const; std::string getDescription() const;
--- a/plugins/TonalChangeDetect.cpp Fri Apr 14 09:38:09 2006 +0000 +++ b/plugins/TonalChangeDetect.cpp Mon May 15 12:07:44 2006 +0000 @@ -81,7 +81,7 @@ std::string TonalChangeDetect::getMaker() const { - return "Martin Gasser"; + return "Martin Gasser and Christopher Harte, Queen Mary, University of London"; } int TonalChangeDetect::getPluginVersion() const