Android NDK - ambiguous function fabs() in SoundTouch

283 Views Asked by At

I'm trying to build the SoundTouch library in Android.

I followed the guide written by SoundTouch itself within the README, still while building it I get this error:

ct.cpp:238:32: error: 
    call to 'fabs' is ambiguous
      xcorr[offs] += (float) fabs(sum);

this line of code is in BPMDetect.cpp whitin this function:

void BPMDetect::updateXCorr(int process_samples)
{
    int offs;
    SAMPLETYPE *pBuffer;

    assert(buffer->numSamples() >= (uint)(process_samples + windowLen));

    pBuffer = buffer->ptrBegin();

    // calculate decay factor for xcorr filtering
    float xcorr_decay = (float)pow(0.5, 1.0 / (xcorr_decay_time_constant * target_srate / process_samples));

    #pragma omp parallel for
    for (offs = windowStart; offs < windowLen; offs ++) 
    {
        LONG_SAMPLETYPE sum;
        int i;

        sum = 0;
        for (i = 0; i < process_samples; i ++) 
        {
            sum += pBuffer[i] * pBuffer[i + offs];    // scaling the sub-result shouldn't be necessary
        }
        xcorr[offs] *= xcorr_decay;   // decay 'xcorr' here with suitable time constant.

        xcorr[offs] += (float) fabs(sum);
    }
}

Since I know that the fabs() function is included within the math.h library, at least in c, I checked the libraries imported in the file which are the following:

#include <math.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>

FYI: I decided not to post all the code because of the length, If you need it though, let me know and I'll post it right away.

1

There are 1 best solutions below

1
On BEST ANSWER

Did you change to SOUNDTOUCH_INTEGER_SAMPLES (16 bits) in STTypes.h ?

In my case, I have the same error with this configuration.

To fix that, you can try to change fabs function to labs, because LONG_SAMPLETYPE is a long type in 16 bits.