make this render a way prettier waveform kinda like soundcloud

using System;
using System.Drawing;
using System.Windows.Forms;
using NAudio.Wave;

namespace WaveformDemo
{
    public class WaveformRenderer : IDisposable
    {
        private readonly Panel _panel;
        private readonly Color _backgroundColor;
        private readonly Color _waveformColor;
        private readonly Color _borderColor;
        private float[] _waveformPoints = new float[0]; // normalized waveform data [-1..1]
        private readonly string _audioFilePath;
        private bool _dataReady = false;

        public WaveformRenderer(string audioFilePath, Panel panel, Color backgroundColor, Color waveformColor, Color borderColor)
        {
            if (string.IsNullOrWhiteSpace(audioFilePath))
                throw new ArgumentException("audioFilePath cannot be null or empty");

            _audioFilePath = audioFilePath;
            _panel = panel ?? throw new ArgumentNullException(nameof(panel));
            _backgroundColor = backgroundColor;
            _waveformColor = waveformColor;
            _borderColor = borderColor;

            _panel.Paint += Panel_Paint;
            _panel.Resize += Panel_Resize;
            if (_panel.Width > 5)
                LoadWaveform();
            else
                _panel.SizeChanged += Panel_SizeChanged;
        }

        private void Panel_SizeChanged(object sender, EventArgs e)
        {
            if (_panel.Width > 5)
            {
                _panel.SizeChanged -= Panel_SizeChanged;
                LoadWaveform();
                _panel.Invalidate();
            }
        }

        private void LoadWaveform()
        {
            try
            {
                using (var reader = new AudioFileReader(_audioFilePath))
                {
                    int width = _panel.Width;
                    int height = _panel.Height;

                    if (width <= 5 || height <= 5)
                    {
                        _dataReady = false;
                        return;
                    }

                    int channels = reader.WaveFormat.Channels;
                    long totalSamples = reader.Length / (reader.WaveFormat.BitsPerSample / 8);

                    int samplesPerPixel = (int)(totalSamples / width / channels);
                    if (samplesPerPixel < 1) samplesPerPixel = 1;

                    _waveformPoints = new float[width];
                    float[] buffer = new float[samplesPerPixel * channels];

                    int pixelsFilled = 0;
                    reader.Position = 0;

                    while (pixelsFilled < width)
                    {
                        int samplesRead = reader.Read(buffer, 0, buffer.Length);
                        if (samplesRead == 0) break;

                        float maxSample = 0f;
                        int samples = samplesRead / channels;

                        for (int i = 0; i < samples; i++)
                        {
                            for (int ch = 0; ch < channels; ch++)
                            {
                                float sample = buffer[i * channels + ch];
                                if (Math.Abs(sample) > Math.Abs(maxSample)) maxSample = sample;
                            }
                        }

                        if (pixelsFilled < width)
                            _waveformPoints[pixelsFilled++] = maxSample;
                    }

                    // fill remaining with zeros
                    for (int i = pixelsFilled; i < width; i++)
                        _waveformPoints[i] = 0f;

                    // Check if waveform data is basically silent
                    bool allZero = true;
                    foreach (var v in _waveformPoints)
                    {
                        if (Math.Abs(v) > 0.0001f)
                        {
                            allZero = false;
                            break;
                        }
                    }

                    _dataReady = !allZero;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error loading audio file waveform:\n" + ex.Message);
                _dataReady = false;
            }
        }

        private void Panel_Resize(object sender, EventArgs e)
        {
            if (_panel.Width > 5 && _panel.Height > 5)
            {
                LoadWaveform();
                _panel.Invalidate();
            }
        }

        private void Panel_Paint(object sender, PaintEventArgs e)
        {
            var g = e.Graphics;

            // Draw background
            using (var bgBrush = new SolidBrush(_backgroundColor))
            {
                g.FillRectangle(bgBrush, _panel.ClientRectangle);
            }

            if (!_dataReady || _waveformPoints.Length == 0)
            {
                // Show message
                using (var brush = new SolidBrush(Color.Gray))
                using (var sfmt = new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
                {
                    g.DrawString("Waveform unavailable", SystemFonts.DefaultFont, brush, _panel.ClientRectangle, sfmt);
                }
            }
            else
            {
                int midY = _panel.Height / 2;

                // Scale factor: exaggerate waveform if it looks flat
                float maxAmplitude = 0f;
                foreach (var v in _waveformPoints)
                {
                    if (Math.Abs(v) > maxAmplitude) maxAmplitude = Math.Abs(v);
                }
                if (maxAmplitude < 0.01f) maxAmplitude = 0.01f; // prevent division by zero or too small

                // Scale waveform vertically to use 90% of panel height
                float verticalScale = (midY * 0.9f) / maxAmplitude;

                using (var pen = new Pen(_waveformColor))
                {
                    for (int x = 0; x < _waveformPoints.Length - 1; x++)
                    {
                        float y1 = midY - (_waveformPoints[x] * verticalScale);
                        float y2 = midY - (_waveformPoints[x + 1] * verticalScale);
                        g.DrawLine(pen, x, y1, x + 1, y2);
                    }
                }
            }

            // Draw border
            using (var borderPen = new Pen(_borderColor, 2))
            {
                var rect = _panel.ClientRectangle;
                rect.Width -= 1;
                rect.Height -= 1;
                g.DrawRectangle(borderPen, rect);
            }
        }

        public void Dispose()
        {
            _panel.Paint -= Panel_Paint;
            _panel.Resize -= Panel_Resize;
            _panel.SizeChanged -= Panel_SizeChanged;
        }
    }
}