Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法为android应用程序使用TarsosDSP解析符号_Java_Android_Audio_Tarsosdsp - Fatal编程技术网

Java 无法为android应用程序使用TarsosDSP解析符号

Java 无法为android应用程序使用TarsosDSP解析符号,java,android,audio,tarsosdsp,Java,Android,Audio,Tarsosdsp,这个问题真让我大吃一惊。我正在尝试从TarsosDSP音频库中实现StructionDetector类,但有点不对劲 这是我的代码: public class PercussionDetectionForTimer extends Timer { int SAMPLING_RATE=22050; int BUFFER_SIZE=1024; int BUFFER_OVERLAP=0; AudioDispatcher dispatcher = AudioDispatcherFactory.from

这个问题真让我大吃一惊。我正在尝试从TarsosDSP音频库中实现StructionDetector类,但有点不对劲

这是我的代码:

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,这很奇怪


感谢您的帮助

如果其他人有这个问题,我觉得这是不可能的,因为我觉得自己在发布这个答案时很笨,我会回答我自己的问题:

我忘了为整个过程声明一个方法,所以我在所有其他方法之外编写了所有代码。难怪它不起作用