I am collecting (sound) data and converting it to image, and recording as a movie. I want the drawing to exit at the left of the screen and redraw at the right, so it appears as a continuous stream.
I'm have some code that draws audio input as dots. It was written to save output as pages of image files (.pdf ) but I want it to save as a movie for as long as the sound runs. I followed instructions from
http://forum.processing.org/topic/record-code but Quicktime doesn't recognise the .mov file - and I think there is also a problem that the .mov file is written before the sound input ends.
import processing.video.*;
public int pn=0;
public String savename ="wakemovie-"; // << here is the name of the file
MovieMaker mm;
public boolean firstpass = true;
public int frate = 5; // <<-- here is the frameRate
public boolean inc = true; // always set to true this increments each frame
public boolean addmovframe = true; // this is used to save the quictktime video
public boolean dovid =false; //<< toggle this true or false to save pics
public boolean looponce = false; // if you want to just loop once set to true
public boolean snap = true; // toggle this to take a snap of the first frame
void saveget() {
setupvid();
if (dovid) {
if (inc) {
pn++;
}
save(savename+str(pn)+".png");
}
if (addmovframe) {
mm.addFrame();
}
if (looponce) {
noLoop();
exit();
} // Pressing the ESCape , ' key or ~ key will end the capture and the sketch
if (keyPressed ==true && ( key=='`' || key =='~' || key == ESC)) {
mm.finish();
exit();
}
}
void setupvid() {
if (firstpass)
{
mm = new MovieMaker(this, width, height, savename+".mov", frate,
MovieMaker.ANIMATION, MovieMaker.LOSSLESS);
if (snap) {
save("snap"+savename+str(pn)+".png");
}
firstpass = false;
}
}
void loop() {
saveget(); // toggle comment this to save video or run as normal
}
//////////
import krister.Ess.*;
AudioInput myChannel;
FFT myFFT;
void setup() {
size(screen.width,400);
background(255);
// start up Ess
Ess.start(this);
myChannel= new AudioInput();
myChannel.start();
// we want 256 frequency bands, so we pass 512
myFFT=new FFT(512/4);
// normalize the spectrum
myFFT.limits();
myFFT.equalizer(true);
// I want 20 averages
myFFT.averages(20);
}
int counter = 0;
int page_ctr= 0;
boolean REDRAW = false;
public void audioInputData(AudioInput input) {
myFFT.getSpectrum(input);
counter+=20.458; // 20 is the distance that it moves across each pass
if(counter>=width) {
counter = 0;
REDRAW = true;
}
}