开发者

How to get volume from mic input

I'm 开发者_高级运维using the mic input (3.5mm) as a sort of analog to digital converter through the AudioRecord interface. I need to take a sample approximately every 1(worst case) to 3 (best case) milliseconds and measure the volume (relative voltage). Absolute voltage isn't really important as long as I can see the peak.

The problem is I know very little about audio. Can someone recommended how I setup my AudioRecord and buffers, like what size, etc?

Is it possible to observe the amplitude without using a FFT algorithm?

Thanks


Is this application real-time or are you going to record the waveform, store it and then look at it? For this answer, I have assumed that the processing will be done offline.

You need to take a sample every 1 - 3 milliseconds (worst to best case). If my calculations are not wrong, that would mean a sampling rate of 1000 - 333 Hz respectively. The sampling rate within android is constrained by the minimum sampling rate requirements of your encoder (output format). Looking at the supported audio/video formats, it does not seem like most of the formats would support a sampling rate of your choice. So, either you could try encoding in the wav format (it might have the sampling rate you need), or record the waveform in whatever format, downsample to your desired frequency range and then analyze.

Also, you can look at this application - Audalyzer for viewing waveforms.

And yes, you can look at the amplitude without getting an FFT, in fact, not FFT-ing the signal and viewing it just as it was recorded (in the time domain), is perhaps the best way to go.

HTH,
Sriram

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜