here is my class I made a // comment for the error

'my class'
using System;
using System.Drawing;
using System.Windows.Forms;
using NAudio.Dsp;
using NAudio.Wave;

public class AudioVisualizer : IDisposable
{
    private readonly Panel _panel;
    private readonly Color _barColor;
    private readonly int _barCount;
    private readonly int _fftLength = 1024; // power of two for FFT

    private readonly Complex[] _fftComplexBuffer;
    private readonly float[] _fftBuffer;
    private float[] _previousBarHeights;

    private BufferedWaveProvider _bufferedWaveProvider;

    private System.Windows.Forms.Timer _refreshTimer;

    private Bitmap _offscreenBitmap;

    private const float DecayFactor = 0.05f; // controls how fast bars fall

    // New: no internal capture, external wave provider instead
    public AudioVisualizer(Panel panel, IWaveProvider waveProvider, Color barColor, int barCount = 32)
    {
        if (panel == null) throw new ArgumentNullException(nameof(panel));
        if (waveProvider == null) throw new ArgumentNullException(nameof(waveProvider));

        _panel = panel;
        _barColor = barColor;
        _barCount = barCount;

        _fftComplexBuffer = new Complex[_fftLength];
        _fftBuffer = new float[_fftLength];
        _previousBarHeights = new float[_barCount];

        _bufferedWaveProvider = new BufferedWaveProvider(waveProvider.WaveFormat)
        {
            BufferLength = _fftLength * 4,
            DiscardOnBufferOverflow = true,
        };

        // Start a background thread or use a timer to read samples from waveProvider and enqueue to bufferedWaveProvider
        // Because IWaveProvider is pull-based, you need to periodically read from it.

        StartReadingFromWaveProvider(waveProvider);

        SetupTimer();

        EnableDoubleBuffering(_panel);
        _panel.BackColor = Color.Black;

        // Hook Paint event for rendering
        _panel.Paint += Panel_Paint;
        _panel.Resize += Panel_Resize;
    }

    private System.Threading.Thread _readThread;
    private bool _reading;

    private void StartReadingFromWaveProvider(IWaveProvider waveProvider)
    {
        _reading = true;
        _readThread = new System.Threading.Thread(() =>
        {
            int bufferSize = 4096;
            byte[] buffer = new byte[bufferSize];
            while (_reading)
            {
                int bytesRead = waveProvider.Read(buffer, 0, buffer.Length); // System.NullReferenceException: 'Object reference not set to an instance of an object.' ERROR GPT
                if (bytesRead > 0)
                {
                    _bufferedWaveProvider.AddSamples(buffer, 0, bytesRead);
                }
                else
                {
                    System.Threading.Thread.Sleep(10); // no data, avoid busy waiting
                }
            }
        })
        {
            IsBackground = true,
            Name = "AudioVisualizerWaveProviderReadThread"
        };
        _readThread.Start();
    }

    private void SetupTimer()
    {
        _refreshTimer = new System.Windows.Forms.Timer();
        _refreshTimer.Interval = 15; // ~66 FPS smooth animation
        _refreshTimer.Tick += (s, e) => _panel.Invalidate();
        _refreshTimer.Start();
    }

    // Removed WasapiLoopbackCapture and SetupAudioCapture method entirely

    // Removed Capture_DataAvailable since no capture events anymore

    private void Panel_Resize(object sender, EventArgs e)
    {
        _offscreenBitmap?.Dispose();
        _offscreenBitmap = new Bitmap(_panel.ClientSize.Width, _panel.ClientSize.Height);
    }

    private void Panel_Paint(object sender, PaintEventArgs e)
    {
        if (_panel.ClientSize.Width == 0 || _panel.ClientSize.Height == 0)
            return; // nothing to paint

        if (_offscreenBitmap == null ||
            _offscreenBitmap.Width != _panel.ClientSize.Width ||
            _offscreenBitmap.Height != _panel.ClientSize.Height)
        {
            _offscreenBitmap?.Dispose();
            _offscreenBitmap = new Bitmap(_panel.ClientSize.Width, _panel.ClientSize.Height);
        }

        byte[] audioBytes = new byte[_fftLength * 4];
        int bytesRead = _bufferedWaveProvider.Read(audioBytes, 0, audioBytes.Length);
        if (bytesRead == 0)
        {
            // No data, smooth decay bars to zero
            DecayBars(_panel.ClientSize.Height);
            DrawBars(e.Graphics, _panel.ClientSize.Width, _panel.ClientSize.Height);
            return;
        }

        int samplesRead = bytesRead / 4; // 4 bytes per 32-bit float

        // Convert bytes to floats
        for (int i = 0; i < _fftLength; i++)
        {
            if (i < samplesRead)
                _fftBuffer[i] = BitConverter.ToSingle(audioBytes, i * 4);
            else
                _fftBuffer[i] = 0f;
        }

        for (int i = 0; i < _fftLength; i++)
        {
            _fftComplexBuffer[i].X = (float)(_fftBuffer[i] * FastFourierTransform.HammingWindow(i, _fftLength));
            _fftComplexBuffer[i].Y = 0f;
        }

        FastFourierTransform.FFT(true, (int)Math.Log(_fftLength, 2.0), _fftComplexBuffer);

        UpdateBarHeights(_panel.ClientSize.Height);

        using (var g = Graphics.FromImage(_offscreenBitmap))
        {
            g.Clear(Color.Transparent);
            DrawBars(g, _panel.ClientSize.Width, _panel.ClientSize.Height);
        }

        e.Graphics.DrawImageUnscaled(_offscreenBitmap, 0, 0);
    }

    private void UpdateBarHeights(int panelHeight)
    {
        int bars = _barCount;
        int binsPerBar = (_fftLength / 2) / bars;

        for (int bar = 0; bar < bars; bar++)
        {
            int start = bar * binsPerBar;
            int end = (bar + 1) * binsPerBar;

            double avgMagnitude = 0;

            for (int bin = start; bin < end; bin++)
            {
                float re = _fftComplexBuffer[bin].X;
                float im = _fftComplexBuffer[bin].Y;
                double mag = Math.Sqrt(re * re + im * im);
                avgMagnitude += mag;
            }
            avgMagnitude /= binsPerBar;

            double db = 20 * Math.Log10(avgMagnitude);
            if (double.IsInfinity(db) || db < -100)
                db = -100;

            double norm = (db + 100) / 100; // 0..1

            float targetHeight = (float)(norm * panelHeight);
            if (targetHeight > _previousBarHeights[bar])
            {
                _previousBarHeights[bar] = targetHeight;
            }
            else
            {
                _previousBarHeights[bar] -= DecayFactor * panelHeight;
                if (_previousBarHeights[bar] < 0)
                    _previousBarHeights[bar] = 0;
            }
        }
    }

    private void DecayBars(int panelHeight)
    {
        for (int i = 0; i < _previousBarHeights.Length; i++)
        {
            _previousBarHeights[i] -= DecayFactor * panelHeight;
            if (_previousBarHeights[i] < 0)
                _previousBarHeights[i] = 0;
        }
    }

    private void DrawBars(Graphics g, int width, int height)
    {
        int barWidth = Math.Max(width / _barCount, 2);
        float spacing = 2;

        using (Brush brush = new SolidBrush(_barColor))
        {
            for (int i = 0; i < _barCount; i++)
            {
                float x = i * (barWidth + spacing);
                float barHeight = _previousBarHeights[i];
                float y = height - barHeight;

                if (barHeight > 0)
                    g.FillRectangle(brush, x, y, barWidth, barHeight);
            }
        }
    }

    private void EnableDoubleBuffering(Control control)
    {
        var prop = typeof(Control).GetProperty("DoubleBuffered", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
        prop?.SetValue(control, true);
    }

    public void Dispose()
    {
        _reading = false;
        try
        {
            _readThread?.Join(500);
        }
        catch { }

        _refreshTimer?.Stop();
        _refreshTimer?.Dispose();
        _refreshTimer = null;

        _offscreenBitmap?.Dispose();
        _offscreenBitmap = null;

        _panel.Paint -= Panel_Paint;
        _panel.Resize -= Panel_Resize;
    }
}

my use of class

public async Task PlayAudio(InputSimulator ISim, TimeSpan duration, bool bypass, bool combo)
{
    if (NoPlayMode) return;

    // Cancel any ongoing playback
    if (_isPlaying)
    {
        _cancellationTokenSource.Cancel();
        _cancellationTokenSource.Dispose();
        _cancellationTokenSource = new CancellationTokenSource();
    }

    _isPlaying = true;

    try
    {
        if (ChatCombo)
        {
            if (PartyMode)
            {
                ISim.Keyboard.KeyPress(VirtualKeyCode.RETURN);
                await Task.Delay(10);

                ISim.Keyboard.TextEntry("/party");
                await Task.Delay(10);

                ISim.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LCONTROL, VirtualKeyCode.VK_V);
                await Task.Delay(10);

                ISim.Keyboard.KeyPress(VirtualKeyCode.RETURN);
            }
            else
            {
                ISim.Keyboard.KeyPress(VirtualKeyCode.RETURN);
                await Task.Delay(11);

                ISim.Keyboard.TextEntry("/team");
                await Task.Delay(11);

                string messages = await ClipboardWpf.GetTextAsync();
                await ClipboardWpf.SetTextAsync(messages);
                await Task.Delay(11);

                ISim.Keyboard.ModifiedKeyStroke(VirtualKeyCode.LCONTROL, VirtualKeyCode.VK_V);
                await Task.Delay(11);

                ISim.Keyboard.KeyPress(VirtualKeyCode.RETURN);
            }
        }

        CancellationToken token = _cancellationTokenSource.Token;

        // Stop existing playback, dispose resources
        if (_waveOut?.PlaybackState == PlaybackState.Playing)
        {
            _waveOut.Stop();
            _audioFileReader?.Dispose();
            _waveOut.Dispose();
        }

        // Setup playback
        _waveOut = new WaveOutEvent
        {
            DeviceNumber = OutDev,
            Volume = vol
        };
        _audioFileReader = new AudioFileReader(audioFilePath);
        _waveOut.Init(_audioFileReader);
        _waveOut.Play();

        var visualizer = new AudioVisualizer(panelVisualizer, _audioFileReader, Color.LimeGreen, 32);

        // Handle push-to-talk key press
        if (!bypass)
        {
            keyToPress = PartyMode ? VirtualKeyCode.VK_0 : VirtualKeyCode.VK_9;
            if (P2T)
                ISim.Keyboard.KeyDown(keyToPress);
        }

        // Wait duration + buffer
        await Task.Delay(duration.Add(TimeSpan.FromMilliseconds(200)), token);

        // Release push-to-talk key after playback duration
        if (P2T && !bypass)
            ISim.Keyboard.KeyUp(keyToPress);

        // Wait for playback to actually stop or cancellation
        while (_waveOut.PlaybackState == PlaybackState.Playing && !token.IsCancellationRequested)
            await Task.Delay(166, token);

        // Clean up audio resources if not cancelled
        if (!token.IsCancellationRequested)
        {
            _audioFileReader?.Dispose();
            _waveOut.Stop();
            _waveOut.Dispose();
        }

        // Extra action if configured and not using P2T
        if (!P2T && ConfMode && !token.IsCancellationRequested)
        {
            //PlayWavFile(@"C:\Users\DjZaN\OneDrive\Desktop\Digital_Breath\Content\SFX\Ready.wav");
        }
    }
    catch (TaskCanceledException)
    {

    }
    catch (Exception ex)
    {
    }
    finally
    {
        _isPlaying = false;
        if (RealisticVolume)
            volumeSlider1.Volume = vol;
    }
}

if you have to change either script then provide either script back in full fixed tysm.