Microphone input

前端 未结 4 522
庸人自扰
庸人自扰 2021-01-03 10:36

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 an

相关标签:
4条回答
  • 2021-01-03 11:01

    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:

    1. The audio capture doesn't currently work for emulated devices because of the unsupported frequency requested
    2. The timer functionality doesn't work yet - was focusing on getting the audio capture first.

    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.

    0 讨论(0)
  • 2021-01-03 11:06

    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)

    0 讨论(0)
  • 2021-01-03 11:15

    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

    0 讨论(0)
  • 2021-01-03 11:21

    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 :-)

    0 讨论(0)
提交回复
热议问题