在 Android 中录制音频时的 VU(音频)表

发布于 2024-11-02 13:08:53 字数 272 浏览 1 评论 0原文

我是 Android 开发新手,对于我的第一个应用程序,我创建了一个允许录制音频的应用程序。录音和音频播放都正常。该应用程序缺少的一件事是在录制期间以 vu 表的形式向用户提供反馈。在iOS平台上,我相信有一个内置的vu表可以用于应用程序。我还没能在 Android 平台上找到类似的东西。

我一直在寻找各种专门用于 Android 开发的论坛并在谷歌上搜索,但我没有找到任何有用的东西。

有谁知道用于录制音频的数字 VU 表的编码示例吗?

有谁知道在录制时显示反馈的任何编码示例?

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 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

等风来 2024-11-09 13:08:53

您必须编写自己的 VU 表,但这并不难。

首先,获取最近一组音频样本的当前最大幅度。循环使用 AudioRecord 填充的缓冲区,并记下最高值。这几乎就是 MediaPlayer.getAmplitude 内部所做的事情。

现在您已经有了振幅,您只需绘制一根针或一个不断调整大小的矩形(其中高度= MAX_RECT_HEIGHT * curAmplitude / CONST_MAXIMUM_AMPLITUDE)或自定义视图的draw()方法中的任何内容。您必须研究峰值和衰减等,但这就是全部。

您可以在此处查看内置 VU 表动态壁纸的来源:VU米

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.

别挽留 2024-11-09 13:08:53

您是否看过此问题的答案:访问 Android 媒体流音频可视化

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文