audio - IOS and FFT (vDSP_fft_zrip): frequencies below appr. 100 Hz are cut off - why? -


i'm using novocaine framework in order perform pitch detection. works - graphic fft representation, there troubles.

when use audio file input, fft works fine - frequencies below 100 hz shown perfectly.

instead when use mic input, frequencies below 100 hz not shown @ - can't figure out why! see screenshot below:

the higher frequencies (for example 1000 hz) correctly displayed!

here's source code fft procedure:

- (nsmutablearray*)performfft: (float*) data  withframes: (int) numsamples {      // 1. init      float buffersize = numsamples;      uint32_t maxframes = numsamples;      displaydata = (float*)malloc(maxframes*sizeof(float));      bzero(displaydata, maxframes*sizeof(float));      int log2n = log2f(maxframes);      int n = 1 << log2n;      assert(n == maxframes);      float nover2 = maxframes/2;                  a.realp = (float*)malloc(nover2 * sizeof(float));      a.imagp = (float*)malloc(nover2 * sizeof(float));      fftsetup = vdsp_create_fftsetup(log2n, fft_radix2);            // 2. calcuate      buffersize = numsamples;      float ln = log2f(numsamples);      vdsp_ctoz((complex*)data, 2, &a, 1, numsamples/2);            //fft      vdsp_fft_zrip(fftsetup, &a, 1, ln, fft_forward);            // absolute square (equivalent mag^2)      vdsp_zvmags(&a, 1, a.realp, 1, numsamples/2);      // make imaginary part 0 in order filter them out in following loop      bzero(a.imagp, (numsamples/2) * sizeof(float));            //convert complex split real      vdsp_ztoc(&a, 1, (complex*)displaydata, 2, numsamples/2);            // normalize      float scale = 1.f/displaydata[0];      vdsp_vsmul(displaydata, 1, &scale, displaydata, 1, numsamples);                  //scale fft      float32 mfftnormfactor = 1.0/(2*numsamples);      vdsp_vsmul(a.realp, 1, &mfftnormfactor, a.realp, 1, numsamples/2);      vdsp_vsmul(a.imagp, 1, &mfftnormfactor, a.imagp, 1, numsamples/2);    ...  }

for further graphical issues, use displaydata.

as i'm interested lower frequencies (there's separate pitch detection algorithm works fine), i've reduced sample rate 11.025 (instead of 44100).

within novocaine, make following calls:

1) input

[audiomanager setinputblock:^(float *data, uint32 numframes, uint32 numchannels) {                            // frequency analysis              vdsp_rmsqv(data, 1, &magnitude, numframes*numchannels);              self->ringbuffer->addnewinterleavedfloatdata(data, numframes, numchannels);  ...  }

2) output:

[audiomanager setoutputblock:^(float *data, uint32 numframes, uint32 numchannels)       {      self->ringbuffer->fetchinterleaveddata(data, numframes, numchannels);     ....     [fft performfft:data withframes:numframes];     ...     }

has got idea?

this because built-in microphone condenser mic , has high-pass filter remove dc bias on signal.

it possible disable hpf. dc bias isn't of issue, turn in bin #0 of fft.

[[avaudiosession sharedinstance] setmode: avaudiosessionmodemeasurement error:null]; 

also aware windowing fft affects accuracy of low-frequency bins of fft. need @ least 2*pi of samples in window given frequency.


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -