注意检测与处理和微小

时间:2013-04-26 15:11:44

标签: signal-processing processing minim

我正在尝试创建一个能够从乐器(吉他)中检测音符的处理应用程序。例如,如果播放打开的“A”音符,我想基于此做一些事情,比如在屏幕上显示音符或显示图像。

我被困住了,不确定我是做得对还是如何继续。根据我的理解,我需要获得基本频率?如果是这样,我该怎么做?好像我现在正在播放音符时,草图会随着音符的进展显示出一堆不同的频率。我本来应该只是试着得到这个音符的开头还是什么?

如果你不能说,我是一个新手,所以要温柔;)这是我到目前为止所拥有的:

/* sketch to measure frequencies */

import ddf.minim.analysis.*;
import ddf.minim.*;

Minim minim;
AudioInput in;
FFT fft;

void setup()

{
  size(512, 200, P3D);
  minim = new Minim(this);

  in = minim.getLineIn(Minim.STEREO, 2048);

  // 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(in.bufferSize(), 44100);
}

void draw()
{
  background(0);
  stroke(255);
  // perform a forward FFT on the audip that's coming in
  fft.forward(in.mix);
  for(int i = 0; i < fft.specSize(); i++)
  {
    // draw the line for frequency band i, scaling it by 4 so we can see it a bit better
    line(i, height, i, height - fft.getBand(i) * 4);
    //print out the frequency. Am I supposed to be multiplying the value by 2048?
    println( (fft.getFreq(i) * 2048)); 
  }

  fill(255);

}


void stop()
{
  // always close Minim audio classes when you finish with them
  in.close();
  minim.stop();
  super.stop();
}

1 个答案:

答案 0 :(得分:2)

不要使用裸FFT进行吉他音高估计。即使是一个窗口的。不要使用上面的bjorneroche博客文章。

FFT峰值检测器对于主要由泛音(例如在大多数音乐中找到)的声音的效果非常差。使用更强大的音调检测/估计方法,例如RAPT,YAAPT,自相关变体,谐波积频谱或倒谱/倒谱方法。