/// <summary> /// 音频数据更新 /// </summary> /// <param name="args"></param> private void AudioInput_DataGenerated(DataGeneratedEventArgs args) { double[][] samples = args.Samples; if (samples.Length == 0) { return; } //源波 double[] souceWave = samples[0]; //生成载波 double MaxAmplitude = 10000; double[] carryWave = WaveGenerator.Sine(samples[0].Count(), (int)MaxAmplitude, _samplingFrequency, Param.moudulateFrequency); //生成调制波 double[] modulatedWava = new double[souceWave.Count()]; for (int i = 0; i < souceWave.Count(); i++) { double signal = souceWave[i] * carryWave[i]; //每个信号除以载波幅度以约束其值范围 signal /= MaxAmplitude; modulatedWava[i] = signal; } //为示波器输入数据 if (m_aWaveformMonitors != null) { double[][] waveData = new double[_seriesNames.Count()][]; waveData[0] = souceWave; waveData[1] = carryWave; waveData[2] = modulatedWava; waveData[3] = samples[0]; m_aWaveformMonitors.FeedData(waveData); } //Feed multi-channel data to FFT calculator. If it gives a calculated result, set multi-channel result in the selected FFT chart if (m_fftCalculator != null) { double[][][] yValues; double[][][] xValues; double[][] data = new double[2][]; data[0] = souceWave; data[1] = modulatedWava; if (m_fftCalculator.FeedDataAndCalculate(data, out xValues, out yValues)) { int rowCount = xValues.Length; m_aSpectrograms2D_source.SetData(yValues, 0, rowCount); m_AreaSpectrum_souce.SetData(xValues[0][0], yValues[0][0]); m_aSpectrograms2D_signal.SetData(yValues, 1, rowCount); m_AreaSpectrum_signal.SetData(xValues[0][1], yValues[0][1]); } } //TODO //base.DataGenerated(samples[0].Length); }
private static Sprite _genPhotonSprite() { return(_generateSprite((600, 35), WaveGenerator.Sine(1), 2)); }