Mercurial > hg > nnls-chroma
comparison NNLSBase.cpp @ 76:d398e73b46e0 matthiasm-plugin
it's broken at the moment, work in progress (makeing bins per semitone variable, ie not necessarily 3)
author | Matthias Mauch <mail@matthiasmauch.net> |
---|---|
date | Wed, 10 Nov 2010 22:52:46 +0900 |
parents | 9a1f83057e84 |
children | ba930176df5b |
comparison
equal
deleted
inserted
replaced
75:ec5b599fbabc | 76:d398e73b46e0 |
---|---|
25 #include <cmath> | 25 #include <cmath> |
26 | 26 |
27 #include <algorithm> | 27 #include <algorithm> |
28 | 28 |
29 const bool debug_on = false; | 29 const bool debug_on = false; |
30 | |
31 const vector<float> hw(hammingwind, hammingwind+19); | |
32 | 30 |
33 NNLSBase::NNLSBase(float inputSampleRate) : | 31 NNLSBase::NNLSBase(float inputSampleRate) : |
34 Plugin(inputSampleRate), | 32 Plugin(inputSampleRate), |
35 m_logSpectrum(0), | 33 m_logSpectrum(0), |
36 m_blockSize(0), | 34 m_blockSize(0), |
351 NNLSBase::initialise(size_t channels, size_t stepSize, size_t blockSize) | 349 NNLSBase::initialise(size_t channels, size_t stepSize, size_t blockSize) |
352 { | 350 { |
353 if (debug_on) { | 351 if (debug_on) { |
354 cerr << "--> initialise"; | 352 cerr << "--> initialise"; |
355 } | 353 } |
354 | |
355 int hamwinlength = nBPS * 6 + 1; | |
356 float hamwinsum = 0; | |
357 for (int i = 0; i < hamwinlength; ++i) { | |
358 hw.push_back(0.54 - 0.46 * cos((2*M_PI*i)/(hamwinlength-1))); | |
359 hamwinsum += 0.54 - 0.46 * cos((2*M_PI*i)/(hamwinlength-1)); | |
360 } | |
361 for (int i = 0; i < hamwinlength; ++i) hw[i] = round(hw[i] / hamwinsum * 10000)*1.0/10000; | |
356 | 362 |
357 if (channels < getMinChannelCount() || | 363 if (channels < getMinChannelCount() || |
358 channels > getMaxChannelCount()) return false; | 364 channels > getMaxChannelCount()) return false; |
359 m_blockSize = blockSize; | 365 m_blockSize = blockSize; |
360 m_stepSize = stepSize; | 366 m_stepSize = stepSize; |