有没有办法在录制声音时获得声音的分贝值?我现在MediaRecorder
用来录声音
我无法使用 Marketplace 上的任何应用程序,因为我无法确定用户是否会将其安装在他们的手机上,例如 Audalyzer
我正在使用以下公式,但不确定它们是否正确或我的结果是否正确!
short data[] = new short[bufferSize];
read = recorder.read(data, 0, bufferSize);
double p2 = data[data.length-1];
System.out.println("p2: " + p2);
double decibel;
if (p2==0)
decibel=Double.NEGATIVE_INFINITY;
else
decibel = 20.0*Math.log10(p2/65535.0);
System.out.println("p2/65535: " + (p2/65535.0));
System.out.println("decibel: " + decibel);
当前结果:
01-11 16:43:03.821: I/System.out(14530): p2: 0.0
01-11 16:43:03.821: I/System.out(14530): p2/65535: 0.0
01-11 16:43:03.821: I/System.out(14530): decibel: -Infinity
01-11 16:43:03.911: I/System.out(14530): p2: 0.0
01-11 16:43:03.911: I/System.out(14530): p2/65535: 0.0
01-11 16:43:03.911: I/System.out(14530): decibel: -Infinity
01-11 16:43:04.001: I/System.out(14530): p2: 0.0
01-11 16:43:04.001: I/System.out(14530): p2/65535: 0.0
01-11 16:43:04.001: I/System.out(14530): decibel: -Infinity
01-11 16:43:04.091: I/System.out(14530): p2: 0.0
01-11 16:43:04.091: I/System.out(14530): p2/65535: 0.0
01-11 16:43:04.091: I/System.out(14530): decibel: -Infinity
01-11 16:43:04.191: I/System.out(14530): p2: 0.0
01-11 16:43:04.191: I/System.out(14530): p2/65535: 0.0
01-11 16:43:04.191: I/System.out(14530): decibel: -Infinity
01-11 16:43:04.281: I/System.out(14530): p2: 0.0
01-11 16:43:04.281: I/System.out(14530): p2/65535: 0.0
01-11 16:43:04.281: I/System.out(14530): decibel: -Infinity
01-11 16:43:04.371: I/System.out(14530): p2: 0.0
01-11 16:43:04.371: I/System.out(14530): p2/65535: 0.0
01-11 16:43:04.371: I/System.out(14530): decibel: -Infinity