private void DrawData(double[] data, Graphics g, Converter cvter) { var chkpoint2 = DateTime.Now; if (data == null || data.Length == 0 || sourceData == null) { return; } float ratioFreq = (float)panel1.Width / (float)data.Length;; float ratioFreqTest = (float)panel1.Width / 200; float ratioWave = (float)panel1.Width / (float)sourceData.Length; float value = 0; gTempBuffer.DrawImage(mainBuffer, new Rectangle(0, 0, tempBuffer.Width, tempBuffer.Height), 0, 0, mainBuffer.Width, mainBuffer.Height, GraphicsUnit.Pixel); //BitmapFilter.GaussianBlur(mainBuffer as Bitmap, 5); gMainBuffer.DrawImage(tempBuffer, new Rectangle(-2, -1, mainBuffer.Width + 4, mainBuffer.Height + 3), 0, 0, tempBuffer.Width, tempBuffer.Height, GraphicsUnit.Pixel, imgAttribute); int sx, sy; for (int i = 0; i < data.Length; i++) { cvter.FromReal(i * ratioFreq, 0, out sx, out sy); value = (float)(data[i] * cvt.MaxScaledY); gMainBuffer.FillRectangle(Constants.Brushes.redLightBrush, i * ratioFreq, sy, ratioFreq - 1, value / 2); } for (int i = 0; i < sourceData.Length - 4; i += 4) { cvter.FromReal(i * ratioWave, 0, out sx, out sy); gMainBuffer.DrawLine(new Pen(Constants.Brushes.blueBrush), new PointF(i * ratioWave, sy - (int)(sourceData[i] * 150 * MasterScaleFFT) + 2), new PointF((i + 4) * ratioWave, sy - (int)(sourceData[i + 4] * 150 * MasterScaleFFT) + 2)); } g.DrawImage(mainBuffer, new Point(0, 0)); for (int i = 0; i < data.Length; i++) { cvter.FromReal(i * ratioFreq, 0, out sx, out sy); value = (float)(data[i] * cvt.MaxScaledY); g.FillRectangle(Constants.Brushes.redBrush, i * ratioFreq, sy - value / 2, ratioFreq - 1, value / 2); } #region BeatDetector (Don't know what will to, just code) double newBass = 0, accumBass = 0; bool beatDetected = BeatDetector.Scan(data, 6, 13, ref accumBass, ref newBass); #endregion osdPanel.AddSet("Drawing delay(ms):", DateTime.Now.Subtract(chkpoint2).TotalMilliseconds.ToString()); }