麦克风输入
我正在尝试构建一个使用 Android 检测手枪射击的小工具。它是手枪射击者训练辅助工具的一部分,可以告诉您射击如何及时分布,我使用 HTC Tattoo 进行测试。
我使用 MediaRecorder 及其 getMaxAmplitude 方法来获取最后 1/100 秒内的最高振幅,但它没有按预期工作;语音给我的 getMaxAmplitude 值范围为 0 到大约 25000,而手枪射击(或喊叫!)仅达到大约 15000。采样频率为 8kHz 时,应该有一些具有相当高电平的样本。
谁知道这些东西是如何工作的?在记录最大幅度之前是否应用了滤波器。如果是的话,是硬件还是软件?
谢谢, /乔治
I'm trying to build a gadget that detects pistol shots using Android. It's a part of a training aid for pistol shooters that tells how the shots are distributed in time and I use a HTC Tattoo for testing.
I use the MediaRecorder and its getMaxAmplitude method to get the highest amplitude during the last 1/100 s but it does not work as expected; speech gives me values from getMaxAmplitude in the range from 0 to about 25000 while the pistol shots (or shouting!) only reaches about 15000. With a sampling frequency of 8kHz there should be some samples with considerably high level.
Anyone who knows how these things work? Are there filters that are applied before registering the max amplitude. If so, is it hardware or software?
Thanks,
/George
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
似乎有一个 AGC(自动增益控制)滤波器。您还应该能够通过频率特征来识别镜头。我希望它能够出现在大部分可听频谱中,但是请使用频谱分析仪(应用程序市场上有一些分析仪,例如 SpectralView)并尝试通过其频率“特征”和幅度来识别事件。如果你拍手,你会得到最大振幅是多少?您也可以尝试用一些东西覆盖手机以消音,例如几层布
It seems there's an AGC (Automatic Gain Control) filter in place. You should also be able to identify the shot by its frequency characteristics. I would expect it to show up across most of the audible spectrum, but get a spectrum analyzer (there are a few on the app market, like SpectralView) and try identifying the event by its frequency "signature" and amplitude. If you clap your hands what do you get for max amplitude? You could also try covering the phone with something to muffle the sound like a few layers of cloth
好像AGC在媒体记录器中。当我使用 AudioRecord 时,我可以使用振幅来检测镜头,尽管它有时会对镜头以外的声音做出反应。这不是问题,因为射手在射击时通常不会发出任何其他噪音。
但我也会做一些 FFT 以使其完美:-)
It seems like AGC is in the media recorder. When I use AudioRecord I can detect shots using the amplitude even though it sometimes reacts on sounds other than shots. This is not a problem since the shooter usually doesn't make any other noise while shooting.
But I will do some FFT too to get it perfect :-)
听起来你已经解决了 agc 的问题了。进一步的建议:我不确定 FFT 是否适合这项工作。使用滑动功率估计器,您可能会获得更好的检测效果并降低 CPU 使用率。
例如
信号=>正方形=>移动平均线=>峰值检测
上述所有内容都可以使用定点数学非常有效地实现,这非常适合移动 Android 平台。
您可以通过搜索“帕塞瓦尔定理”和“CIC 滤波器”(级联积分器梳)找到更多信息
Sounds like you figured out your agc problem. One further suggestion: I'm not sure the FFT is the right tool for the job. You might have better detection and lower CPU use with a sliding power estimator.
e.g.
signal => square => moving average => peak detection
All of the above can be implemented very efficiently using fixed point math, which fits well with mobile android platforms.
You can find more info by searching for "Parseval's Theorem" and "CIC filter" (cascaded integrator comb)
抱歉回复晚了;直到我开始寻找不同的问题时我才看到这个问题...
我已经启动了一个应用程序来执行我认为您正在尝试的操作。它是一个基于音频的单圈计时器(用于开始/停止记录的按钮,以及用于单圈设置的响亮音频噪音)。它尚未完成,但可能为您提供一个良好的入门基础。
现在,它允许您监控来自麦克风的信号音量,并设置环境噪音量。它还使用新的 BSD 许可证,因此请随时查看此处的代码:http:// code.google.com/p/audio-timer/。它被设置为使用 1.5 API 来包含尽可能多的设备。
它还没有完成,因为它有两个主要问题:
我正在研究频率支持,但 Android 似乎没有办法找出支持哪些频率,而无需对每个设备进行反复试验。
我的本地开发机器上还有一些额外的代码来为列表视图项目创建布局以显示“圈”信息。但由于频率问题而偏离了方向。但由于显示和音频捕获已经基本完成,因此使用系统时间来填充计时信息的显示值应该相对简单,然后添加将数据表导出到SD 卡上的 CSV。
如果您想加入这个项目,或者有任何疑问,请告诉我。
Sorry for the late response; I didn't see this question until I started searching for a different problem...
I have started an application to do what I think you're attempting. It's an audio-based lap timer (button to start/stop recording, and loud audio noises for lap setting). It' not finished, but might provide you with a decent base to get started.
Right now, it allows you to monitor the signal volume coming from the mic, and set the ambient noise amount. It's also using the new BSD license, so feel free to check out the code here: http://code.google.com/p/audio-timer/. It's set up to use the 1.5 API to include as many devices as possible.
It's not finished, in that it has two main issues:
I'm looking into the frequency support, but Android doesn't seem to have a way to find out which frequencies are supported without trial and error per-device.
I also have on my local dev machine some extra code to create a layout for the listview items to display "lap" information. Got sidetracked by the frequency problem though. But since the display and audio capture are pretty much done, using the system time to fill in the display values for timing information should be relatively straightforward, and then it shouldn't be too difficult to add the ability to export the data table to a CSV on the SD card.
Let me know if you want to join this project, or if you have any questions.