Пример #1
0
        /// <summary>
        ///构造
        /// </summary>
        public Chart_AM()
        {
            m_aSpectrograms2D_source = null;
            m_aSpectrograms2D_signal = null;
            m_AreaSpectrum_signal    = null;
            m_AreaSpectrum_souce     = null;
            m_aWaveformMonitors      = null;
            m_iFFTCalcIntervalMs     = 20;
            m_iFFTWindowLength       = 1024 * 4;
            m_iHighFreq        = 2000;
            _samplingFrequency = 0;
            Param        = new Param_AM(1000);
            _seriesNames = new string[]
            {
                "音频",
                "载波",
                "调制",
                "检波"
            };

            InitializeComponent();

            //销毁时释放资源
            Dispatcher.ShutdownStarted += (object sender, EventArgs e) =>
            {
                Dispose();
            };
        }
Пример #2
0
        /// <summary>
        /// 初始化示波器
        /// </summary>
        private void InitWaveformMonitors()
        {
            if (m_aWaveformMonitors != null)
            {
                DisposeWaveformMonitors();
            }

            if (m_aWaveformMonitors == null)
            {
                // Let's disable SizeChanged event handler temporarily.
                // ArrangeMonitors method is called at the end of this
                // method.
                gridChart.SizeChanged -= gridChart_SizeChanged;

                m_aWaveformMonitors =
                    new WaveformMonitor(
                        gridChart,
                        _seriesNames,
                        _samplingFrequency,
                        DefaultColors.SeriesForBlackBackgroundWpf[0],
                        null);
                m_aWaveformMonitors.Chart.ChartName = "示波器";

                gridChart.SizeChanged += gridChart_SizeChanged;

                string strTitle = "示波器 (幅值 / 时间)\n"
                                  + " " + string.Format("采样频率 = {0} kHz",
                                                        ((double)+_samplingFrequency / 1000.0).ToString("0"));

                m_aWaveformMonitors.Initialize(_samplingFrequency, strTitle,
                                               XAxisScrollMode.Scrolling, 0.03125);
            }

            ArrangeMonitors();
        }
Пример #3
0
 /// <summary>
 /// 释放示波器
 /// </summary>
 private void DisposeWaveformMonitors()
 {
     if (m_aWaveformMonitors != null)
     {
         m_aWaveformMonitors.Dispose();
         m_aWaveformMonitors = null;
     }
 }
Пример #4
0
        /// <summary>
        /// 释放示波器
        /// </summary>
        private void DisposeWaveformMonitors()
        {
            if (m_WaveformMonitor != null)
            {
                m_WaveformMonitor.Dispose();
                m_WaveformMonitor = null;
            }

            if (m_CodeMonitor != null)
            {
                m_CodeMonitor.Dispose();
                m_CodeMonitor = null;
            }
        }
Пример #5
0
        /// <summary>
        /// 停止模拟 释放资源
        /// </summary>
        public void Dispose()
        {
            if (audioInput1.Input.IsInputEnabled == true)
            {
                audioInput1.Input.StopRequest();
            }
            else
            {
                gridChart.Children.Clear();

                if (m_WaveformMonitor != null)
                {
                    m_WaveformMonitor.Dispose();
                    m_WaveformMonitor = null;
                }
            }
        }
Пример #6
0
        /// <summary>
        /// 构造
        /// </summary>
        public Chart_PCM()
        {
            m_WaveformMonitor  = null;
            m_CodeMonitor      = null;
            _samplingFrequency = 0;
            _seriesNames       = new string[]
            {
                "信号源",
                "PCM信号"
            };
            Param = new Param_PCM(2000);

            InitializeComponent();

            //销毁时释放资源
            Dispatcher.ShutdownStarted += (object sender, EventArgs e) =>
            {
                Dispose();
            };
        }
Пример #7
0
        /// <summary>
        /// 初始化示波器
        /// </summary>
        private void InitWaveformMonitors()
        {
            if (m_WaveformMonitor != null || m_CodeMonitor != null)
            {
                DisposeWaveformMonitors();
            }

            if (m_WaveformMonitor == null)
            {
                // Let's disable SizeChanged event handler temporarily.
                // ArrangeMonitors method is called at the end of this
                // method.
                gridChart.SizeChanged -= gridChart_SizeChanged;

                m_WaveformMonitor =
                    new WaveformMonitor(
                        gridChart,
                        _seriesNames,
                        _samplingFrequency,
                        DefaultColors.SeriesForBlackBackgroundWpf[0],
                        null);
                m_WaveformMonitor.Chart.ChartName = "示波器";

                gridChart.SizeChanged += gridChart_SizeChanged;

                string strTitle = "示波器 (幅值 / 时间)\n"
                                  + " " + string.Format("采样频率 = {0} kHz",
                                                        ((double)+_samplingFrequency / 1000.0).ToString("0"));

                m_WaveformMonitor.Initialize(_samplingFrequency, strTitle,
                                             XAxisScrollMode.Scrolling, 0.03125);

                m_WaveformMonitor.Chart.ViewXY.ZoomPanOptions.MouseWheelZooming = MouseWheelZooming.Off;
            }

            if (m_CodeMonitor == null)
            {
                // Let's disable SizeChanged event handler temporarily.
                // ArrangeMonitors method is called at the end of this
                // method.
                gridChart.SizeChanged -= gridChart_SizeChanged;

                m_CodeMonitor =
                    new WaveformMonitor(
                        gridChart,
                        new string[] {
                    "PCM编码"
                },
                        _samplingFrequency,
                        DefaultColors.SeriesForBlackBackgroundWpf[0],
                        null);
                m_CodeMonitor.Chart.ChartName = "PCM显示器";

                gridChart.SizeChanged += gridChart_SizeChanged;

                m_CodeMonitor.Initialize(_samplingFrequency, null,
                                         XAxisScrollMode.Scrolling, 0.03125);
                //重新设置Y轴范围
                m_CodeMonitor.Chart.ViewXY.YAxes.FirstOrDefault().SetRange(-0.5, 1.5);
                m_CodeMonitor.Chart.ViewXY.ZoomPanOptions.MouseWheelZooming = MouseWheelZooming.Off;
            }
            ArrangeMonitors();
        }
Пример #8
0
        /// <summary>
        /// 初始化示波器
        /// </summary>
        private void InitWaveformMonitors()
        {
            bool bCreate = false;

            if (m_aWaveformMonitors != null)
            {
                if (_channelCount != m_aWaveformMonitors.Length)
                {
                    DisposeWaveformMonitors();
                    bCreate = true;
                }
            }
            else
            {
                bCreate = true;
            }

            if (bCreate)
            {
                m_aWaveformMonitors = new WaveformMonitor[_channelCount];



                for (int i = 0; i < _channelCount; i++)
                {
                    WaveformMonitor wm =
                        new WaveformMonitor(
                            gridChart,
                            new string[] { "输入" },
                            _samplingFrequency,
                            DefaultColors.SeriesForBlackBackgroundWpf[i % DefaultColors.SeriesForBlackBackgroundWpf.Length],
                            null
                            );
                    wm.Chart.ChartName = "Waveform Chart " + (i + 1).ToString();

                    m_aWaveformMonitors[i] = wm;
                }

                // Re-enable SizeChanged event handler.
                gridChart.SizeChanged += gridChart_SizeChanged;
            }

            for (int i = 0; i < _channelCount; i++)
            {
                string strTitle = "Audio waveform (amplitude / time)\n"
                                  + " " + string.Format("sfreq = {0} kHz",
                                                        ((double)+_samplingFrequency / 1000.0).ToString("0"));

                if (_channelCount == 2)
                {
                    if (i == 0)
                    {
                        strTitle += " - Left";
                    }
                    else
                    {
                        strTitle += " - Right";
                    }
                }

                m_aWaveformMonitors[i].Initialize(_samplingFrequency, strTitle, XAxisScrollMode.Scrolling, 0.03125);
            }

            ArrangeMonitors();
        }