Hello Connor,

If you just wanted to do a quick FFT and then using the spectrum to control
synthesis, then I would recommend staying in the callback. If you are doing
overlap-add then set framesPerBuffer to half your window size and combine
the current buffer with the previous buffer to feed into the FTT.

But if you are using the FFT to do complex analysis, or to drive a graphics
display, then that is probably too much for the callback. In that case just
set the callback pointer to NULL and use Pa_ReadStream() with a large
buffer size.

http://portaudio.com/docs/v19-doxydocs/portaudio_8h.html#a0b62d4b74b5d3d88368e9e4c0b8b2dc7

This decouples your code from the main audio processing. Then you can do
almost anything, including writing files or generating graphics displays.
You will probably need to create a separate thread that does the read and
the FFT.

Phil Burk


On Thu, Jun 11, 2015 at 7:20 AM, Connor Gettel <connorget...@me.com> wrote:

> Hello Everyone,
>
> My name’s Connor and I’m new to this mailing list. I was hoping somebody
> might be able to help me out with some FFT code.
>
> I want to do a spectral analysis of the mic input of my sound card. So far
> in my program i’ve got my main function initialising portaudio,
> inputParameters, outputParameters etc, and a callback function above
> passing audio through. It all runs smoothly.
>
> What I don’t understand at all is how to structure the FFT code in and
> around the callback as i’m fairly new to C. I understand all the steps of
> the FFT mostly in terms of memory allocation, setting up a plan, and
> executing the plan, but I’m still really unclear as how to structure these
> pieces of code into the program. What exactly can and can’t go inside the
> callback? I know it’s a tricky place because of timing etc…
>
> Could anybody please explain to me how i could achieve a real to complex 1
> dimensional DFT on my audio input using a callback?
>
> I cannot even begin to explain how grateful I would be if somebody could
> walk me through this process.
>
> I have attached my callback function code so far with the FFT code
> unincorporated at the very bottom below the main function (should anyone
> wish to have a look)
>
> I hope this is all clear enough, if more information is required please
> let me know.
>
> Thanks very much in advance!
>
> All the best,
>
> Connor.
>
>
>
> --
> dupswapdrop -- the music-dsp mailing list and website:
> subscription info, FAQ, source code archive, list archive, book reviews,
> dsp links
> http://music.columbia.edu/cmc/music-dsp
> http://music.columbia.edu/mailman/listinfo/music-dsp
>
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp 
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp

Reply via email to