/// <summary> /// 分析SteppedLevelSine波形 /// </summary> /// <param name="testData">测试波形</param> /// <param name="refWaveform">参考波形</param> /// <param name="peakToPeak">峰峰值</param> /// <param name="thdInDb">谐波失真(dB)</param> /// <param name="nrInDb">噪声比(dB)</param> /// <param name="thdPlusNInDb">谐波失真和噪声与信号的比(dB)</param> /// <param name="rms">有效电平</param> public static void AnalyzeSteppedLevelSineWaveform(double[] testData, Waveform.SteppedLevelSineWaveform refWaveform, out double[] peakToPeak, out double[] thdInDb, out double[] nrInDb, out double[] thdPlusNInDb, out double[] rms) { SteppedLevelSineAnalyzer analyzer = new SteppedLevelSineAnalyzer(); ManagedAudioLibrary.SteppedLevelSineWaveform rawWaveform = refWaveform.GetRawWaveform() as ManagedAudioLibrary.SteppedLevelSineWaveform; analyzer.SetReferenceWaveform(rawWaveform); double[] refData = refWaveform.GetWaveData(); uint pathDelay = AnalyzePathDelay(testData, refData); analyzer.SetDataDelayCounts(pathDelay); analyzer.Analyze(testData, (uint)testData.Length); peakToPeak = new double[rawWaveform.GetNumberOfSteps()]; thdInDb = new double[rawWaveform.GetNumberOfSteps()]; nrInDb = new double[rawWaveform.GetNumberOfSteps()]; thdPlusNInDb = new double[rawWaveform.GetNumberOfSteps()]; rms = new double[rawWaveform.GetNumberOfSteps()]; for (ushort i = 0; i < rawWaveform.GetNumberOfSteps(); i++) { peakToPeak[i] = analyzer.GetPeakToPeak(i); thdInDb[i] = analyzer.GetThd(i); nrInDb[i] = analyzer.GetNoiseRatio(i); thdPlusNInDb[i] = analyzer.GetThdPlusN(i); rms[i] = analyzer.GetRMS(i); } }
public void ShowResult() { double[] peakToPeak = _analyzer.GetPeakToPeak(); double[] thd = _analyzer.GetTHDInDb(); double[] nr = _analyzer.GetNoiseRatioInDb(); double[] thdPlusNr = _analyzer.GetTHDPlusNoiseInDb(); double[] rms = _analyzer.GetRms(); for (int i = 0; i < peakToPeak.Length; i++) { int rowIndex = dataGridView_result.Rows.Add(); dataGridView_result.Rows[rowIndex].Cells[0].Value = peakToPeak[i]; dataGridView_result.Rows[rowIndex].Cells[1].Value = thd[i]; dataGridView_result.Rows[rowIndex].Cells[2].Value = nr[i]; dataGridView_result.Rows[rowIndex].Cells[3].Value = thdPlusNr[i]; dataGridView_result.Rows[rowIndex].Cells[4].Value = rms[i]; } }