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() {
  audioIn = new AudioIn(this, 0);;

void draw() {
  segments[stage] = audioIn;

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?