0

There are a few lines of code in this onset detection program that make use of the FFTW3 library which is difficult to incorporate into iOS. I would like to replace it using the Accelerate framework.

In onsetdshelpers.h there is a member variable:

fftwf_plan fftplan;

and then in onsetdshelpers.c there are a couple of malloc methods:

odsbuf->windoweddata = (float*) fftwf_malloc(framesizebytes);  
odsbuf->fftbuf       = (float*) fftwf_malloc(framesizebytes);

a method to instantiate fftplan

odsbuf->fftplan = fftwf_plan_r2r_1d(ods->fftsize, odsbuf->windoweddata, odsbuf->fftbuf, FFTW_R2HC, FFTW_ESTIMATE);

methods for releasing memory:

void onsetsds_destroy_audiodata(OnsetsDSAudioBuf *odsbuf){
    // take down the FFTW stuff
    fftwf_destroy_plan(odsbuf->fftplan);
    // free mem
    free(odsbuf->data);
    free(odsbuf->window);
    fftwf_free(odsbuf->windoweddata);
    fftwf_free(odsbuf->fftbuf);
}

and finally the method to actually execute the FFT:

fftwf_execute(odsbuf->fftplan);

My knowledge of C and FFTs is pretty limited. Any pointers to get me going in the right direction which be much appreciated.

Eric Brotto
  • 53,471
  • 32
  • 129
  • 174
  • What is it that you do not understand? If you want to know how FFT works, the Wikipedia article might be enough. If you want to understand how this specific implementation works, you might have to use the source. – HonkyTonk Jun 04 '12 at 15:50
  • @HonkyTonk It's just not clear. I am assuming I need to get an FFT on a buffer of audio, but it was difficult for me to find in the original library how they do it. – Eric Brotto Jun 04 '12 at 16:14
  • Read the data to be analyzed, put it into the allocated buffer, do the FFT call, done. Or am I missing something? The result from the call to the FFT function is most likely stored inside the `fftwf_plan` structure but you'll need to find out in which format. – HonkyTonk Jun 04 '12 at 16:19
  • 1
    Hot topic here: http://stackoverflow.com/questions/3398753/using-the-apple-fft-and-accelerate-framework – Viktor Latypov Jun 04 '12 at 18:59

0 Answers0