Leland,
The problem turns out to be the original FFT() function has the sign
inverted on imaginary values relative to the standard definition of the DFT.
The net result of this is the time shifts go in the wrong direction. You can
get away with this as long as you make the same error in both the forward
and inverse transform and/or if you only deal with data symmetric about 0.
In this case I didn't change the FFT function references used to create the
filter, but I did change the FFT functions used when applying the filter.
Since the original function and my function are using opposite imaginary
signs, and the equalizer filter is not symmetric about 0, this causes the
problem you noted.
The simple fix would be to change FFT.c to use the correct sign:
-if (InverseTransform)
+if (!InverseTransform)
angle_numerator = -angle_numerator;
The downside with this solution is if any asymmetrical FFT values were
stored in an older version of Audacity using the incorrect sign, and then
get recalled and used in a current version of Audacity using the correct
sign, you'll get an incorrect result. I looked over the code, and I don't
see anywhere where the real and imaginary part are stored between sessions.
For the most part in Audacity only the magnitude is used, so I think the
Equalizer effect is the only code that would be sensitive to the sign of the
imaginary part.
If there are no objections, I'll make the above patch to FFT.c
If there are objections, the harder fix would be to change the sign of my
function to use the same sign as the original FFT function.
Phil
Note: If you want to verify for yourself that the sign is incorrect, compute
the FFT of a shifted impulse (a vector of zeros, with only vector[1] = 1).
>From the definition of the FFT the result should be F[n] =
1*exp(-2*pi*i*1*n/N) The imaginary part of this starts at 0 and goes
negative (due to the -2pi). If you make this calculation using the original
FFT function in Audacity the imaginary part starts at 0 and goes positive.
---- sample test code ----------
float *impulse = new float[mWindowSize];
float *outr = new float[mWindowSize];
float *outi = new float[mWindowSize];
for(i=0; i<mWindowSize; i++)
impulse[i] = 0;
impulse[1] = 1;
FFT(mWindowSize,false,impulse,0,outr,outi);
fp=fopen("impulse.txt","w");
for(i=0; i<mWindowSize; i++) {
fprintf(fp, "%g\t%g\n", outr[i], outi[i]);
}
fclose(fp);
delete[] impulse;
delete[] outr;
delete[] outi;
---------------------
--------------------------------------------------
From: "Leland" <
[hidden email]>
Sent: Tuesday, June 23, 2009 7:56 PM
To: <
[hidden email]>
Subject: Re: [Audacity-devel] New FFT function
> Philip Van Baren wrote:
>> I submitted new FFT functions, RealFFTf and InverseRealFFTf, and updated
>> the NoiseRemoval and Equalizer effects to use the new functions. By my
>> benchmarks this gives a better than 2x speedup in NoiseRemoval, and
>> similar improvement in the processing part of Equalizer.
>>
>> I also made a crude remap from FFT() to the new function as proof of
>> concept, and found we can also get some significant improvement in the
>> Plot Spectrum function. It should also help in the spectrogram plots,
>> but I wasn't sure how to benchmark that. I didn't submit the crude
>> remap, though, but have attached it to this email in case anyone is
>> interested.
>>
> Phil,
>
> Can you check something with your new implementation.
>
> 1) Start Audacity clean
> 2) Generate -> Chirp with default parameters (sine, freq: 440-1320, amp:
> 0.8-0.8, linear, 30 secs)
> 3) Effect -> Equalization (draw curves, length: 4001, curve: amradio)
>
> If you have View -> Show Clipping turned on, you should see a fair amount
> of regularly spaced clipping with missing sections of audio.
>
> Leland
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> audacity-devel mailing list
>
[hidden email]
>
https://lists.sourceforge.net/lists/listinfo/audacity-devel
------------------------------------------------------------------------------
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel