Esempio n. 1
0
        public void Analyze()
        {
            // F0 estimate

            var harvest = new Harvest();

            harvest.FramePeriod = FramePeriod;
            harvest.F0Floor     = 40.0;
            var f0Length = harvest.GetSamplesForHarvest(SampleRate, Wave.Length, FramePeriod);

            F0       = new double[f0Length];
            TimeAxis = new double[f0Length];
            harvest.Estimate(Wave, SampleRate, TimeAxis, F0);

            // spectral envelope estimate

            var cheapTrick = new CheapTrick(SampleRate);

            cheapTrick.F0Floor = 71.0;
            cheapTrick.FFTSize = cheapTrick.GetFFTSizeForCheapTrick(SampleRate);
            FFTSize            = cheapTrick.FFTSize;
            Spectrogram        = Enumerable.Range(0, f0Length).Select((i) => new double[FFTSize / 2 + 1]).ToArray();
            cheapTrick.Estimate(Wave, SampleRate, TimeAxis, F0, Spectrogram);

            // aperiodicity estimate

            var d4c = new D4C();

            d4c.Threshold = 0.85;
            Aperiodicity  = Enumerable.Range(0, f0Length).Select((i) => new double[FFTSize / 2 + 1]).ToArray();
            d4c.Estimate(Wave, SampleRate, TimeAxis, F0, f0Length, FFTSize, Aperiodicity);
        }