Android NDK - SoundTouch 中的模糊函数 fabs()
Android NDK - ambiguous function fabs() in SoundTouch
我正在尝试在 Android 中构建 SoundTouch 库。
我在 README 中按照 SoundTouch 本身编写的指南进行操作,但在构建它时仍然遇到此错误:
ct.cpp:238:32: error:
call to 'fabs' is ambiguous
xcorr[offs] += (float) fabs(sum);
这行代码在 BPMDetect.cpp
函数中:
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);
}
}
因为我知道 fabs()
函数包含在 math.h
库中,至少在 c 中,我检查了文件中导入的库如下:
#include <math.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>
仅供参考:由于长度原因,我决定不 post 所有代码,如果您需要它,请告诉我,我会立即 post。
您是否在 STTypes.h
中更改为 SOUNDTOUCH_INTEGER_SAMPLES
(16 位)?
在我的例子中,我对这个配置有同样的错误。
要解决这个问题,您可以尝试将 fabs 函数更改为 labs,因为 LONG_SAMPLETYPE
是 16 位的 long 类型。
我正在尝试在 Android 中构建 SoundTouch 库。
我在 README 中按照 SoundTouch 本身编写的指南进行操作,但在构建它时仍然遇到此错误:
ct.cpp:238:32: error:
call to 'fabs' is ambiguous
xcorr[offs] += (float) fabs(sum);
这行代码在 BPMDetect.cpp
函数中:
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);
}
}
因为我知道 fabs()
函数包含在 math.h
库中,至少在 c 中,我检查了文件中导入的库如下:
#include <math.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>
仅供参考:由于长度原因,我决定不 post 所有代码,如果您需要它,请告诉我,我会立即 post。
您是否在 STTypes.h
中更改为 SOUNDTOUCH_INTEGER_SAMPLES
(16 位)?
在我的例子中,我对这个配置有同样的错误。
要解决这个问题,您可以尝试将 fabs 函数更改为 labs,因为 LONG_SAMPLETYPE
是 16 位的 long 类型。