Other Parts Discussed in Thread: BOOSTXL-AUDIO,
Hello everyone,
I am using the BOOSTXL-Audio demo on the MSP430FR5994 to capture audio signals from an external microphone. After this, I calculate the FFT for these signals and then want to calculate some coefficients on the Mel Scale for my application. The code that I use for the Mel calculations is functional on the MSP430 and when in debugging, I can observe all the outputs correctly for every coefficient that is calculated. However, when I am running the code directly, it seems to execute endlessly and never terminates at any point. While I am using floating point operations as that is a bit unavoidable for the task, I do not face any issues with the calculations when in debugging mode. One consistent theme during the entire test is the following warning for different floating point operations: 1531-D: Detected floating point operations. Recommend moving them to RAM during run time as these are processing power intensive. My question is related to this statement. Is there a way in which I can specifically move all my floating point calculations to the RAM during run time? I have already tried creating a secondary RAM Partition and assigned all my global and static variables on to the new RAM partition - however, that ended in the same warning I mentioned above.
I am not completely sure if this is happening because the operations are too long or take up too much processing power - as they all execute correctly during the debugging. I am attaching my library here for reference. The 'lib_mfcc.c' is the main code file in which the entire calculations is carried out.
/* * libmfcc.c - Code implementation for libMFCC * Copyright (c) 2010 Jeremy Sawruk * * This code is released under the MIT License. * For conditions of distribution and use, see the license in LICENSE */ #include <math.h> #include "lib_mfcc.h" /* * Computes the specified (mth) MFCC * * spectralData - array of doubles containing the results of FFT computation. This data is already assumed to be purely real * samplingRate - the rate that the original time-series data was sampled at (i.e 44100) * NumFilters - the number of filters to use in the computation. Recommended value = 48 * binSize - the size of the spectralData array, usually a power of 2 * m - The mth MFCC coefficient to compute * */ double GetCoefficient(double* spectralData, unsigned int samplingRate, unsigned int NumFilters, unsigned int binSize, unsigned int m) { double result = 0.0f; double outerSum = 0.0f; double innerSum = 0.0f; unsigned int k, l; // 0 <= m < L if(m >= NumFilters) { // This represents an error condition - the specified coefficient is greater than or equal to the number of filters. The behavior in this case is undefined. return 0.0f; } result = NormalizationFactor(NumFilters, m); for(l = 1; l <= NumFilters; l++) { // Compute inner sum innerSum = 0.0f; for(k = 0; k < binSize - 1; k++) { innerSum += fabs(spectralData[k] * GetFilterParameter(samplingRate, binSize, k, l)); } if(innerSum > 0.0f) { innerSum = log(innerSum); // The log of 0 is undefined, so don't use it } innerSum = innerSum * cos(((m * PI) / NumFilters) * (l - 0.5f)); outerSum += innerSum; } result *= outerSum; return result; } /* * Computes the Normalization Factor (Equation 6) * Used for internal computation only - not to be called directly */ double NormalizationFactor(int NumFilters, int m) { double normalizationFactor = 0.0f; if(m == 0) { normalizationFactor = sqrt(1.0f / NumFilters); } else { normalizationFactor = sqrt(2.0f / NumFilters); } return normalizationFactor; } /* * Compute the filter parameter for the specified frequency and filter bands (Eq. 2) * Used for internal computation only - not the be called directly */ double GetFilterParameter(unsigned int samplingRate, unsigned int binSize, unsigned int frequencyBand, unsigned int filterBand) { double filterParameter = 0.0f; double boundary = (frequencyBand * samplingRate) / binSize; // k * Fs / N double prevCenterFrequency = GetCenterFrequency(filterBand - 1); // fc(l - 1) etc. double thisCenterFrequency = GetCenterFrequency(filterBand); double nextCenterFrequency = GetCenterFrequency(filterBand + 1); if(boundary >= 0 && boundary < prevCenterFrequency) { filterParameter = 0.0f; } else if(boundary >= prevCenterFrequency && boundary < thisCenterFrequency) { filterParameter = (boundary - prevCenterFrequency) / (thisCenterFrequency - prevCenterFrequency); filterParameter *= GetMagnitudeFactor(filterBand); } else if(boundary >= thisCenterFrequency && boundary < nextCenterFrequency) { filterParameter = (boundary - nextCenterFrequency) / (thisCenterFrequency - nextCenterFrequency); filterParameter *= GetMagnitudeFactor(filterBand); } else if(boundary >= nextCenterFrequency && boundary < samplingRate) { filterParameter = 0.0f; } return filterParameter; } /* * Compute the band-dependent magnitude factor for the given filter band (Eq. 3) * Used for internal computation only - not the be called directly */ double GetMagnitudeFactor(unsigned int filterBand) { double magnitudeFactor = 0.0f; if(filterBand >= 1 && filterBand <= 14) { magnitudeFactor = 0.015; } else if(filterBand >= 15 && filterBand <= 48) { magnitudeFactor = 2.0f / (GetCenterFrequency(filterBand + 1) - GetCenterFrequency(filterBand -1)); } return magnitudeFactor; } /* * Compute the center frequency (fc) of the specified filter band (l) (Eq. 4) * This where the mel-frequency scaling occurs. Filters are specified so that their * center frequencies are equally spaced on the mel scale * Used for internal computation only - not the be called directly */ double GetCenterFrequency(unsigned int filterBand) { double centerFrequency = 0.0f; double exponent; if(filterBand == 0) { centerFrequency = 0; } else if(filterBand >= 1 && filterBand <= 14) { centerFrequency = (200.0f * filterBand) / 3.0f; } else { exponent = filterBand - 14.0f; centerFrequency = pow(1.0711703, exponent); centerFrequency *= 1073.4; } return centerFrequency; }
Let me know if any other details are necessary. Thank you!
Regards,
Siddhant