Ejemplo n.º 1
0
        /// <summary>
        /// 分析多音色波形
        /// </summary>
        /// <param name="testData">测试波形</param>
        /// <param name="refWaveform">参考波形</param>
        /// <param name="sampleRate">采样率</param>
        /// <param name="peakToPeak">峰峰值</param>
        /// <param name="acRms">交流有效电平</param>
        /// <param name="dcRms">直流有效电平</param>
        /// <param name="max">最大值</param>
        /// <param name="min">最小值</param>
        /// <param name="tdPlusN">失真和噪声与信号比</param>
        /// <param name="acPart">AC部分</param>
        /// <param name="powerSpectrum">功率谱值</param>
        /// <param name="phaseSpectrum">相位谱</param>
        public static void AnalyzeMultiToneWaveform(double[] testData, MultiToneWaveform refWaveform,
                                                    double sampleRate, out double peakToPeak, out double acRms, out double dcRms,
                                                    out double max, out double min, out double tdPlusN, out double[] acPart,
                                                    out double[] powerSpectrum, out double[] phaseSpectrum)
        {
            MultiToneAnalyzer analyzer = new MultiToneAnalyzer();

            analyzer.SetReferenceWaveform((ManagedAudioLibrary.MultiToneWaveform)refWaveform.GetRawWaveform());
//            uint pathDelay = AnalyzePathDelay(testData, refWaveform.GetWaveData());
//            analyzer.SetDataDelayCounts(pathDelay);
            analyzer.SetDataSampleRate(sampleRate);
            analyzer.Analyze(testData, (uint)testData.Length);

            peakToPeak = analyzer.GetPeakToPeak();
            acRms      = analyzer.GetAcPart();
            dcRms      = analyzer.GetDcPart();
            max        = analyzer.GetMax();
            min        = analyzer.GetMin();
            tdPlusN    = analyzer.GetTdPlusN();

            acPart = new double[refWaveform.FrequencyPoints];
            for (uint i = 0; i < refWaveform.FrequencyPoints; i++)
            {
                acPart[i] = analyzer.GetAcPart((ushort)i);
            }

            uint spectrumLength = analyzer.GetSpectrumLength();

            powerSpectrum = new double[spectrumLength];
            phaseSpectrum = new double[spectrumLength];
            analyzer.GetPowerSpectrum(powerSpectrum);
            analyzer.GetPhaseSpectrum(phaseSpectrum);
        }
Ejemplo n.º 2
0
 public void Analyze()
 {
     _analyzer.SetAnalyzeParam(_refWaveform);
     _analyzer.Analyze(_testData, _globalInfo.DelaySamples, _analyzeSize);
 }