如何从java中的麦克风获取dB(或任何类型的音量)级别?
如果我问的是已经问过的问题,我真的很抱歉,但我到处都找了,但什么也没有出现。
我正在尝试使用 java sound api 即时读取房间中当前的音量。我注意到我从麦克风混音器获得的控件对此没有帮助,从我所看到的来看,人们建议从 TargetDataLine 读取一小块声音并使用均方根算法检查音量。
实际问题 :) 问题是,每当我对样本运行 rms(我为此使用 PCM_SIGNED,44100Hz 16 位)时,当没有背景噪音时,我得到的值范围在 20-30 之间,而当我说话/大喊/说话时,我得到的值范围为 60。 (我尝试从大小为 100-44100 的缓冲区读取该行 缓冲区大小越小,有效值越低 - 但总体来说 - 安静约为 10,而大声噪音约为 30。)
事实是,当我播放刚刚录制的内容时,您可以完美地听到所有内容,并且没有背景噪音。
太长了;博士 谁能(请)告诉我一种从字节数组读数(PCM SIGNED 44100Hz 16bit)中判断音量的方法?
预先感谢所有回答的人!
i'm really sorry if i'm asking something already asked, but i looked everywhere and nothing came up.
i'm trying to do an on the fly read of the current volume of sound in the room using the java sound api. i noticed the controls i get from my microphone Mixer don't help with that and from what i've seen, people suggest reading a small chunk of sound from a TargetDataLine and checking volume with a Root Mean Square algorithm.
the actual question :)
problem is, whenever i run rms on a sample (i'm using PCM_SIGNED for this, 44100Hz 16bit), i get values ranging between 20-30 when there's no background noise and up to 60 when i speak/yell/talk.
(i tried having the line read from a buffer size of 100-44100
with smaller buffer sizes the rms is lower - but all over - quiet is around 10, and loud noise at around 30.)
thing is, when i play what i just recorded, you can hear everything perfectly, and no background noise.
tl;dr
can anyone (please) tell me of a way to tell the volume from a byte array reading(of PCM SIGNED 44100Hz 16bit)?
thank you in advance for whoever answers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有关 RMS,请参阅此回复。
See this reply for RMS.