import krister.Ess.*; AudioStream myStream; AudioFile myFile; //import moviemaker.*; //MovieMaker mm; final int W = 640; final int H = 480; int frame = 0; void setupSound() { // start up Ess Ess.start(this); // get ready to stream our radio station (KXJC) // (Ess.READ does not require a sample rate) myFile=new AudioFile("tempest_-_acidjazzed_evening.mp3",0,Ess.READ); // create a new AudioStream and set the sample rate myStream=new AudioStream(128*1024); // 128k buffer myStream.sampleRate(myFile.sampleRate); myStream.start(); } void setupGL() { tglViewport(0, 0, W, H); tglMatrixMode(TGL_PROJECTION); tglLoadIdentity(); tglFrustum(-1.0, 1.0, -0.75, 0.75, 1.0, 5.0); tglMatrixMode(TGL_MODELVIEW); tglLoadIdentity(); smooth(); tglPointSize(10.0); tglClearColor(0.2, 0.2, 0.2); } void setup() { size(640, 480); frameRate(30); //mm = new MovieMaker(this,width,height,"invtro2.mov", MovieMaker.JPEG, MovieMaker.HIGH,30); setupSound(); setupGL(); bernstein_setup(); setupScroller(); setupSineScroller(); setupBlubber(); } float[][] cube = { {-1, -1, -1}, { 1, -1, -1}, { 1, 1, -1}, {-1, 1, -1}, {-1, -1, 1}, { 1, -1, 1}, { 1, 1, 1}, {-1, 1, 1}, }; float i = 0; void draw_cube() { fill(#000000); stroke(#BC9A1E); tglMatrixMode(TGL_MODELVIEW); tglLoadIdentity(); tglTranslatef(cos(i*PI/180), sin(i*PI/180), -5 + 2*sin(0.5*i*PI/180)); i++; tglRotatef(i % 360, 0, 0, 1); tglRotatef(i % 360, 1, 1, 0); float scal = sin(i*PI/180/2); tglBegin(TGL_POINTS); /* for(int d = 0; d<8; ++d) { tglPushMatrix(); tglTranslatef(cube[d][0], cube[d][1], cube[d][2]); tglScalef(0.5, 0.5, 0.5); */ for(int c = 0; c<8; ++c) { tglPushMatrix(); tglTranslatef(cube[c][0], cube[c][1], cube[c][2]); for(int p = 0; p<8; ++p) { tglPushMatrix(); //tglScalef(0.5, 0.5, 0.5); tglScalef(scal,scal,scal); tglVertex3fv(cube[p]); tglPopMatrix(); } tglPopMatrix(); } /* tglPopMatrix(); }*/ tglEnd(); } void draw() { tglClear(TGL_COLOR_BUFFER_BIT); if(millis() < 3500) return; draw_blubber(); draw_cube(); //if(millis() > 5*1000) if(frame > 5*30) draw_scroller(); else rect(-1, H - bernstein_get_glyph_height() - 4, W+1, 50); //if(millis() > 30*1000) if(frame > 30*30) draw_sine_scroller(); //loadPixels(); //mm.addFrame(pixels,width, height); frame++; } /* public void mousePressed() { mm.finishMovie(); exit(); } */ void audioStreamWrite(AudioStream theStream) { // read the next chunk int samplesRead=myFile.read(myStream); } // we are done, clean up Ess public void stop() { Ess.stop(); super.stop(); }