Recording Multiple Audio Files

Hey all,

I'm working on a project that both plays back audio clips but allows users to press a button to record their own audio and another button to stop the recorder and save it. I'm working off of the minim recordAudio example and can't yet figure out how to create separate audio files for each time some one presses the stop recording button. Do I need to try to make multiple 'AudioRecorder's?

Here was my basic attempt at an array of AudioRecorders:

import ddf.minim.*;

Minim minim;
AudioInput in;
AudioRecorder[] recorder;

int n=0;
int MaxNumRecordings = 20;
void setup()
{
  size(512, 200, P3D);

  minim = new Minim(this);

  in = minim.getLineIn();

  for(n = 0; n<= MaxNumRecordings; n++){

  recorder[n] = minim.createRecorder(in, "myrecording" + n + ".wav", true);

  n++;

  }

  textFont(createFont("Arial", 12));
}

void draw()
{
  background(0); 
  stroke(255);

  for(int i = 0; i < in.bufferSize() - 1; i++)
  {
    line(i, 50 + in.left.get(i)*50, i+1, 50 + in.left.get(i+1)*50);
    line(i, 150 + in.right.get(i)*50, i+1, 150 + in.right.get(i+1)*50);
  }

  if ( recorder[n].isRecording() )
  {
    text("Currently recording...", 5, 15);
  }
  else
  {
    text("Not recording.", 5, 15);
  }
}

void keyReleased()
{
  if ( key == 'r' ) 
  {

    if ( recorder[n].isRecording() ) 
    {
      recorder[n].endRecord();
    }
    else 
    {
      recorder[n].beginRecord();
    }
  }
  if ( key == 's' )
  {

    recorder[n].save();
    println("Done saving.");

  }
}

thanks so much for your help!

All the best, mt

Sign In or Register to comment.