Editing FFT Data

my code:

float * data1 = buffer.getWritePointer(0);
float * data2 = buffer.getWritePointer(1);

int numsam = buffer.getNumSamples();
buffer.clear(1,0,numsam);
memcpy(fftData, data1, numsam * sizeof(float));
ForwardFFT.performRealOnlyForwardTransform(fftData);
for (int i = 0; i < numsam / 2; i++) {
	
	float re = fftData[2 * i];
	float im = fftData[(2 * i) + 1];
	mag[i] = std::sqrt((re*re) + (im * im));
	pha[i] = atan2(im,re);
	if (mag[i] < 100) {			
		mag[i] = 0;
	}
	re = mag[i] * cos(pha[i]);
	im = mag[i] * sin(pha[i]);

	fftData[2 * i] = re;
	fftData[(2 * i) + 1] = im;
}

ReverseFFT.performRealOnlyInverseTransform(fftData);
data1 = fftData;

right now i want to zero out any value under a certain value…if this number is high enough, it should kill the entire audio…but it doesnt…what am i doing wrong here?

That just switches the local pointer data1 to point to fftData, it doesn’t actually copy the samples from fftData into the buffer provided into the processBlock method. Once you get that working, you will probably bump into the issue that you are not doing any windowing and overlapping of the audio, so the results are going to sound bad.

Can you elaborate on the windowing? Would a Hanning window work? Do I apply this window before the first transform?

dsp::WindowingFunction has very limited documentation.

How do i apply a window to my fftData array?
I have never used a c++ template and am having trouble understanding the syntax.

code:

dsp::WindowingFunction <float>(1024, dsp::WindowingFunction<float>::hamming, false, 0.0f).multiplyWithWindowingTable(fftData,numsam);

Its not entirely clear how to apply the window for complex FFTs. For real FFTs, its pretty straightforward:

    forwardFFT.performFrequencyOnlyForwardTransform (fftData); // [2]```

But the complex FFT has this function signature: 

void dsp::FFT::perform ( const Complex< float > * input,
Complex< float > * output,
bool inverse
) const


How does one apply the window in the case of the complex FFT?