I found myself doing the same thing a couple times, so I thought I'd whip up a quick library. It records all the action that happens in your applet, and dumps it to file. It can then play back that file. Being woefully unoriginal and lazy, I'm going just call it Camcorder.

So, say you're working on a Processing sketch where you're making a music visualization. You whip up something nice little applet with a bunch of boxes bouncing around and so-forth. It looks pretty good, but your computer's running at its limit just to keep the frame rate up. If you tried dumping the frames to disk on top of that, it would start to crawl. Let's also say there's a lot of randomness, so some takes are awesome, and other ones blow.

Your narcissism/need-to-see-cool-shit kicks in, and you want to make a movie of your awesome visualization. Because I'm me, let's also say you want to do it with P5Sunflow. Time to start writing the FFT bands to disk, right? Time to start writing way too much Java to read them back in, right?

Man. Screw that. Here's the way to do it now. We can even run through it a couple times until all the random parts look awesome.

import hipstersinc.camcorder.*;

void setup() {
  size(400, 400, P3D);
  new Camcorder(this, "/tmp/camcorder.dump");
}

void draw() {
  loadSamples();
  forwardFftMix();
  drawFftMix();
}
Copy/Paste

Fuck yeah! If you're thinking "Ain't no shit going to be able to track my code with no one line," then you need to go to bed. Computers for the win! HERE'S HOW COMPUTERS WILL PLAY BACK THIS FILE:

import hipstersinc.camcorder.*;

Camcorder cam;

void setup() {
  size(800, 600, "hipstersinc.P5Sunflow");
  cam = new Camcorder("/tmp/camcorder.dump");
}

void draw() {
  cam.play(this);
  addFrameToMovieOrWhatever();
}
Copy/Paste

There we go! That's not so bad! Now you have yourself a little four-line applet that'll play back any dump.

There's one more library I'm trying to finish that'll complete the libraries-that-help-me-write-the-code-that-will-help-me-get-a-job-that-doesn't-bore-me-to-tears trifecta. Here are some facts:

Also, Elliott Smith died four years ago today. What the fuck?