//
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        private void Test(WWTimeDependentForwardFourierTransform t, WWTimeDependentInverseFourierTransform f, double [] x, int fragmentSize)
        {
            int iPos = 0;
            int oPos = 0;

            // Processのテスト。
            while (iPos < x.Length)
            {
                int size = fragmentSize;
                if (x.Length - iPos < size)
                {
                    size = x.Length - iPos;
                }

                var xF = new double[size];
                Array.Copy(x, iPos, xF, 0, size);
                iPos += size;

                var X = t.Process(xF);
                if (0 < X.Length)
                {
                    var xR = f.Process(X);
                    if (0 <= xR.Length)
                    {
                        for (int j = 0; j < xR.Length; ++j)
                        {
                            Assert.IsTrue(Math.Abs(xR[j] - x[oPos]) < 1e-8);
                            ++oPos;
                        }
                    }
                }
            }

            {
                // Drainのテスト。
                var X  = t.Drain();
                var xR = f.Process(X);
                for (int j = 0; j < xR.Length; ++j)
                {
                    if (x.Length <= oPos)
                    {
                        break;
                    }
                    Assert.IsTrue(Math.Abs(xR[j] - x[oPos]) < 1e-8);
                    ++oPos;
                }
            }
        }
        public override WWUtil.LargeArray <double> FilterDo(WWUtil.LargeArray <double> inPcmLA)
        {
            var inPcm = inPcmLA.ToArray();

            var pcmF = mFFTfwd.Process(inPcm);

            if (pcmF.Length == 0)
            {
                return(new WWUtil.LargeArray <double>(0));
            }

            int idx20Hz = (int)(20.0 * mFftLength / mPcmFormat.SampleRate);
            int idx40Hz = (int)(40.0 * mFftLength / mPcmFormat.SampleRate);

            for (int i = 0; i < idx40Hz - idx20Hz; ++i)
            {
                // 正の周波数
                {
                    var v = pcmF[i + idx40Hz];
                    v = WWComplex.Mul(v, Gain);
                    pcmF[i + idx20Hz] = WWComplex.Add(pcmF[i + idx20Hz], v);
                }

                // 負の周波数
                {
                    var v = pcmF[mFftLength - (i + idx40Hz)];
                    v = WWComplex.Mul(v, Gain);
                    pcmF[mFftLength - (i + idx20Hz)] = WWComplex.Add(pcmF[mFftLength - (i + idx20Hz)], v);
                }
            }

            var r = new WWUtil.LargeArray <double>(mFFTinv.Process(pcmF));

            // 進捗表示。
            mProcessedSamples += inPcm.Length;
            ProgressReport((double)mProcessedSamples / mTotalSamples);

            return(r);
        }
Example #3
0
 public WWComplex[] ForwardFft(double[] timeDomain)
 {
     return(mFFTfwd.Process(timeDomain));
 }