title: JMF with Processing - audio visualizer
body: <p>I have this awesome audio visualizer created with Processing 2.0a5 with the minim library, which uses fft to analyze the audio data.</p>
  
  <pre><code>import ddf.minim.*;
  import ddf.minim.analysis.*;
  
  Minim minim;
  AudioPlayer song;
  FFT fft;
  
  int col=0; // color, oscillates over time.
  
  void setup()
  {
  size(498, 89);
  
  // always start Minim first!
  minim = new Minim(this);
  
  // specify 512 for the length of the sample buffers
  // the default buffer size is 1024
  song = minim.loadFile("obedear.mp3", 2048);
  
  song.play();
  
  // an FFT needs to know how
  // long the audio buffers it will be analyzing are
  // and also needs to know
  // the sample rate of the audio it is analyzing
  fft = new FFT(song.bufferSize(), song.sampleRate());
  
  
  }
  
  void draw()
  {
  colorMode(HSB);  
  background(0);
  // first perform a forward fft on one of song's buffers
  // I'm using the mix buffer
  // but you can use any one you like
  fft.forward(song.mix);
  col++;
  if (255&lt;col){col=0;} // loops the color
  strokeWeight(8);
  stroke(col, 255, 255);
  
  // draw the spectrum as a series of vertical lines
  // I multiple the value of getBand by 4
  // so that we can see the lines better
  for(int i = 0; i &lt; fft.specSize(); i++)
  {
  line(i-160, height, i-160, height - fft.getBand(i)*2);
  }
  
  
  }
  
  void stop()
  {
  song.close();
  minim.stop();
  
  super.stop();
  }
  </code></pre>
  
  <p>So now what I would like to do is import the song source via a url, like say from soundcloud. The url might look something like this - <a href="http://api.soundcloud.com/tracks/46893/stream?client_id=759a08f9fd8515cf34695bf3e714f74b" rel="nofollow">http://api.soundcloud.com/tracks/46893/stream?client_id=759a08f9fd8515cf34695bf3e714f74b</a> which returns a 128 kbps mp3 stream. I know that JMF 2.1 has support for a URLDataSource for streaming audio, but I'm not sure that JMF and processing/minim/fft will play nicely together. I am really new to java and still not totally familiar with the ins and outs. I'm used to php and html really. I also saw that Soundcloud has Soundmanager2 streaming integration in its javascript SDK. Not sure if this would offer any possible integration solutions.</p>
  
  <p>Ideally I would like to serve up a list of soundcloud songs to the user with php and html, and on click, I would like to play the song with my own visualizer, preferably the one I created in processing. I am having a real tough time trying to get this to work, and my ignorance with java definitely doesn't help. Any suggestions for the best way to make this happen, if it's even possible at all?</p>