EZAudio:你如何分开的FFT窗口大小的缓冲区大小(渴望更高的频率点的分辨率)。 [英] EZAudio: How do you separate the buffersize from the FFT window size(desire higher frequency bin resolution).

查看:2293
本文介绍了EZAudio:你如何分开的FFT窗口大小的缓冲区大小(渴望更高的频率点的分辨率)。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

https://github.com/syedhali/EZAudio

我一直在使用这个语音库有成功的,但现在我想增加的读取麦克风数据的分辨率,这样的分辨率FFT或频率仓规模下降到10Hz。要做到这一点,我需要的,而不是8820的512一个缓冲区大小是麦克风和FFT窗口大小的缓冲区大小分开?我看不到的方式来分开吧。

I've been having success using this audio library, but now I'd like to increase the resolution of the microphone data that's read in, so that the FFT resolution, or frequency bin size goes down to 10Hz. To do that, I need a buffersize of 8820 instead of 512. Is the buffersize of the microphone and FFT windowing size separable? I can't see a way to separate it.

我如何设置音频流描述,以便它可以用较大的窗口计算FFT?

How do I set up the audio stream description, so that it can calculate the FFT with a larger window?

任何帮助将是非常美联社preciated。

Any help would be much appreciated.

推荐答案

感谢JAKET的建议。缓冲区是要走的路,这里是相同的功能我的工作实现现在可调FFT窗口:

Thanks Jaket for suggestion. Buffer is the way to go and here is my working implementation of that same function now with adjustable FFT window:

    -(void)microphone:(EZMicrophone *)microphone
            hasAudioReceived:(float **)buffer
            withBufferSize:(UInt32)bufferSize
            withNumberOfChannels:(UInt32)numberOfChannels {

dispatch_async(dispatch_get_main_queue(),^{

    [self.audioPlot updateBuffer:buffer[0] withBufferSize:bufferSize];

    // Decibel Calculation.
    float one       = 1.0;
    float meanVal   = 0.0;
    float tiny      = 0.1;
    vDSP_vsq(buffer[0], 1, buffer[0], 1, bufferSize);
    vDSP_meanv(buffer[0], 1, &meanVal, bufferSize);
    vDSP_vdbcon(&meanVal, 1, &one, &meanVal, 1, 1, 0);
    // Exponential moving average to dB level to only get continous sounds.
    float currentdb = 1.0 - (fabs(meanVal)/100);
    if (lastdbValue == INFINITY || lastdbValue == -INFINITY || isnan(lastdbValue)) {
        lastdbValue = 0.0;
    }
    dbValue =   ((1.0 - tiny)*lastdbValue) + tiny*currentdb;
    lastdbValue = dbValue;
    // NSLog(@"dbval:  %f",dbValue);
    //
    // Setup the FFT if it's not already setup
    int samplestoCopy = fmin(bufferSize, FFTLEN - _fftBufIndex);
    for ( size_t i = 0; i < samplestoCopy; i++ ) {
        _fftBuf[_fftBufIndex+i] = buffer[0][i];
    }
    _fftBufIndex        += samplestoCopy;
   _samplesRemaining    -= samplestoCopy;
    if (_fftBufIndex == FFTLEN) {
        if( !_isFFTSetup ){
            [self createFFTWithBufferSize:FFTLEN withAudioData:_fftBuf];
            _isFFTSetup = YES;
        }
        [self updateFFTWithBufferSize:FFTLEN withAudioData:_fftBuf];
        _fftBufIndex        = 0;
        _samplesRemaining   = FFTLEN;
    } 
});  

}

这篇关于EZAudio:你如何分开的FFT窗口大小的缓冲区大小(渴望更高的频率点的分辨率)。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆