安卓音频处理与语音用户界面设计
音频处理相关技术
在音频处理领域,利用麦克风作为音频传感器有着广泛的应用。下面将介绍几种不同的音频处理方式及相关算法。
噪声拍手器改进
有一种噪声拍手器,它相较于之前的版本更加稳健。其代码如下:
@Override
public boolean heard(short[] data, int sampleRate)
{
boolean heard = false;
// use rms to take the entire audio signal into account
// and discount any one single high amplitude
double currentVolume = rootMeanSquared(data);
if (currentVolume > volumeThreshold)
{
Log.d(TAG, "heard");
heard = true;
}
return heard;
}
private double rootMeanSquared(short[] nums)
{
double ms = 0;
for (int i = 0; i < nums.length; i++)
{
ms += nums[i] * nums[i];
}
ms /= nums.length;
return Math.sqrt(ms);
}
超级会员免费看
订阅专栏 解锁全文
1804

被折叠的 条评论
为什么被折叠?



