0

我正在根据每秒平均的声音分析从音频文件中收集数据,我想知道是否有办法加快速度,因为我在分析音频时不必听音频。但我不知道 Processing 特定的 draw() 循环是否可以让我这样做。此外,Minim 库似乎只实时处理音频,所以我问是否有人知道不同。

4

3 回答 3

1

你看过 Ess 图书馆吗?看起来 AudioFile.read() 方法可以让您一次检索所有样本。然后你可以用你喜欢的任何大小的块来处理它们。

于 2011-12-09T19:21:26.663 回答
0

在 Processing 附带的 ForwardFFT 示例中,fft.forward()每帧调用一次,因此没有什么可以阻止您fft.forward()在设置中多次调用该函数以获取数据。这是我在setup()ForwardFFT 示例中添加的内容以获取数据的方式:

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 会为您提供足够的数据吗?

于 2011-12-10T11:50:35.883 回答
0

使用ddf.minim.ugens.FilePlayer和 使用patch()其他 ugen 对其应用效果。在您的情况下,您可能会创建一个对输入进行 FFT 的 ugen,然后创建另一个将随着时间的推移接收到的所有输入相加并在完成后对它们进行平均的另一个。这些必须扩展类ddf.minim.UGen

于 2015-07-22T18:05:01.040 回答