in

.NET Opensource

Community for opensource projects by Christoph Rüegg

ComplexFrequencyTransform.GetFrequencyAxis()

Last post 03-07-2008 18:11 by Christoph Rüegg. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 03-07-2008 17:38

    ComplexFrequencyTransform.GetFrequencyAxis()

     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).

     

  • 03-07-2008 18:11 In reply to

    Re: ComplexFrequencyTransform.GetFrequencyAxis()

    Answer

    No, that's actually like this by design. Since the most positive and most negative frequency component is always equal, we only return the most positive one (but also return the zero component instead), and thus also generate the frequency axis alike. See Data Structures.

Page 1 of 1 (2 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems