栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Android音频FFT使用音频记录检索特定频率幅度

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Android音频FFT使用音频记录检索特定频率幅度

首先,您需要确保将获得的结果正确转换为浮点数/双精度数。我不确定short []版本的工作方式,但是byte []版本仅返回原始字节版本。然后需要将此字节数组正确转换为浮点数。转换代码应如下所示:

    double[] micBufferData = new double[<insert-proper-size>];    final int bytesPerSample = 2; // As it is 16bit PCM    final double amplification = 100.0; // choose a number as you like    for (int index = 0, floatIndex = 0; index < bytesRecorded - bytesPerSample + 1; index += bytesPerSample, floatIndex++) {        double sample = 0;        for (int b = 0; b < bytesPerSample; b++) { int v = bufferData[index + b]; if (b < bytesPerSample - 1 || bytesPerSample == 1) {     v &= 0xFF; } sample += v << (b * 8);        }        double sample32 = amplification * (sample / 32768.0);        micBufferData[floatIndex] = sample32;    }

然后,使用micBufferData []创建输入复杂数组。

获得结果后,请在结果中使用复数的大小。除具有实际值的频率外,大多数量值应接近零。

您需要采样频率才能将数组索引转换为这样的幅度到频率:

private double ComputeFrequency(int arrayIndex) {    return ((1.0 * sampleRate) / (1.0 * fftOutWindowSize)) * arrayIndex;}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/366951.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号