用于进行声音检测,android端的声音检测程序,实时获取当前周围环境的声压级,也就是平常所说的分贝值 private Handler handler = new Handler() { @Override public void handleMessage(Message msg) { super.handleMessage(msg); if (this.hasMessages(msgWhat)) { return; } volume = mRecorder.getMaxAmplitude(); //获取声压值 if(volume > 0 && volume < 1000000) { World.setDbCount(20 * (float)(Math.log10(volume))); //将声压值转为分贝值 soundDiscView.refresh(); } handler.sendEmptyMessageDelayed(msgWhat, refreshTime); }};
评论