1
因此,我正在处理音频的这个应用程序,并且我有一个包含所有要发送到声卡的数据的缓冲区。我想知道是否有人有任何建议,以此作为VU仪表的最佳方式?如果它有什么区别,我使用Java。我见过的大多数例子都是用于物理VU表。从音频缓冲区制作VU表
编辑:我需要弄清楚如何让音频缓冲区的容量在任何给定的点
因此,我正在处理音频的这个应用程序,并且我有一个包含所有要发送到声卡的数据的缓冲区。我想知道是否有人有任何建议,以此作为VU仪表的最佳方式?如果它有什么区别,我使用Java。我见过的大多数例子都是用于物理VU表。从音频缓冲区制作VU表
编辑:我需要弄清楚如何让音频缓冲区的容量在任何给定的点
什么我的回答确实很粗略计算缓冲区的绝对值的漏积分。 由于数字音频需要重现正反两方面的声压,通常50%的值是“关闭”的。如果你没有得到这个,请参阅关于数字音频的维基百科文章。
真正的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".
总计值通常以对数形式显示。