diff --git a/Correlator/Dialog/SimplyAuditionDialog.xaml.cs b/Correlator/Dialog/SimplyAuditionDialog.xaml.cs index 41cb280..4f0a1fc 100644 --- a/Correlator/Dialog/SimplyAuditionDialog.xaml.cs +++ b/Correlator/Dialog/SimplyAuditionDialog.xaml.cs @@ -22,6 +22,7 @@ private readonly WasapiCapture _capture; // 音频捕获 private int _colorIndex; private readonly Color[] _allColors; + private Point[] _pointArray; private readonly DispatcherTimer _dataTimer = new DispatcherTimer { @@ -54,7 +55,7 @@ _visualizer.PushSampleData(result); // 将新的采样存储到 可视化器 中 }; - + _dataTimer.Tick += DataTimer_Tick; _drawingTimer.Tick += DrawingTimer_Tick; } @@ -149,19 +150,19 @@ double xOffset, double yOffset, double scale ) { - var pointArray = new Point[pointCount]; + _pointArray = new Point[pointCount]; for (var i = 0; i < pointCount; i++) { var x = i * drawingWidth / pointCount + xOffset; var y = spectrumData[i * spectrumData.Length / pointCount] * scale + yOffset; - pointArray[i] = new Point(x, y); + _pointArray[i] = new Point(x, y); } var figure = new PathFigure { - StartPoint = pointArray[0] + StartPoint = _pointArray[0] }; - figure.Segments.Add(new PolyLineSegment(pointArray, true)); + figure.Segments.Add(new PolyLineSegment(_pointArray, true)); wavePath.Data = new PathGeometry { Figures = { figure } }; wavePath.Stroke = brush; diff --git a/Correlator/Dialog/SimplyAuditionDialog.xaml.cs b/Correlator/Dialog/SimplyAuditionDialog.xaml.cs index 41cb280..4f0a1fc 100644 --- a/Correlator/Dialog/SimplyAuditionDialog.xaml.cs +++ b/Correlator/Dialog/SimplyAuditionDialog.xaml.cs @@ -22,6 +22,7 @@ private readonly WasapiCapture _capture; // 音频捕获 private int _colorIndex; private readonly Color[] _allColors; + private Point[] _pointArray; private readonly DispatcherTimer _dataTimer = new DispatcherTimer { @@ -54,7 +55,7 @@ _visualizer.PushSampleData(result); // 将新的采样存储到 可视化器 中 }; - + _dataTimer.Tick += DataTimer_Tick; _drawingTimer.Tick += DrawingTimer_Tick; } @@ -149,19 +150,19 @@ double xOffset, double yOffset, double scale ) { - var pointArray = new Point[pointCount]; + _pointArray = new Point[pointCount]; for (var i = 0; i < pointCount; i++) { var x = i * drawingWidth / pointCount + xOffset; var y = spectrumData[i * spectrumData.Length / pointCount] * scale + yOffset; - pointArray[i] = new Point(x, y); + _pointArray[i] = new Point(x, y); } var figure = new PathFigure { - StartPoint = pointArray[0] + StartPoint = _pointArray[0] }; - figure.Segments.Add(new PolyLineSegment(pointArray, true)); + figure.Segments.Add(new PolyLineSegment(_pointArray, true)); wavePath.Data = new PathGeometry { Figures = { figure } }; wavePath.Stroke = brush; diff --git a/Correlator/SensorHubTag/TagFactory.cs b/Correlator/SensorHubTag/TagFactory.cs index b61f55b..ff721f6 100644 --- a/Correlator/SensorHubTag/TagFactory.cs +++ b/Correlator/SensorHubTag/TagFactory.cs @@ -2,34 +2,35 @@ { public static class TagFactory { + private static Tag _tag; + public static Tag Create(string oid, int len, byte[] value) { - Tag tag; if (UploadTag.IsUploadTag(oid)) { //关键数据存在此Tag中 - tag = new UploadTag(oid, len, value); + _tag = new UploadTag(oid, len, value); } else { switch (oid) { case TagOid.CellTagOid: - tag = new CellTag(oid, len, value); + _tag = new CellTag(oid, len, value); break; case TagOid.TimeTagOid: - tag = new TimeTag(oid, len, value); + _tag = new TimeTag(oid, len, value); break; case TagOid.ExceptionTagOid: - tag = new SensorExceptionTag(oid, len, value); + _tag = new SensorExceptionTag(oid, len, value); break; default: - tag = new NormalTag(oid, len, value); + _tag = new NormalTag(oid, len, value); break; } } - return tag; + return _tag; } } } \ No newline at end of file diff --git a/Correlator/Dialog/SimplyAuditionDialog.xaml.cs b/Correlator/Dialog/SimplyAuditionDialog.xaml.cs index 41cb280..4f0a1fc 100644 --- a/Correlator/Dialog/SimplyAuditionDialog.xaml.cs +++ b/Correlator/Dialog/SimplyAuditionDialog.xaml.cs @@ -22,6 +22,7 @@ private readonly WasapiCapture _capture; // 音频捕获 private int _colorIndex; private readonly Color[] _allColors; + private Point[] _pointArray; private readonly DispatcherTimer _dataTimer = new DispatcherTimer { @@ -54,7 +55,7 @@ _visualizer.PushSampleData(result); // 将新的采样存储到 可视化器 中 }; - + _dataTimer.Tick += DataTimer_Tick; _drawingTimer.Tick += DrawingTimer_Tick; } @@ -149,19 +150,19 @@ double xOffset, double yOffset, double scale ) { - var pointArray = new Point[pointCount]; + _pointArray = new Point[pointCount]; for (var i = 0; i < pointCount; i++) { var x = i * drawingWidth / pointCount + xOffset; var y = spectrumData[i * spectrumData.Length / pointCount] * scale + yOffset; - pointArray[i] = new Point(x, y); + _pointArray[i] = new Point(x, y); } var figure = new PathFigure { - StartPoint = pointArray[0] + StartPoint = _pointArray[0] }; - figure.Segments.Add(new PolyLineSegment(pointArray, true)); + figure.Segments.Add(new PolyLineSegment(_pointArray, true)); wavePath.Data = new PathGeometry { Figures = { figure } }; wavePath.Stroke = brush; diff --git a/Correlator/SensorHubTag/TagFactory.cs b/Correlator/SensorHubTag/TagFactory.cs index b61f55b..ff721f6 100644 --- a/Correlator/SensorHubTag/TagFactory.cs +++ b/Correlator/SensorHubTag/TagFactory.cs @@ -2,34 +2,35 @@ { public static class TagFactory { + private static Tag _tag; + public static Tag Create(string oid, int len, byte[] value) { - Tag tag; if (UploadTag.IsUploadTag(oid)) { //关键数据存在此Tag中 - tag = new UploadTag(oid, len, value); + _tag = new UploadTag(oid, len, value); } else { switch (oid) { case TagOid.CellTagOid: - tag = new CellTag(oid, len, value); + _tag = new CellTag(oid, len, value); break; case TagOid.TimeTagOid: - tag = new TimeTag(oid, len, value); + _tag = new TimeTag(oid, len, value); break; case TagOid.ExceptionTagOid: - tag = new SensorExceptionTag(oid, len, value); + _tag = new SensorExceptionTag(oid, len, value); break; default: - tag = new NormalTag(oid, len, value); + _tag = new NormalTag(oid, len, value); break; } } - return tag; + return _tag; } } } \ No newline at end of file diff --git a/Correlator/Util/AudioVisualizer.cs b/Correlator/Util/AudioVisualizer.cs index 393f7df..a5153f6 100644 --- a/Correlator/Util/AudioVisualizer.cs +++ b/Correlator/Util/AudioVisualizer.cs @@ -15,7 +15,7 @@ private Complex[] _data; /// - /// + /// 初始化音频可视化容器 /// /// 控制频谱数量,数量越多,界面显示波动的频谱越多,建议256就好 ///