处理 - 覆盖音频



是否可以使处理覆盖录制的文件?例如,代码录制十个音频文件,然后当它达到十个(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);      
    }
  }
}

你不能做这样的事情吗?

recID++;
if(recID >= maxRecordings){
   recID = 0;
}

相关内容

  • 没有找到相关文章

最新更新