Java &引用;意外标记:Void“;处理IDE时由于for循环而导致的错误(不考虑位置)?

Java &引用;意外标记:Void“;处理IDE时由于for循环而导致的错误(不考虑位置)?,java,audio,delay,void,processing-ide,Java,Audio,Delay,Void,Processing Ide,我目前正试图在处理IDE中编写一个简单的音频延迟草图。我不断收到指向Void Setup()函数的“意外标记:Void”错误。如果我注释掉这个for循环的内容: for (int i = 0; i < output.length; i++) { output[i] = (audioData[i]+audioData[i-44100]; } for(int i=0;i=delayData.length){ readHeadDelay=0; } } } 有人能帮忙吗?也

我目前正试图在处理IDE中编写一个简单的音频延迟草图。我不断收到指向Void Setup()函数的“意外标记:Void”错误。如果我注释掉这个for循环的内容:

for (int i = 0; i < output.length; i++)  
{  
    output[i] = (audioData[i]+audioData[i-44100];  
}
for(int i=0;i
然后这个错误就不会出现了。不管我把这个循环放在哪个函数中,这个错误都会发生,我也试着用其他的方法对它进行编码。运气不好

下面是给我带来麻烦的选项卡代码:

AudioThread audioThread;
// we'll use this to store the audio data we read from the audio file
float[] audioData;
float[] delayData;
// we'll use this to remember our position in the audio data array
float readHead;
float readHeadDelay;

void setup() {
    size(500, 400, P2D);
    // the audio file we want to play, which should be in the data dir
    String audioFilename = "myk_hats_dub1.wav";

    // read the audio data into a float array using the AudioFileIn class
    audioData = new AudioFileIn(audioFilename, this).getSampleData();
    delayData = new AudioFileIn(audioFilename, this).getSampleData();

    // print how many samples we read
    println("Read " + audioData.length + " samples");
    // set the read head to zero, the first sample
    readHead = 0;
    readHeadDelay = 44100;
    // start up the audio thread
    audioThread = new AudioThread();
    audioThread.start();
}

void draw() {
    background(255);
    fill(0);
}

// this function gets called when you press the escape key in the sketch
void stop() {
    // tell the audio to stop
    audioThread.quit();
    // call the version of stop defined in our parent class, in case it does
    // anything vital
    super.stop();
}

// this gets called by the audio thread when it wants some audio
// we should fill the sent buffer with the audio we want to send to the
// audio output
void generateAudioOut(float[] buffer) {

    for (int i = 0; i < buffer.length; i++) {

        // copy data from the audio we read from the file (audioData)
        // into the buffer that gets sent to the sound card
        buffer[i] = audioData[(int) readHead];

        // add a sample from the other array
        buffer[i] += delayData[(int) readHeadDelay];
        // scale it so it does not go over 1.0
        buffer[i] *= 0.5;

        // move the read head along one, resetting to zero
        // if it goes to the end of the audioData array
        readHead++;
        readHeadDelay++;
        if (readHead >= audioData.length) {
            readHead = 0;
        }
        if (readHeadDelay >= delayData.length) {
            readHeadDelay = 0;
        }
    }

}
AudioThread音频线程;
//我们将使用它来存储从音频文件读取的音频数据
音频数据;
浮动数据;
//我们将使用它来记住我们在音频数据阵列中的位置
浮动读头;
浮动读取延迟;
无效设置(){
尺寸(500、400、P2D);
//我们要播放的音频文件,应该在数据目录中
String audioFilename=“myk\u hats\u dub1.wav”;
//使用AudioFileIn类将音频数据读入浮点数组
audioData=newaudiofilein(audioFilename,this).getSampleData();
delayData=新的AudioFileIn(audioFilename,this).getSampleData();
//打印我们阅读的样本数量
println(“读取”+audioData.length+“样本”);
//将读取头设置为零,即第一个样本
readHead=0;
readHeadDelay=44100;
//启动音频线程
audioThread=新的audioThread();
audioThread.start();
}
作废提款(){
背景(255);
填充(0);
}
//在草图中按escape键时调用此函数
无效停止(){
//告诉音频停止
audioThread.quit();
//调用父类中定义的stop版本,以防
//有要紧的事吗
super.stop();
}
//当音频线程需要一些音频时,它会被调用
//我们应该用要发送到服务器的音频填充发送缓冲区
//音频输出
void generateAudiout(浮点[]缓冲区){
for(int i=0;i=audioData.length){
readHead=0;
}
if(readHeadDelay>=delayData.length){
readHeadDelay=0;
}
}
}

有人能帮忙吗?

也许你忘了用“')”合上括号


我看不到您给出的代码中的循环。

也许您忘了用“')”关闭括号


我在你给出的代码中没有看到循环。

你有一个未关闭的
你有一个未关闭的

查看
?它需要转到:)

查看
?它需要转到:)

output[i] = (audioData[i]+audioData[i-44100]; 
            ^