2013-04-26 21 views
1

我想創建一個處理應用程序,它能夠從樂器(吉他)中檢測音符。例如,如果播放打開的「A」音符,我想根據該音符進行操作,例如在屏幕上顯示音符或顯示圖像。注意檢測與處理和最小

我被卡住了,不確定我是否正確地做了或者如何繼續。據我所知,我需要獲得基本頻率?如果是這樣,我該如何得到它?看起來就像現在我在演奏音符時,隨着音符的進展,草圖顯示了一系列不同的頻率。我應該只是試圖獲得音符的開始或什麼?

如果你不能告訴,I'lm對於新手,所以要溫柔;)這是我到目前爲止有:

/* 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(); 
} 
+0

我認爲你需要做一些關於基音檢測的基礎知識的更多研究。嘗試維基百科,SO或其他問題,或這篇博文:http://blog.bjornroche.com/2012/07/frequency-detection-using-fft-aka-pitch.html – 2013-04-26 16:50:14

+0

謝謝比約恩。這看起來像一篇很棒的文章。我會閱讀它並嘗試儘可能多地學習理論。但是我不用C編碼。有沒有什麼建議可以讓我在這個處理過程中向前邁進? – 2013-04-26 17:16:00

+0

這篇文章中的C代碼示例與您在Java/Processing中做的任何事情非常相似,並且概念是相同的。 – 2013-04-26 20:15:29

回答

2

不要使用吉他的音調估計裸FFT。甚至是一個窗口的。不要使用上面的bjorneroche博客文章。

對於主要由泛音組成的聲音(如大多數音樂中發現的聲音),FFT峯值檢波器的工作效果很差。改爲使用更強大的基音檢測/估計方法,例如RAPT,YAAPT,自相關變體,諧波產品譜或倒譜/倒譜方法。

+1

嗨Hotpaw2!你能給出一個處理特定的例子嗎?或者正在處理只是不是使用這個程序? – 2013-04-27 11:07:13