我搜索类似的话题,但无法找到一个清晰,简明的答案。我一直在试图找出一种方法,我可以在给定的时间点判断分贝输出,而Android的媒体播放器正在播放。我不能找到一种方法来确定如何响亮的手机是在给定的时间点,当歌曲播放。我一直在寻找在媒体播放器API,但我想不通我怎么能得到读数在给定时间在一首歌曲播放。
I've searched similar topics but cannot find a clear and concise answer. I've been trying to figure out a way I could determine the decibel level output at a given point of time while the Android media player is being played. I cannot find a way to determine how loud the phone is at a given point in time when a song is being played. I've been looking over the media player API but I cannot figure out how I can get a reading at a given time during a song being played.
任何意见或帮助AP preciated。
Any ideas or help appreciated.
推荐答案
我认为你必须要录制音频,使用 MediaRecorder
:
I think you have to record audio to using MediaRecorder
:
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile("/dev/null");
mRecorder.prepare();
mRecorder.start();
public double getAmplitude() {
if (mRecorder != null)
return (mRecorder.getMaxAmplitude());
else
return 0;
}
要计算dB值:
To calculate Db value :
powerDb = 20 * log10(getAmplitude() / referenceAmp);
有共同选择的最大信号幅度的作为基准振幅。也就是说,我们规格化信号,使得最大振幅被定义为1,或0 dB的
It is common to choose the maximum signal magnitude as the reference amplitude. That is, we normalize the signal so that the maximum amplitude is defined as 1, or 0 dB
相关推荐
最新文章