在使用来自 TarsosDSP 的 PercussionOnsetDetector 时,我无法获取振幅/分贝值。我到处进行了研究,但从我的搜索中没有发现任何与我的问题相关的东西。我在使用 TarsosDSP 时尝试过使用 MediaRecorder,但我在处理那个问题时遇到了问题。有没有办法解决这个问题?请告诉我。谢谢你。
这是我的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Checks Permission
checkPermission(Manifest.permission.RECORD_AUDIO,REQUEST_RECORD_AUDIO_PERMISSION);
pitchText = (TextView) findViewById(R.id.pitch);
counterText = (TextView) findViewById(R.id.note);
double threshold = 4.5;
double sensitivity = 45;
PercussionOnsetDetector mPercussionDetector = new PercussionOnsetDetector(22050, 1024,
new OnsetHandler() {
@Override
public void handleOnset(double time, double salience) {
runOnUiThread(new Runnable() {
@Override
public void run() {
counterText.setText("Counter: " + counter++);
}
});
}
}, sensitivity, threshold);
dispatcher.addAudioProcessor(mPercussionDetector);
new Thread(dispatcher,"Audio Dispatcher").start();
}