首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从音频缓冲区制作VU计量器

从音频缓冲区制作VU计量器
EN

Stack Overflow用户
提问于 2012-02-02 07:20:25
回答 1查看 3K关注 0票数 2

所以我正在开发这个处理音频的应用程序,并且我有一个缓冲区,其中包含要发送到声卡的所有数据。我想知道是否有人有任何建议,作为VU的最好的绘制方法?如果有什么不同的话,那就是我正在使用Java。我见过的大多数例子都是针对物理VU的。

编辑:我需要弄清楚如何在任何给定的时间点获得音频缓冲区的音量

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-02-02 08:20:45

我的答案是非常粗略地计算缓冲区绝对值的泄漏积分。通常,50%的值是“关”的,因为数字音频需要再现正负声压。如果你不明白这一点,请参阅wikipedia上关于数字音频的文章。

真正的VU测量仪是信号幅度的泄漏积分器。(如果检流计或电子VU表芯片具有足够高的输入电阻,则一个简单的缓冲器和一个电容器就足够了)

因此,对于16位样本,代码可能如下所示……(从我的头顶)

代码语言:javascript
运行
复制
//set up
long total=0;
const long half = 32768; //2^(n-1)
const long decayInMilliseconds=30; // 30ms for the needle to fall back to zero.
// leak rate is enough to get the reported signal to decay to zero decayMilliseconds after 
// the actual amplitude goes to zero.
int leakRate = (sample_rate*1000 /decayInMilliseconds) * half; 


// goes in a loop to do the work
// can be executed on buffer-loads of data at less than the sampling rate, but the net number of calls to it persecond needs to equal the sampling rate.

int amplitude = buffer[i]-half;
total = total + abs(amplitude);
total = total - leakRate;
if( total > half) {
    total = half;
}
//total is the current "vu level".

total的值通常以对数刻度显示。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9104896

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档