Ejemplo n.º 1
0
 /// <summary>
 /// overwrites ImageBuffer
 /// </summary>
 public void Backward()
 {
     ifft.Execute();
 }
Ejemplo n.º 2
0
        static void doBand(ref double[] filteredFreq, ref double[] filteredTime, double[] timeData, int rate, double lowerFrequency, double upperFrequency, bool bandPass)
        {
            //fft - forward
            for (int i = 0; i < timeData.Length; i++)
            {
                mTimeBuffer[i] = timeData[i];
            }
            mPlanFore.Execute();

            //normalizing factor
            var energyTime = calcTimeEnergy(timeData, rate);
            var energyFreq = calcFreqEnergy(mFreqBuffer, rate);
            var factor     = Math.Sqrt(energyTime / energyFreq);

            for (int i = 0; i < mFreqBuffer.Length; i++)
            {
                mFreqBuffer[i] *= factor;
            }

            //TEST
            //for (int i = 0; i < filteredFreq.Length; i++) filteredFreq[i] = Complex.Abs(mFreqBuffer[i]);

            //filtering
            var index = TimingParam.IndexOf(lowerFrequency, upperFrequency);

            if (bandPass)
            {
                doBandPass(mFreqBuffer, index);
            }
            else
            {
                doBandStop(mFreqBuffer, index);
            }

            //return freq data
            filteredFreq[0] = mFreqBuffer[0].Magnitude;
            for (int i = 1; i < filteredFreq.Length; i++)
            {
                filteredFreq[i] = mFreqBuffer[i].Magnitude * SQRT2;
            }

            //fft - inverse
            mPlanBack.Execute();

            //backup time data
            for (int i = 0; i < filteredTime.Length; i++)
            {
                filteredTime[i] = mTimeBuffer[i].Real;
            }

            //re-normalization
            energyTime = calcTimeEnergy(filteredTime, rate);
            energyFreq = calcFreqEnergy(mFreqBuffer, rate);
            factor     = Math.Sqrt(energyFreq / energyTime);
            for (int i = 0; i < filteredTime.Length; i++)
            {
                filteredTime[i] *= factor;
            }

            DFT.Wisdom.Export("wisdom.txt");
        }
Ejemplo n.º 3
0
 /// <summary>
 /// overwrites FourierBuffer
 /// </summary>
 public void Forward()
 {
     fft.Execute();
 }