Android Audio Analysis in Real-time

心已入冬 提交于 2019-12-02 19:29:41
Andrew Packer

Check out this code (ignore the playback part): Playing back sound coming from microphone in real-time

Basically the idea is that you will have to take the value of each 16-bit sample (which corresponds to the value of the wave at that time). Using the sampling rate, you can calculate the time between peaks in volume. I think that might accomplish what you want.

I think I have an easier way.

You could use the MediaRecorder 's getMaxAmplitude method.

Anytime your recorder detects a big jump in amplitude, you have detected a corn pop!

this may be a bit overkill, but there is a framework from MIT media labs called funf: http://code.google.com/p/funf-open-sensing-framework/
They already created classes for audio input and some analysis (FFT and the like), also saving to files or uploading is implemented as far as I've seen, and they handle most of the sensors available on the phone. You can also get inspired from the code they wrote, which I think is pretty good.

Dr. ABT

We've published an open source Android spectrum analyzer on Github here which computes FFT on an audio from the microphone and displays a 2D spectrogram.

You can see a video of it in action at https://youtu.be/yU05fsgOYO4

Critical code for reading the mic & computing the audio spectra is found at v2.x / ... sciShowcase / Viewmodels / AudioAnalyzer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!