所以我正在开发这个处理音频的应用程序,并且我有一个缓冲区,其中包含要发送到声卡的所有数据。我想知道是否有人有任何建议,作为VU的最好的绘制方法?如果有什么不同的话,那就是我正在使用Java。我见过的大多数例子都是针对物理VU的。
编辑:我需要弄清楚如何在任何给定的时间点获得音频缓冲区的音量
发布于 2012-02-02 00:20:45
我的答案是非常粗略地计算缓冲区绝对值的泄漏积分。通常,50%的值是“关”的,因为数字音频需要再现正负声压。如果你不明白这一点,请参阅wikipedia上关于数字音频的文章。
真正的VU测量仪是信号幅度的泄漏积分器。(如果检流计或电子VU表芯片具有足够高的输入电阻,则一个简单的缓冲器和一个电容器就足够了)
因此,对于16位样本,代码可能如下所示……(从我的头顶)
//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的值通常以对数刻度显示。
https://stackoverflow.com/questions/9104896
复制相似问题