声级计机器人声级计、机器人

2023-09-05 04:48:03 作者:梦毁千百次

我想实现一个声音米分贝的Andr​​oid,但我还没有找到尚未启动的方式。我已经在机器人API,并没有发现任何东西,我认为是合适的。任何人都可以帮助我吗?

I'm trying to implement a sound meter in dB in android but I haven't found the way to start yet. I have gone over androids API and haven't found anything that I think is suitable. Can anyone help me please?

推荐答案

请尝试使用 AudioRecord 以记录音频到一个缓冲区,然后从原始PCM数据测量分贝的

Try using AudioRecord to record the audio to a buffer, then measure the dB's from the raw PCM data.

要初始化 AudioRecord

AudioRecord record = new AudioRecord(AudioSource.MIC, SAMPLING_RATE, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, bufferSize);

要由MIC读取样品

short[] buff = new short[8000];
record.read(buff, 0, buff.length); 
 
精彩推荐
图片推荐