2011-12-09 71 views
1

我從基於每秒鐘平均聲音分析的音頻文件中收集數據,我想知道是否有辦法加速它,因爲我不必聽在分析音頻的同時進行分析。 但我不知道處理的draw()循環是否可以讓我這樣做。此外,Minim庫似乎只能實時處理音頻,所以我問是否有人知道不同。處理中的快速聲音分析(最小庫)

回答

1

你看過Ess庫嗎?它看起來像AudioFile.read()方法可以讓你一次檢索所有的樣本。然後你可以按照你喜歡的任何大小處理它們。

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會給你足夠的數據?

0

使用ddf.minim.ugens.FilePlayer,並使用patch()與其他原因應用效果。在你的情況下,你可能會創建一個用於FFT輸入的ugen,然後是另一個將隨着時間推移而收到的所有輸入相加,並在完成時對其進行平均。這些必須擴展類ddf.minim.UGen