Editing FFT Data


my code:

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

int numsam = buffer.getNumSamples();
memcpy(fftData, data1, numsam * sizeof(float));
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;

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.



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