PDA

View Full Version : Please help me with buffers in IPlug so I can do FFTs


metalhobo
04-10-2010, 08:32 PM
Sorry if these questions seem very newbish. I'm not very good with computers.

So I'm playing with buffer sizes in preparation for doing some noodling around with FFT. Right now I'm just playing around with ProcessDoubleReplacing (I'm sure I'm doing it completely wrong, as always) and getting an input buffer and ouput buffer initialized, but I've run into some issues.

void PlugExample::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
double* in1 = inputs[0];
double* in2 = inputs[1];
double* out1 = outputs[0];
double* out2 = outputs[1];

int fftbuffersize = 512;




WDL_FFT_COMPLEX fftbuffer [fftbuffersize];


for(int i = 0; i < fftbuffersize; i++, in1++){
fftbuffer[i].re = *in1;
}


for(int j = 0; j < fftbuffersize; j++, out1++){
*out1 = fftbuffer[j].re;
}


}

What I've found is with a buffer size of 512 it works like it should. it passes through only the left channel. However, when I set the buffer size to 1024, for some reason it passes both channels, like the plugin isn't even doing anything. At 2048 and higher it just crashes the DAW. I'm pretty sure I'm doing this completely wrong and would appreciate some help.

dub3000
04-10-2010, 11:58 PM
you can't assume the data coming in will be any particular buffer size - it can change every time you get called, and it won't necessarily even be a power of two (it can be as small as a single sample - check nFrames).

you have to store incoming data into a buffer. when your buffer has 512 samples in it, process them. make sure you're reporting a delay size of 512 samples (or whatever you end up using as your internal buffer size).

metalhobo
04-11-2010, 07:42 PM
edit: think I got it.

metalhobo
04-13-2010, 04:33 PM
Okay, got the buffers all squared away.

Now I have the real part of the signal stored, but I think I need to also do the phase shift to get the imaginary part. I think I need to a Hilbert transform, but I'm not sure how to do it discretely. Any tips?

cc_
04-15-2010, 12:52 AM
I haven't played with this yet, but as no one else has answered: I think the imaginary is part just set to 0 because real signals like audio don't have an imaginary component.