Question

I have this awesome audio visualizer created with Processing 2.0a5 with the minim library, which uses fft to analyze the audio data.

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<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 < fft.specSize(); i++)
{
line(i-160, height, i-160, height - fft.getBand(i)*2);
}


}

void stop()
{
song.close();
minim.stop();

super.stop();
}

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 - http://api.soundcloud.com/tracks/46893/stream?client_id=759a08f9fd8515cf34695bf3e714f74b 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.

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?

Was it helpful?

Solution

Holy sh@t! Minim's loadFile accepts direct urls, like the one I posted above as the filename param! I found the answer here: code.compartmental.net/tools/minim/manual-minim There was so many different documentation links I guess I missed "the manual". Anyway this is awesome. If anyone wants a cool java-based audio player and visualizer, feel free to steal mine (mostly openly avail code anyway).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top