diff --git a/Correlator/Dialog/AudioVisualizeDialog.xaml b/Correlator/Dialog/AudioVisualizeDialog.xaml
index 7c29b7b..c4d9b4b 100644
--- a/Correlator/Dialog/AudioVisualizeDialog.xaml
+++ b/Correlator/Dialog/AudioVisualizeDialog.xaml
@@ -44,9 +44,12 @@
Text="音频波形图" />
+ Background="Black">
+
+
diff --git a/Correlator/Dialog/AudioVisualizeDialog.xaml b/Correlator/Dialog/AudioVisualizeDialog.xaml
index 7c29b7b..c4d9b4b 100644
--- a/Correlator/Dialog/AudioVisualizeDialog.xaml
+++ b/Correlator/Dialog/AudioVisualizeDialog.xaml
@@ -44,9 +44,12 @@
Text="音频波形图" />
+ Background="Black">
+
+
diff --git a/Correlator/Dialog/AudioVisualizeDialog.xaml.cs b/Correlator/Dialog/AudioVisualizeDialog.xaml.cs
index 13155b8..041aad4 100644
--- a/Correlator/Dialog/AudioVisualizeDialog.xaml.cs
+++ b/Correlator/Dialog/AudioVisualizeDialog.xaml.cs
@@ -15,7 +15,12 @@
{
private readonly AudioVisualizer _visualizer; // 可视化
private readonly WasapiCapture _capture; // 音频捕获
- private double[] _spectrumData; // 频谱数据
+
+ ///
+ /// 频谱数据
+ ///
+ private double[] _spectrumData;
+
private int _colorIndex;
private readonly Color[] _allColors;
@@ -109,6 +114,16 @@
var color1 = _allColors[_colorIndex % _allColors.Length];
var color2 = _allColors[(_colorIndex + 200) % _allColors.Length];
+ //时域
+ var curveBrush = new SolidColorBrush(color1);
+ DrawCurve(
+ SampleWavePath, curveBrush,
+ _visualizer.SampleData, _visualizer.SampleData.Length,
+ SampleWavePanel.ActualWidth, 0, SampleWavePanel.ActualHeight / 2,
+ Math.Min(SampleWavePanel.ActualHeight / 2, 50)
+ );
+
+ //频域
DrawGradientStrips(
StripsPath, color1, color2,
_spectrumData, _spectrumData.Length,
@@ -118,6 +133,41 @@
}
///
+ /// 画曲线
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// 控制波形图波峰高度和波谷深度
+ private void DrawCurve(
+ Path wavePath, Brush brush, double[] spectrumData, int pointCount, double drawingWidth,
+ double xOffset, double yOffset, double scale
+ )
+ {
+ var 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);
+ }
+
+ var figure = new PathFigure
+ {
+ StartPoint = pointArray[0]
+ };
+ figure.Segments.Add(new PolyLineSegment(pointArray, true));
+
+ wavePath.Data = new PathGeometry { Figures = { figure } };
+ wavePath.StrokeThickness = 2;
+ wavePath.Stroke = brush;
+ }
+
+ ///
/// 绘制渐变的条形
///
/// 绘图目标
diff --git a/Correlator/Dialog/AudioVisualizeDialog.xaml b/Correlator/Dialog/AudioVisualizeDialog.xaml
index 7c29b7b..c4d9b4b 100644
--- a/Correlator/Dialog/AudioVisualizeDialog.xaml
+++ b/Correlator/Dialog/AudioVisualizeDialog.xaml
@@ -44,9 +44,12 @@
Text="音频波形图" />
+ Background="Black">
+
+
diff --git a/Correlator/Dialog/AudioVisualizeDialog.xaml.cs b/Correlator/Dialog/AudioVisualizeDialog.xaml.cs
index 13155b8..041aad4 100644
--- a/Correlator/Dialog/AudioVisualizeDialog.xaml.cs
+++ b/Correlator/Dialog/AudioVisualizeDialog.xaml.cs
@@ -15,7 +15,12 @@
{
private readonly AudioVisualizer _visualizer; // 可视化
private readonly WasapiCapture _capture; // 音频捕获
- private double[] _spectrumData; // 频谱数据
+
+ ///
+ /// 频谱数据
+ ///
+ private double[] _spectrumData;
+
private int _colorIndex;
private readonly Color[] _allColors;
@@ -109,6 +114,16 @@
var color1 = _allColors[_colorIndex % _allColors.Length];
var color2 = _allColors[(_colorIndex + 200) % _allColors.Length];
+ //时域
+ var curveBrush = new SolidColorBrush(color1);
+ DrawCurve(
+ SampleWavePath, curveBrush,
+ _visualizer.SampleData, _visualizer.SampleData.Length,
+ SampleWavePanel.ActualWidth, 0, SampleWavePanel.ActualHeight / 2,
+ Math.Min(SampleWavePanel.ActualHeight / 2, 50)
+ );
+
+ //频域
DrawGradientStrips(
StripsPath, color1, color2,
_spectrumData, _spectrumData.Length,
@@ -118,6 +133,41 @@
}
///
+ /// 画曲线
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// 控制波形图波峰高度和波谷深度
+ private void DrawCurve(
+ Path wavePath, Brush brush, double[] spectrumData, int pointCount, double drawingWidth,
+ double xOffset, double yOffset, double scale
+ )
+ {
+ var 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);
+ }
+
+ var figure = new PathFigure
+ {
+ StartPoint = pointArray[0]
+ };
+ figure.Segments.Add(new PolyLineSegment(pointArray, true));
+
+ wavePath.Data = new PathGeometry { Figures = { figure } };
+ wavePath.StrokeThickness = 2;
+ wavePath.Stroke = brush;
+ }
+
+ ///
/// 绘制渐变的条形
///
/// 绘图目标
diff --git a/Correlator/Util/AudioVisualizer.cs b/Correlator/Util/AudioVisualizer.cs
index a5153f6..739b32d 100644
--- a/Correlator/Util/AudioVisualizer.cs
+++ b/Correlator/Util/AudioVisualizer.cs
@@ -58,7 +58,7 @@
}
///
- /// 获取频谱数据 (数据已经删去共轭部分)
+ /// 获取频域数据,采样数据(时域)转频域
///
///
public double[] GetSpectrumData()