Converting AudioIn to a SoundFile

I’m making a audio recorder/saver, this is the code as of right now.

import processing.sound.*;
AudioIn audioIn;
int stage;
SoundFile segments[] = new SoundFile[10000];
void setup() {
  fullScreen();
  audioIn = new AudioIn(this, 0);
  audioIn.play();
}      

void draw() {
  background(0);
  segments[stage] = audioIn;
  stage++;
}

This code, of course, throws an error, due to the fact you can’t add an audioIn to a SoundFile.
Is there any way to convert an AudioIn to a SoundFile, PImage or String?