diff --git a/src/spectrogram.c b/src/spectrogram.c index 7b27974..6cbdb83 100644 --- a/src/spectrogram.c +++ b/src/spectrogram.c @@ -118,9 +118,24 @@ void ResetForNewSignal(void) // Cached STFT results are tied to the old signal data. FreeAllCacheEntries(&app.fftCache); - // Reset view + selection to full range. + // Zoom out both axes and drop the old selection / any in-progress drags. + // Display preferences (colormap, dB scale, FFT size, grid, scope layout) + // are intentionally preserved across loads. app.view.start = 0.0f; app.view.end = 1.0f; + app.view.freqStart = 0.0f; app.view.freqEnd = 1.0f; + app.view.isPanning = false; ClearSelection(); + app.sel.isDragging = false; + app.sel.isTimeSelecting = false; + app.sel.isFreqSelecting = false; + app.isDividing = false; + + // Stop any playback from the previous signal and rewind the playhead. + if (app.isPlaying && AudioPlaybackSound.frameCount > 0) StopSound(AudioPlaybackSound); + app.isPlaying = false; + app.playbackFinished = false; + app.playheadElapsed = 0.0f; + app.playheadT = 0.0f; // Invalidate the cached visible texture. if (app.visibleTexture.id != 0) UnloadTexture(app.visibleTexture);