예제 #1
0
        /// <summary>
        /// 分析单音色波形
        /// </summary>
        /// <param name="waveform">测试波形</param>
        /// <param name="targetFreq">目标频率</param>
        /// <param name="sampleRate">采样率</param>
        /// <param name="amplitudeInVol">波幅</param>
        /// <param name="thdInDb">谐波失真(dB)</param>
        /// <param name="nrInDb">噪声比(dB)</param>
        /// <param name="thdPlusNRatioInDb">噪声和谐波失真与信号的比(dB)</param>
        /// <param name="harmonicPower">谐波分量功率</param>
        public static void AnalyzeSingleToneWave(double[] waveform, double targetFreq, double sampleRate,
                                                 out double amplitudeInVol, out double thdInDb, out double nrInDb, out double thdPlusNRatioInDb,
                                                 out double[] harmonicPower)
        {
            const ushort       harmonicOrder = 6;
            SingleToneAnalyzer analyzer      = new SingleToneAnalyzer();

            analyzer.SetTargetToneFrequency(targetFreq, sampleRate);
            analyzer.Analyze(waveform, (uint)waveform.Length);
            amplitudeInVol    = analyzer.GetPeakToPeak();
            thdInDb           = analyzer.GetThd();
            nrInDb            = analyzer.GetNoiseRatio();
            thdPlusNRatioInDb = analyzer.GetThdPlusN();
            harmonicPower     = new double[harmonicOrder];
            for (ushort i = 0; i < harmonicOrder; i++)
            {
                harmonicPower[i] = analyzer.GetHarmonicPower(i);
            }
        }
예제 #2
0
 public void Analyze()
 {
     _analyzer.SetAnalyzeParam(_globalInfo.AITask.GetSampleRate());
     _analyzer.Analyze(_testData, _globalInfo.DelaySamples, _analyzeSize);
 }