WaveSurfer waveform is not cleared when starting a new recording
Overview
When a user starts a new audio recording, the waveform from the previous recording remains visible instead of being cleared. This causes stale waveform data to persist in the UI and creates confusion about the currently active recording.
Current Behavior
- Record an audio clip.
- Start a new recording.
- The previous waveform remains visible and overlaps with the new recording session.
- The waveform appears to be cached and is not properly reset.
Expected Behavior
- Previous waveform should be completely removed when a new recording starts.
- A fresh WaveSurfer instance should be initialized for each recording session.
- Only the waveform of the current recording should be displayed.
Impact
- Confusing user experience due to stale waveform visualization.
- Potential memory leaks from unmanaged WaveSurfer instances.
- Inconsistent UI state across multiple recording sessions.
Proposed Solution
- Destroy the existing WaveSurfer instance before creating a new one.
- Clear the waveform container during recording initialization.
- Reset audio-related state, references, and cached waveform data.
- Ensure only one active WaveSurfer instance exists at any time.
Acceptance Criteria
- Previous waveform is removed when a new recording starts.
- Only the current recording's waveform is displayed.
- No waveform artifacts remain after multiple recording sessions.
- WaveSurfer instances are properly cleaned up to prevent memory leaks.
Edited by srilatha bandari