开发者

VU (Audio) Meter when Recording Audio in Android

开发者 https://www.devze.com 2023-02-27 03:42 出处:网络
I am new to Android development and for my first application I have created an application that allows for the recording of audio. The audio record is working as well as the audio playback. One thing

I am new to Android development and for my first application I have created an application that allows for the recording of audio. The audio record is working as well as the audio playback. One thing that is missing from the application is feedback to the user during recording in the form of a vu meter. On the iOS platform, I believe there is a built-in vu meter that can be used for applications. I have not been able to find an equivalent on the Android platform.

I have been looking on various forums dedicated to Android development and searching on google but I haven't found anything useful.

Does anyone know开发者_C百科 of any coding examples of a digital VU Meter for recording audio?

Does anyone know of any coding examples for showing feedback when a recording is being made?


You'll have to write your own VU meter, but it's not that hard.

First, get the current maximum amplitude of the most recent set of audio samples. Loop over the buffer you're filling with AudioRecord, and note the highest value. That's pretty much what MediaPlayer.getAmplitude does internally.

Now that you've got an amplitude, you simply draw a needle or a constantly resizing rectangle (where height = MAX_RECT_HEIGHT * curAmplitude / CONST_MAXIMUM_AMPLITUDE) or whatever in the draw() method of a custom view. You'll have to look into peaks and decays, etc, but that's all there is to it.

You can view the source for the built in VU meter live wallpaper here: VU meter.


Have you looked at the answers to this question: Accessing the Android media stream for audio visualization?

0

精彩评论

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

关注公众号