我有一个使用 Processing 2.0a5 和 minim 库创建的很棒的音频可视化工具,它使用 fft 分析音频数据。
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();
}
所以现在我想做的是通过 url 导入歌曲源,比如来自 soundcloud。网址可能看起来像这样 - http://api.soundcloud.com/tracks/46893/stream?client_id=759a08f9fd8515cf34695bf3e714f74b它返回一个 128 kbps 的 mp3 流。我知道 JMF 2.1 支持流式音频的 URLDataSource,但我不确定 JMF 和 processing/minim/fft 是否可以很好地协同工作。我真的是 java 的新手,仍然不完全熟悉它的来龙去脉。我真的习惯了 php 和 html。我还看到 Soundcloud 在其 javascript SDK 中集成了 Soundmanager2 流媒体。不确定这是否会提供任何可能的集成解决方案。
理想情况下,我想用 php 和 html 为用户提供一个 soundcloud 歌曲列表,点击后,我想用我自己的可视化工具播放歌曲,最好是我在处理过程中创建的可视化工具。我真的很难让它工作,而且我对 java 的无知肯定无济于事。对于实现这一目标的最佳方式有何建议(如果可能的话)?
最佳答案
天啊@t! Minim 的 loadFile 接受直接 url,就像我在上面作为文件名参数发布的那样!我在这里找到了答案:code.compartmental.net/tools/minim/manual-minim有这么多不同的文档链接,我想我错过了“手册”。无论如何,这太棒了。如果有人想要一个很酷的基于 Java 的音频播放器和可视化工具,请随意窃取我的(无论如何大部分都是公开使用的代码)。
关于java - JMF with Processing - 音频可视化工具,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10574678/