public VoiceActivityDetectorV2(int sampleRate)
        {
            this.sampleRate = sampleRate;

            samplesInFrame = sampleRate / (1000 / frameSize);

            fft = new FFT2();
            fft.init((uint)Math.Log(samplesInFrame, 2));

            Enabled = true; // default value
        }
Пример #2
0
        public void TestFFT()
        {
            const int SIZE = 512;
            var re = new double[SIZE];
            var im = new double[SIZE];

            for (int i = 0; i < SIZE; i++)
            {
                re[i] = Math.Sin(2 * Math.PI / SIZE * i);
                im[i] = 0;
            }

            var fft = new FFT2();
            var logN = (uint)Math.Log(SIZE, 2);
            fft.init(logN);

            var expected = new double[SIZE];
            Array.Copy(re, expected, re.Length);

            fft.run(re, im);
            fft.run(re, im, true);

            for (int i = 0; i < SIZE; i++)
            {
                Assert.AreEqual(expected[i], re[i], 0.000000001);
            }
        }