# HG changeset patch # User Adam Stark # Date 1452425812 0 # Node ID 496d12635af80632a8b1d998106114b5341c009d # Parent 3b69082715ea342ce211fee1efb4bb508ced745e# Parent 5eeabb24d677fe55259e91a98992567081dc7507 Merge branch 'release/1.0.3' diff -r 3b69082715ea -r 496d12635af8 .gitignore --- a/.gitignore Tue Nov 25 23:00:13 2014 +0000 +++ b/.gitignore Sun Jan 10 11:36:52 2016 +0000 @@ -8,4 +8,5 @@ *.xcworkspace -modules-and-plug-ins/max-external/build \ No newline at end of file +modules-and-plug-ins/max-external/build +modules-and-plug-ins/python-module/build \ No newline at end of file diff -r 3b69082715ea -r 496d12635af8 README.md --- a/README.md Tue Nov 25 23:00:13 2014 +0000 +++ b/README.md Sun Jan 10 11:36:52 2016 +0000 @@ -1,7 +1,7 @@ BTrack - A Real-Time Beat Tracker ================================= -** Version 1.0.2 ** +** Version 1.0.3 ** *by Adam Stark, Matthew Davies and Mark Plumbley.* @@ -22,6 +22,11 @@ Versions -------- +==== 1.0.3 ==== (10th January 2016) + +* Fixed implementation error in complex spectral difference (thanks to @zbanks for pointing it out) +* Small change to python module build script + ==== 1.0.2 ==== (25th November 2014) * Added updated Max external project and associated files diff -r 3b69082715ea -r 496d12635af8 modules-and-plug-ins/python-module/setup.py --- a/modules-and-plug-ins/python-module/setup.py Tue Nov 25 23:00:13 2014 +0000 +++ b/modules-and-plug-ins/python-module/setup.py Sun Jan 10 11:36:52 2016 +0000 @@ -12,5 +12,5 @@ setup( name = 'BTrack', include_dirs = include_dirs, - ext_modules = [Extension(name, sources,libraries = ['fftw3','samplerate'])] + ext_modules = [Extension(name, sources,libraries = ['fftw3','samplerate'],library_dirs = ['/usr/local/lib'])] ) \ No newline at end of file diff -r 3b69082715ea -r 496d12635af8 src/OnsetDetectionFunction.cpp --- a/src/OnsetDetectionFunction.cpp Tue Nov 25 23:00:13 2014 +0000 +++ b/src/OnsetDetectionFunction.cpp Sun Jan 10 11:36:52 2016 +0000 @@ -435,10 +435,9 @@ //======================================================================= double OnsetDetectionFunction :: complexSpectralDifference() { - double dev,pdev; + double phaseDeviation; double sum; - double mag_diff,phase_diff; - double value; + double csd; // perform the FFT performFFT(); @@ -454,29 +453,14 @@ // calculate magnitude value magSpec[i] = sqrt(pow(complexOut[i][0],2) + pow(complexOut[i][1],2)); + // phase deviation + phaseDeviation = phase[i] - (2*prevPhase[i]) + prevPhase2[i]; - // phase deviation - dev = phase[i] - (2*prevPhase[i]) + prevPhase2[i]; - - // wrap into [-pi,pi] range - pdev = princarg(dev); - - - // calculate magnitude difference (real part of Euclidean distance between complex frames) - mag_diff = magSpec[i] - prevMagSpec[i]; - - // calculate phase difference (imaginary part of Euclidean distance between complex frames) - phase_diff = -magSpec[i]*sin(pdev); - - - - // square real and imaginary parts, sum and take square root - value = sqrt(pow(mag_diff,2) + pow(phase_diff,2)); - + // calculate complex spectral difference for the current spectral bin + csd = sqrt(pow(magSpec[i], 2) + pow(prevMagSpec[i], 2) - 2 * magSpec[i] * prevMagSpec[i] * cos(phaseDeviation)); // add to sum - sum = sum + value; - + sum = sum + csd; // store values for next calculation prevPhase2[i] = prevPhase[i]; @@ -490,10 +474,10 @@ //======================================================================= double OnsetDetectionFunction :: complexSpectralDifferenceHWR() { - double dev,pdev; + double phaseDeviation; double sum; - double mag_diff,phase_diff; - double value; + double magnitudeDifference; + double csd; // perform the FFT performFFT(); @@ -509,30 +493,22 @@ // calculate magnitude value magSpec[i] = sqrt(pow(complexOut[i][0],2) + pow(complexOut[i][1],2)); - - // phase deviation - dev = phase[i] - (2*prevPhase[i]) + prevPhase2[i]; - - // wrap into [-pi,pi] range - pdev = princarg(dev); - - - // calculate magnitude difference (real part of Euclidean distance between complex frames) - mag_diff = magSpec[i] - prevMagSpec[i]; - - // if we have a positive change in magnitude, then include in sum, otherwise ignore (half-wave rectification) - if (mag_diff > 0) - { - // calculate phase difference (imaginary part of Euclidean distance between complex frames) - phase_diff = -magSpec[i]*sin(pdev); - - // square real and imaginary parts, sum and take square root - value = sqrt(pow(mag_diff,2) + pow(phase_diff,2)); - - // add to sum - sum = sum + value; - } - + // phase deviation + phaseDeviation = phase[i] - (2*prevPhase[i]) + prevPhase2[i]; + + // calculate magnitude difference (real part of Euclidean distance between complex frames) + magnitudeDifference = magSpec[i] - prevMagSpec[i]; + + // if we have a positive change in magnitude, then include in sum, otherwise ignore (half-wave rectification) + if (magnitudeDifference > 0) + { + // calculate complex spectral difference for the current spectral bin + csd = sqrt(pow(magSpec[i], 2) + pow(prevMagSpec[i], 2) - 2 * magSpec[i] * prevMagSpec[i] * cos(phaseDeviation)); + + // add to sum + sum = sum + csd; + } + // store values for next calculation prevPhase2[i] = prevPhase[i]; prevPhase[i] = phase[i];