diff options
author | Robin Gareus <robin@gareus.org> | 2015-10-05 16:17:49 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2015-10-05 16:17:49 +0200 |
commit | 22b07e0233a29d9633ffa825a79503befaf2e16e (patch) | |
tree | 1d8b06056f8e12197158f5d906319767d3dedda5 /libs/qm-dsp/dsp/tonal | |
parent | e11ba7b79d68bc1070b170236c22123966d7bcc3 (diff) |
NOOP, remove trailing tabs/whitespace.
Diffstat (limited to 'libs/qm-dsp/dsp/tonal')
-rw-r--r-- | libs/qm-dsp/dsp/tonal/ChangeDetectionFunction.cpp | 34 | ||||
-rw-r--r-- | libs/qm-dsp/dsp/tonal/ChangeDetectionFunction.h | 2 | ||||
-rw-r--r-- | libs/qm-dsp/dsp/tonal/TCSgram.cpp | 4 | ||||
-rw-r--r-- | libs/qm-dsp/dsp/tonal/TCSgram.h | 2 | ||||
-rw-r--r-- | libs/qm-dsp/dsp/tonal/TonalEstimator.cpp | 20 | ||||
-rw-r--r-- | libs/qm-dsp/dsp/tonal/TonalEstimator.h | 22 |
6 files changed, 42 insertions, 42 deletions
diff --git a/libs/qm-dsp/dsp/tonal/ChangeDetectionFunction.cpp b/libs/qm-dsp/dsp/tonal/ChangeDetectionFunction.cpp index bcc661dd1d..a572da6ee8 100644 --- a/libs/qm-dsp/dsp/tonal/ChangeDetectionFunction.cpp +++ b/libs/qm-dsp/dsp/tonal/ChangeDetectionFunction.cpp @@ -34,20 +34,20 @@ ChangeDetectionFunction::~ChangeDetectionFunction() void ChangeDetectionFunction::setFilterWidth(const int iWidth) { m_iFilterWidth = iWidth*2+1; - + // it is assumed that the gaussian is 0 outside of +/- FWHM // => filter width = 2*FWHM = 2*2.3548*sigma m_dFilterSigma = double(m_iFilterWidth) / double(2*2.3548); m_vaGaussian.resize(m_iFilterWidth); - + double dScale = 1.0 / (m_dFilterSigma*sqrt(2*PI)); - + for (int x = -(m_iFilterWidth-1)/2; x <= (m_iFilterWidth-1)/2; x++) { double w = dScale * std::exp ( -(x*x)/(2*m_dFilterSigma*m_dFilterSigma) ); m_vaGaussian[x + (m_iFilterWidth-1)/2] = w; } - + #ifdef DEBUG_CHANGE_DETECTION_FUNCTION std::cerr << "Filter sigma: " << m_dFilterSigma << std::endl; std::cerr << "Filter width: " << m_iFilterWidth << std::endl; @@ -59,37 +59,37 @@ ChangeDistance ChangeDetectionFunction::process(const TCSGram& rTCSGram) { ChangeDistance retVal; retVal.resize(rTCSGram.getSize(), 0.0); - + TCSGram smoothedTCSGram; for (int iPosition = 0; iPosition < rTCSGram.getSize(); iPosition++) { int iSkipLower = 0; - + int iLowerPos = iPosition - (m_iFilterWidth-1)/2; int iUpperPos = iPosition + (m_iFilterWidth-1)/2; - + if (iLowerPos < 0) { iSkipLower = -iLowerPos; iLowerPos = 0; } - + if (iUpperPos >= rTCSGram.getSize()) { int iMaxIndex = rTCSGram.getSize() - 1; iUpperPos = iMaxIndex; } - + TCSVector smoothedVector; // for every bin of the vector, calculate the smoothed value for (int iPC = 0; iPC < 6; iPC++) - { + { size_t j = 0; double dSmoothedValue = 0.0; TCSVector rCV; - + for (int i = iLowerPos; i <= iUpperPos; i++) { rTCSGram.getTCSVector(i, rCV); @@ -98,7 +98,7 @@ ChangeDistance ChangeDetectionFunction::process(const TCSGram& rTCSGram) smoothedVector[iPC] = dSmoothedValue; } - + smoothedTCSGram.addTCSVector(smoothedVector); } @@ -109,10 +109,10 @@ ChangeDistance ChangeDetectionFunction::process(const TCSGram& rTCSGram) if the current estimate is not confident enough, look further into the future/the past e.g., High frequency content, zero crossing rate, spectral flatness */ - + TCSVector nextTCS; TCSVector previousTCS; - + int iWindow = 1; // while (previousTCS.magnitude() < 0.1 && (iPosition-iWindow) > 0) @@ -121,9 +121,9 @@ ChangeDistance ChangeDetectionFunction::process(const TCSGram& rTCSGram) // std::cout << previousTCS.magnitude() << std::endl; iWindow++; } - + iWindow = 1; - + // while (nextTCS.magnitude() < 0.1 && (iPosition+iWindow) < (rTCSGram.getSize()-1) ) { smoothedTCSGram.getTCSVector(iPosition+iWindow, nextTCS); @@ -136,7 +136,7 @@ ChangeDistance ChangeDetectionFunction::process(const TCSGram& rTCSGram) { distance += std::pow(nextTCS[j] - previousTCS[j], 2.0); } - + retVal[iPosition] = std::pow(distance, 0.5); } diff --git a/libs/qm-dsp/dsp/tonal/ChangeDetectionFunction.h b/libs/qm-dsp/dsp/tonal/ChangeDetectionFunction.h index 3a84b3096f..5d041ad769 100644 --- a/libs/qm-dsp/dsp/tonal/ChangeDetectionFunction.h +++ b/libs/qm-dsp/dsp/tonal/ChangeDetectionFunction.h @@ -38,7 +38,7 @@ public: ChangeDistance process(const TCSGram& rTCSGram); private: void setFilterWidth(const int iWidth); - + private: valarray<double> m_vaGaussian; double m_dFilterSigma; diff --git a/libs/qm-dsp/dsp/tonal/TCSgram.cpp b/libs/qm-dsp/dsp/tonal/TCSgram.cpp index c226c81402..954ba03e9b 100644 --- a/libs/qm-dsp/dsp/tonal/TCSgram.cpp +++ b/libs/qm-dsp/dsp/tonal/TCSgram.cpp @@ -55,7 +55,7 @@ void TCSGram::addTCSVector(const TCSVector& rTCSVector) std::pair<long, TCSVector> p; p.first = lMilliSeconds; p.second = rTCSVector; - + m_VectorList.push_back(p); } @@ -68,7 +68,7 @@ long TCSGram::getDuration() const void TCSGram::printDebug() { vectorlist_t::iterator vectorIterator = m_VectorList.begin(); - + while (vectorIterator != m_VectorList.end()) { vectorIterator->second.printDebug(); diff --git a/libs/qm-dsp/dsp/tonal/TCSgram.h b/libs/qm-dsp/dsp/tonal/TCSgram.h index 83e8c93f8b..f4825a996a 100644 --- a/libs/qm-dsp/dsp/tonal/TCSgram.h +++ b/libs/qm-dsp/dsp/tonal/TCSgram.h @@ -26,7 +26,7 @@ typedef std::vector<std::pair<long, TCSVector> > vectorlist_t; class TCSGram { -public: +public: TCSGram(); ~TCSGram(); void getTCSVector(int, TCSVector&) const; diff --git a/libs/qm-dsp/dsp/tonal/TonalEstimator.cpp b/libs/qm-dsp/dsp/tonal/TonalEstimator.cpp index 16d1aa8995..72b6f85c83 100644 --- a/libs/qm-dsp/dsp/tonal/TonalEstimator.cpp +++ b/libs/qm-dsp/dsp/tonal/TonalEstimator.cpp @@ -27,15 +27,15 @@ TonalEstimator::TonalEstimator() m_Basis.resize(6); int i = 0; - - + + // circle of fifths m_Basis[i].resize(12); for (int iP = 0; iP < 12; iP++) { m_Basis[i][iP] = std::sin( (7.0 / 6.0) * iP * PI); } - + i++; m_Basis[i].resize(12); @@ -43,17 +43,17 @@ TonalEstimator::TonalEstimator() { m_Basis[i][iP] = std::cos( (7.0 / 6.0) * iP * PI); } - + i++; - - + + // circle of major thirds m_Basis[i].resize(12); for (int iP = 0; iP < 12; iP++) { m_Basis[i][iP] = 0.6 * std::sin( (2.0 / 3.0) * iP * PI); } - + i++; m_Basis[i].resize(12); @@ -71,7 +71,7 @@ TonalEstimator::TonalEstimator() { m_Basis[i][iP] = 1.1 * std::sin( (3.0 / 2.0) * iP * PI); } - + i++; m_Basis[i].resize(12); @@ -90,7 +90,7 @@ TCSVector TonalEstimator::transform2TCS(const ChromaVector& rVector) { TCSVector vaRetVal; vaRetVal.resize(6, 0.0); - + for (int i = 0; i < 6; i++) { for (int iP = 0; iP < 12; iP++) @@ -98,6 +98,6 @@ TCSVector TonalEstimator::transform2TCS(const ChromaVector& rVector) vaRetVal[i] += m_Basis[i][iP] * rVector[iP]; } } - + return vaRetVal; } diff --git a/libs/qm-dsp/dsp/tonal/TonalEstimator.h b/libs/qm-dsp/dsp/tonal/TonalEstimator.h index 5753dff050..cfb8bba5b6 100644 --- a/libs/qm-dsp/dsp/tonal/TonalEstimator.h +++ b/libs/qm-dsp/dsp/tonal/TonalEstimator.h @@ -27,24 +27,24 @@ class ChromaVector : public std::valarray<double> public: ChromaVector(size_t uSize = 12) : std::valarray<double>() { resize(uSize, 0.0f); } - + virtual ~ChromaVector() {}; - + void printDebug() { for (int i = 0; i < size(); i++) { std::cout << (*this)[i] << ";"; } - + std::cout << std::endl; } - + void normalizeL1() { // normalize the chroma vector (L1 norm) double dSum = 0.0; - + for (size_t i = 0; i < 12; (dSum += std::abs((*this)[i++]))) ; for (size_t i = 0; i < 12; dSum > 0.0000001?((*this)[i] /= dSum):(*this)[i]=0.0, i++) ; @@ -55,7 +55,7 @@ public: for (size_t i = 0; i < 12; ++i) (*this)[i] = 0.0; } - + }; class TCSVector : public std::valarray<double> @@ -63,7 +63,7 @@ class TCSVector : public std::valarray<double> public: TCSVector() : std::valarray<double>() { resize(6, 0.0f); } - + virtual ~TCSVector() {}; void printDebug() @@ -72,19 +72,19 @@ public: { std::cout << (*this)[i] << ";"; } - + std::cout << std::endl; } - + double magnitude() const { double dMag = 0.0; - + for (size_t i = 0; i < 6; i++) { dMag += std::pow((*this)[i], 2.0); } - + return std::sqrt(dMag); } |