【发布时间】:2011-12-09 16:50:24
【问题描述】:
我正在根据平均每秒的声音分析从音频文件中收集数据,我想知道是否有办法加快速度,因为我在分析音频时不必听音频。 但我不知道 Processing 特定的 draw() 循环是否可以让我这样做。此外,Minim 库似乎只实时处理音频,所以我想问是否有人知道不同。
【问题讨论】:
标签: audio analysis processing minim
我正在根据平均每秒的声音分析从音频文件中收集数据,我想知道是否有办法加快速度,因为我在分析音频时不必听音频。 但我不知道 Processing 特定的 draw() 循环是否可以让我这样做。此外,Minim 库似乎只实时处理音频,所以我想问是否有人知道不同。
【问题讨论】:
标签: audio analysis processing minim
你看过 Ess 库吗?看起来 AudioFile.read() 方法可以让您一次检索所有样本。然后你可以用你喜欢的任何大小的块来处理它们。
【讨论】:
在 Processing 附带的 ForwardFFT 示例中,fft.forward() 每帧调用一次,因此没有什么可以阻止您在设置中多次调用fft.forward() 函数来获取数据。以下是我在 ForwardFFT 示例的 setup() 中添加以获取数据的方式:
void setup()
{
size(512, 200);
minim = new Minim(this);
jingle = minim.loadFile("jingle.mp3", 2048);
jingle.loop();
// create an FFT object that has a time-domain buffer the same size as jingle's sample buffer
// note that this needs to be a power of two and that it means the size of the spectrum
// will be 512. see the online tutorial for more info.
fft = new FFT(jingle.bufferSize(), jingle.sampleRate());
println("fft analysis start");
int now = millis();
int trackLength = jingle.length();//length in millis
int trackSeconds= (int)trackLength/1000; //length in seconds
int specSize = fft.specSize(); //how many fft bands
float[][] fftData = new float[trackSeconds][specSize];//store fft bands here, for each time step
for(int t = 0 ; t < trackSeconds; t++){//time step in seconds
fft.forward(jingle.mix);//analyse fft
for(int b = 0; b < specSize; b++){//loop through bands
fftData[t][b] = fft.getBand(b);//store each band
}
}
println("fft analysis end, took: " + (millis()-now) + " ms");
textFont(createFont("SanSerif", 12));
windowName = "None";
}
不确定你想对数据做什么,但你确定每秒采样一次 FFT 会给你足够的数据吗?
【讨论】:
使用ddf.minim.ugens.FilePlayer,并使用patch() 将效果与其他 ugen 一起应用到它。在您的情况下,您可能会创建一个对输入进行 FFT 的 ugen,然后创建另一个将随着时间的推移接收到的所有输入相加并在完成后对它们进行平均的另一个。这些必须扩展类ddf.minim.UGen。
【讨论】: