我有用處理2.0a5與最小庫,它使用fft分析音頻數據創建這個令人敬畏的音頻可視化器。JMF與處理 - 音頻可視化器
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();
}
因此,現在我想要做的就是通過網址導入歌曲源,就像從soundcloud說的那樣。 url可能看起來像這樣 - http://api.soundcloud.com/tracks/46893/stream?client_id=759a08f9fd8515cf34695bf3e714f74b它返回一個128 kbps的mp3流。我知道JMF 2.1支持流式音頻的URLDataSource,但我不確定JMF和處理/ minim/fft會在一起播放。我對Java非常陌生,但仍不完全熟悉這些細節。我習慣於PHP和HTML。我還看到Soundcloud在其SDK SDK中具有Soundmanager2流式集成。不確定這是否會提供任何可能的集成解決方案。
理想情況下,我想用php和html爲用戶提供一份soundcloud歌曲列表,點擊後,我想用我自己的可視化工具播放歌曲,最好是我在處理過程中創建的歌曲。我正在努力實現這個目標,並且對java的無知毫無幫助。如果甚至有可能,最好的方法是什麼?
聖sh @ t! Minim的loadFile接受直接的url,就像我上面發佈的文件名參數一樣!我在這裏找到了答案:http://code.compartmental.net/tools/minim/manual-minim/ 有太多不同的文檔鏈接,我想我錯過了「手冊」。無論如何,這是真棒。如果有人想要一個酷酷的基於Java的音頻播放器和可視化工具,隨時可以偷我的(主要是公開可用的代碼)。 –