We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Ess syntax question (Read 562 times)
Ess syntax question
Apr 26th, 2007, 12:57am
 
Hi everyone..wondering if u can help. Can anyone explain in english whats going on in the line below That i have marked with a quote in uppercase and has stars above and below it.

// by Krister Olsson <http://www.tree-axis.com>

// Plays a stream from an Internet radio station in
// real-time

// Created 12 May 2006

import krister.Ess.*;

AudioStream myStream;
AudioFile myFile;

boolean songDone;

void setup() {
 size(256,200);

 // start up Ess
 Ess.start(this);
 
 // get ready to stream KCRW
 // (Ess.READ does not require a sample rate)
 myFile=new AudioFile("http://64.236.34.67/stream/1046",0,Ess.READ);

 // create a new AudioStream and set the sample rate
 myStream=new AudioStream(32*1024); // 32k samples
 myStream.sampleRate(myFile.sampleRate);

 myStream.start();

 framerate(30);
}

void draw() {
 background(0,0,255);

 // draw waveform
 int interp=(int)max(0,(((millis()-myStream.bufferStartTime)/(float)myStream.duration
)*myStream.size));

 for (int i=0;i<256;i++) {
   int top=50;



 ***************************************************  
   if (i+interp<myStream.buffer2.length) top-=(int)(myStream.buffer2[i+interp]*50.0);    

//THIS LINE  CAN ANYONE PLEASE EXPLAIN FROM AFTER THE "IF" STATEMENT.
*********************************************
   int j=0;
   for (int k=top;k<height;k++) {
     set(i,k,color(j,j,255));
     j=min(j+2,255);
   }
 }
}

void audioStreamWrite(AudioStream theStream) {
 // read the next chunk

 int samplesRead=myFile.read(myStream);
 if (samplesRead==0) {
   // start over

   myFile.close();
   myFile.open("http://www.tree-axis.com/temp/vindaloo.mp3",myStream.sampleRate,Ess.READ);

   samplesRead=myFile.read(myStream);
 }
}

// we are done, clean up Ess

public void stop() {
 Ess.stop();
 super.stop();
}



Can anyone help ?? thanks.

Page Index Toggle Pages: 1