import java.util.Calendar; int window_width = 400; int window_height = 400; String podcast_url; // = "http://www.podshow.com/feeds/relax.xml"; SoundBox sbox; SoundWorm worm; void setup() { try { podcast_url = getParameter("podcast_url"); } catch(Exception e) { podcast_url = ""; } size(window_width, window_height); // start ess Ess.start(this); // prepare radio stream sbox = new SoundBox(podcast_url); framerate(30); smooth(); //create sound worm worm = new SoundWorm(width / 2, height / 2, sbox); } void draw() { background(color(255,255,255)); worm.update(); worm.display(); } void audioStreamWrite(AudioStream theStream) { // read the next chunk int samplesRead = sbox.audio_file.read(sbox.audio_stream); if (samplesRead == 0) { // start over sbox.audio_file.close(); sbox.audio_file.open(sbox.audio_stream_url, sbox.audio_stream.sampleRate, Ess.READ); samplesRead = sbox.audio_file.read(sbox.audio_stream); } } // stop ess public void stop() { Ess.stop(); super.stop(); } void mousePressed() { if (mouseButton == LEFT) { sbox.playRandomSong(); } else { worm.randomizeColors(); } }