这个问题真的让我很困惑。我正在尝试从 TarsosDSP 音频库中实现 percussionDetector 类,但有些不对劲......
这是我的代码:
public class PercussionDetectionForTimer extends Timer {
int SAMPLING_RATE=22050;
int BUFFER_SIZE=1024;
int BUFFER_OVERLAP=0;
AudioDispatcher dispatcher = AudioDispatcherFactory.fromDefaultMicrophone(SAMPLING_RATE,BUFFER_SIZE,BUFFER_OVERLAP);
OnsetHandler handler = new OnsetHandler() {
@Override
public void handleOnset(double time, double salience) {
runOnUiThread(new Runnable() {
@Override
public void run() {
//do stuff with result and audioevent
}
});
}
};
double sens = 0.8;
double threshold = 10;
PercussionOnsetDetector percussionDetector = new PercussionOnsetDetector(SAMPLING_RATE,BUFFER_SIZE,handler,sens,threshold);
dispatcher.addAudioDispatcher(percussionDetector);
dispatcher.start();
}
我从 Android Studio 收到以下错误消息:'无法解析符号'addAudioDispatcher()''
但是当我尝试在同一行调用该方法时,我声明了变量'dispatcher'没有这样的错误......可能有什么问题?
这就像Android Studio不会识别变量调度器,它只识别AudioDispatcher类,这很奇怪。
感谢所有帮助!