Hello,
We have a question about FFT and iFFT. With the following code, we manage to reproduce a given sample.
global
{
srate 44100;
krate 100;
}
instr tone()
{
// variable declaration
table re(empty,8192); // values from fft
table im(empty,8192);
table mod(empty,8192); // for modified values
table modim(empty,8192);
table w(window,8192,2); // window envelope
asig y, z;
ksig flag, i;
table voice(sample,-1,"highvolume.wav"); // sample to be edited
y = doscil(voice);
flag = fft(y, re, im, 8192, 1024, 8192, w); // actual fft.....
if(flag)
{
while(i < 4096)
{
tablewrite (mod, i, tableread(re, i)); // writing the mod and modim tables
tablewrite (modim, i, tableread(im,i));
i = i + 1;
}
i = 0;
}
z = ifft(mod,modim,8192, 1024, 8192, w); // reconstruction via inverse fft
output(z*0.5);
}
This works, we get a good reconstruction with this code. But when we change the while-loop into:
while(i < 4096)
{
tablewrite (mod, i, tableread(re, i)); // writing the mod and modim tables
tablewrite (modim, i, tableread(im,i));
tablewrite (mod, i + 1, 0); // writing the mod and modim tables
tablewrite (modim, i + 1, 0);
i = i + 2;
}
With this code, we wanted to copy all the data at the even-numbered indexes, and putting all data at the the odd-numbered indexes to 0. We thought we could put all even harmonics (index 0 gives the dc-offset, so index 1 is the first harmonic) to zero with this change, but this is not what happened.
Can anybody explain what it is that happens here and what we should do to put (for example) all even harmonics to zero?
Peter Maas
Peter van der Noord
This archive was generated by hypermail 2b29 : Mon Jan 28 2002 - 11:46:38 EST