Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Minim play, record, save in sequenced loop

$
0
0

Can anyone help -I am new to processing and I am trying to create an experiment protocol which includes a part in the draw function that when called will loop through a sequence of play-> record ->save etc. until a set number of recorded files are saved.

This is part of a longer code so I have simplified it here to just the minim play/record issue, but it is why I am trying to keep the draw function clear.

Current Problems: 1. Record does not start at all. And in earlier iterations record was starting but when it tried to save there was an error. 2. I'm at a complete loss how to control the play->record->save loop for a set number of times before returning to the Draw function.

I hope someone can help -I've been trying for days now :/


import ddf.minim.*;
import ddf.minim.AudioPlayer;

Minim minim;
Minim record;
AudioInput In;

static final int SONG = 2;
final AudioPlayer[] audio = new AudioPlayer [SONG];

static final int RECORDED = 2;
final AudioRecorder[] recorder = new AudioRecorder [RECORDED];

int audioidx=0;
int recorderidx=0;
int saved;
static final int SAVED = 2;

 
void setup() {

  
  minim = new Minim(this);
  audio [0] = minim.loadFile ("Audio_01.mp3");
  audio [1] = minim.loadFile ("Audio_02.mp3");
  
  
  record = new Minim(this);
  In = record.getLineIn();
  recorder [0] = record.createRecorder(In, "myrecording0.wav");
  recorder [1] = record.createRecorder(In, "myrecording1.wav");
  
}
 
void draw() {
  playrecord();
}

void playrecord(){
  play();
  record();
}

void play(){
  audio[audioidx].play();
audioidx=audioidx+1;
}

void record(){  
  if (audio[audioidx].position() == audio[audioidx].length())
  {
    recorder[recorderidx].beginRecord();
    println ("recording");
  }
  
  if ( key == 's' && recorder[recorderidx].isRecording()){
    recorder[recorderidx].endRecord();
    recorder[recorderidx].save();
    println("Done saving.");
recorderidx=recorderidx+1;
  }
}


Viewing all articles
Browse latest Browse all 2896

Trending Articles