I think there's a small bug in this.
relevant code:
public double[ GenerateFrequencyScale(double sampleRate, int numberOfSamplePairs)
{
double[ scale = new double[numberOfSamplePairs];
double f = 0, step = sampleRate / numberOfSamplePairs;
int secondHalf = (numberOfSamplePairs >> 1) + 1;
for(int i = 0; i < secondHalf; i++)
{
scale[i ] = f;
f + = step;
}
f = -step * (secondHalf - 2);
for(int i = secondHalf; i < numberOfSamplePairs; i++)
{
scale[i ] = f;
f += step;
}
return scale;
}
Example:
Fs (sampling rate) = 8.192 GHz
numberOfSamplePairs = 131072
secondHalf => 65537
step = 62.5 kHz
The first half of the axis (aka the positive side) will go up to (secondHalf-1)*step.... = 4.096 GHz. All good and correct.
The second half of the axis (aka the negative side) will start at -step * (secondHalf - 2) = -62500 * (65537 - 2) = -4.0959375 GHz....one step above the lower frequency bound (which should be -4.096 GHz).