Skip to content

Commit

Permalink
make sure first sample is sentered in the fft window to fix start ofs…
Browse files Browse the repository at this point in the history
…et in key analysis.
  • Loading branch information
daschuer committed Jun 9, 2019
1 parent 8496c31 commit 169ca80
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/analyzer/plugins/buffering_utils.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
#include "analyzer/plugins/buffering_utils.h"

#include "util/math.h"
#include "util/sample.h"

#include <string.h>

namespace mixxx {

bool DownmixAndOverlapHelper::initialize(size_t windowSize, size_t stepSize, WindowReadyCallback callback) {
m_buffer.resize(windowSize);
memset(m_buffer.data(), 0, sizeof(m_buffer[0]) * windowSize);
m_callback = callback;
m_windowSize = windowSize;
m_stepSize = stepSize;
m_bufferWritePosition = 0;
// make sure the first frame is centered into the fft window. This makes sure
// that the result is significant starting fom the first step.
if (stepSize < windowSize) {
m_bufferWritePosition = windowSize / 2;
} else {
m_bufferWritePosition = 0;
}
return m_windowSize > 0 && m_stepSize > 0 &&
m_stepSize <= m_windowSize && callback;
}
Expand Down Expand Up @@ -57,4 +67,4 @@ bool DownmixAndOverlapHelper::finalize() {
return true;
}

}
}

0 comments on commit 169ca80

Please sign in to comment.