コード例 #1
0
ファイル: SP.cs プロジェクト: yusukeinyos/SoundMaker
 //-------------------------------------------------------------------------------------
 //実数値FFT(フル)
 //単独での使用
 public static Complex[] FullRealFastFourierTransform(double[] input)
 {
     input = zeroInserting(input); //0埋め
     Complex[] RFTout = Nm.RealFastFourierTransform(input);
     Complex[] output = new Complex[RFTout.Length * 2];
     for (int i = 0; i < RFTout.Length; i++)
     {
         output[i] = RFTout[i];
         output[RFTout.Length + i] = Complex.Conjugate(RFTout[RFTout.Length - 1 - i]);
     }
     return(output);
 }
コード例 #2
0
ファイル: SP.cs プロジェクト: yusukeinyos/SoundMaker
        //-------------------------------------------------------------------------------------
        //実数値IFFT(高速フーリエ逆変換)
        //複素共役にする処理もNm.RealFastFourierTransform(Complex[])に含まれてる!!
        //入力はナイキスト周波数に対応するスペクトル(半分だけ)でいい!!
        public static void Real_IFFT(double[] Re, double[] Im, out double[] output)
        {
            int size = Re.Length;

            Complex[] comp = new Complex[size];

            for (int i = 0; i < size; i++)
            {
                comp[i] = new Complex(Re[i], Im[i]);
            }
            output = Nm.RealFastFourierTransform(comp);
        }
コード例 #3
0
ファイル: SP.cs プロジェクト: yusukeinyos/SoundMaker
        //-------------------------------------------------------------------------------------
        //STFT(短時間フーリエ変換)
        public static Complex[,] STFT(double[] source_data, int window_size)
        {
            Complex[,] output;
            int    source_length = source_data.Length;           //入力データ長
            int    T_step;                                       //時間ステップ数
            int    F_step;                                       //周波数ステップ数
            int    fft_start_point = 0;                          //fftをするスタート点
            double window_power    = powerOfwindow(window_size); //窓関数のパワー WN

            T_step = (int)((source_length - window_size) / window_power) - 1;
            int n4 = 1 << (Mt.Log2Int(window_size) - 2);
            int n = n4 * 4, n2 = n4 * 2;

            F_step = n2 + 1;
            output = new Complex[F_step, T_step];

            for (int t = 0; t < T_step; t++)
            {
                double[] data = new double[window_size];
                fft_start_point = (int)window_power * t;
                for (int i = 0; i < window_size; i++)
                {
                    data[i] = source_data[fft_start_point + i];
                }
                data = windowing(data);

                Complex[] fft = Nm.RealFastFourierTransform(data);

                for (int f = 0; f < F_step; f++)
                {
                    output[f, t] = fft[f];
                }
            }

            return(output);
        }
コード例 #4
0
ファイル: SP.cs プロジェクト: yusukeinyos/SoundMaker
 public static void Real_IFFT(Complex[] comp, out double[] output)
 {
     output = Nm.RealFastFourierTransform(comp);
 }