From 60341ac292bb9ba6f1d33632f8fd8e767c6a99d4 Mon Sep 17 00:00:00 2001 From: mick grierson Date: Tue, 27 Oct 2015 17:05:12 +0000 Subject: clean up --- openFrameworks/ofxMaxim/libs/maxiMFCC.cpp | 79 +++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 openFrameworks/ofxMaxim/libs/maxiMFCC.cpp (limited to 'openFrameworks/ofxMaxim/libs/maxiMFCC.cpp') diff --git a/openFrameworks/ofxMaxim/libs/maxiMFCC.cpp b/openFrameworks/ofxMaxim/libs/maxiMFCC.cpp new file mode 100644 index 0000000..f180fb5 --- /dev/null +++ b/openFrameworks/ofxMaxim/libs/maxiMFCC.cpp @@ -0,0 +1,79 @@ +/* + * maxiMFCC.cpp + * mfccs + * + * Created by Chris on 08/03/2011. + * Copyright 2011 Goldsmiths Creative Computing. All rights reserved. + * + */ + +#include "maxiMFCC.h" + + +#ifdef __APPLE_CC__ +template <> +void maxiMFCCAnalyser::dct(double *mfccs) { + vDSP_mmulD(melBands, 1, dctMatrix, 1, mfccs, 1, 1, numCoeffs, numFilters); + double n = (double) numCoeffs; + vDSP_vsdivD(mfccs, 1, &n, mfccs, 1, numCoeffs); +} + +template <> +void maxiMFCCAnalyser::dct(float *mfccs) { + vDSP_mmul(melBands, 1, dctMatrix, 1, mfccs, 1, 1, numCoeffs, numFilters); + float n = (float) numCoeffs; + vDSP_vsdiv(mfccs, 1, &n, mfccs, 1, numCoeffs); +} +#endif + +template <> +void maxiMFCCAnalyser::melFilterAndLogSquare(float* powerSpectrum) { +#ifdef __APPLE_CC__ + //conv to double + vDSP_vspdp(powerSpectrum, 1, doubleSpec, 1, numBins); + // vDSP_mmulD(doubleSpec, 1, melFilters, 1, melBands, 1, 1, 42, 512); + vDSP_mmulD(doubleSpec, 1, melFilters, 1, melBands, 1, 1, numFilters, numBins); +#endif + melFilterAndLogSq_Part2(powerSpectrum); +} + + +template <> +void maxiMFCCAnalyser::melFilterAndLogSquare(float* powerSpectrum) { +#ifdef __APPLE_CC__ + vDSP_mmul(powerSpectrum, 1, melFilters, 1, melBands, 1, 1, numFilters, numBins); +#endif + melFilterAndLogSq_Part2(powerSpectrum); +} + +template +void maxiMFCCAnalyser::melFilterAndLogSq_Part2(float *powerSpectrum) { +#ifdef __APPLE_CC__ +#else + for (unsigned int filter = 0;filter < numFilters;filter++) { + melBands[filter] = 0.0; + for (unsigned int bin=0;bin 0.000001 ? log(melBands[filter] * melBands[filter]) : 0.0; + } +} + + + + + + + + + + + + -- cgit v1.3