我正在根据每秒平均的声音分析从音频文件中收集数据,我想知道是否有办法加快速度,因为我在分析时不必听音频。 但我不知道Processing特有的draw()循环是否可以让我这样做。此外,Minim库似乎只是实时处理音频所以我问是否有人知道不同。
答案 0 :(得分:1)
你看过Ess图书馆吗?看起来AudioFile.read()方法可以让您一次检索所有样本。然后你可以用你喜欢的任何大小的块来处理它们。
答案 1 :(得分:0)
在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会为您提供足够的数据吗?
答案 2 :(得分:0)
使用ddf.minim.ugens.FilePlayer
,并使用patch()
对其他ugen应用效果。在您的情况下,您可以创建一个用于对输入进行FFT的ugen,然后创建另一个用于累计它随时间接收的所有输入的ugen,并在完成后对其进行平均。这些必须扩展类ddf.minim.UGen
。