Just realised how ridiculous my last post sounded. Mass confusion. Please 
ignore. Cheers, Connor. 

> On 18 Jun 2015, at 18:15, Connor Gettel <connorget...@me.com> wrote:
> 
> Hello Everyone,
> 
> Ross, Bjorn, Danny, Richard and Bogac, Thank you for your insightful feedback 
> and advice with my project. I haven’t had time to look over all the material 
> just yet, but i surely will over the next couple days. I’ve hit a bit wall 
> with one specific part of the code, this mainly comes down to syntax I think 
> and lack of experience with C. If anyone could tell me what i’m doing wrong 
> in this instance, please let me know if i’m on the right track.
> 
> inside the memory allocations in the main function I’ve got this line:
> 
> in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*N);
> 
> This is my input array, i need to fill it with data from portaudio’s 
> inputBuffer (I think). 
> 
> As far as I know the way to do this is to use the *userData Parameter of the 
> callbaack which is type void*.
> 
> So now I want to make ‘in’ the userData Parameter… i need to cast inside the 
> callback from double to void*, and then to float to match the inputBuffer… 
> I’ve done this with:
> 
> int i;
> double *in;
> in = malloc(sizeof(double));
> userData=(void*)in;
> userData=in;
> float *inp = (float*) inputBuffer, *fftbuffer = (float *) userData;
> for (i=0;i<framesPerBuffer;i++) *fftbuffer++ = *inp++;
> 
> So my thought process now is that inputBuffer should be feeding the fftbuffer 
> (which is the input array of the fft) with data… which means I can now 
> execute my plan… 
> 
> Compiling fine! Unfortunately i’m crashing. I’m pretty sure it’s because i’m 
> calling malloc in the callback. Which isn’t meant to be done (obviously). 
> 
> Question are:
> 1) Am I on the right track at all?
> 2) Is there a malloc free way to cast from double to void* ?
> 3) Am I right in thinking the ‘in’ is the FFT Buffer?
> 
> Cheers,
> 
> 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

Reply via email to