0

是否可以处理覆盖记录的文件?例如,代码记录十个音频文件,然后当它达到十个(rec9.wav)时,它会用新的音频覆盖第一个录音(rec0.wav),依此类推。下面的代码,任何帮助表示赞赏,谢谢!

import ddf.minim.*;

Minim minim;
AudioInput in;
AudioRecorder recorder;
AudioPlayer player;


int prevTime;
int delay = 10000; 
int recID = -1; //what to have a maximum of 10 ID's
int playID = 0;
boolean isRec = false;


void setup(){
  size(512, 200);
  minim = new Minim(this);
  in = minim.getLineIn(Minim.STEREO, 512);
  prevTime = millis();  
}

void draw(){
  if (millis() - prevTime > delay){
    prevTime = millis();  
    if(!isRec){
      if(recorder != null && recorder.isRecording()) recorder.endRecord();
        else{
        recID++;
        recorder = minim.createRecorder(in, "rec"+recID+".wav", true);
        recorder.beginRecord();
        }
          isRec = true;
          println("RECORDING");       
    }else{
      if(recorder != null) {
        recorder.endRecord();
        recorder.save();
        println("Done saving " + recID);
        player = minim.loadFile("rec"+recID+".wav", 2048);
        player.play();
        }
          isRec = false;
          println("SAVING REC " + recID);      
    }
  }
}
4

1 回答 1

0

你不能做这样的事情吗?

recID++;
if(recID >= maxRecordings){
   recID = 0;
}
于 2014-12-15T15:11:50.850 回答