perf+ux: cache reassignment, keep manual dB floor, dedupe load paths
- Split GenerateSpectrogramTexture into ComputeSpectrogramReassignment (the expensive synchrosqueezing, cached in app.reassignBuffer) and ColorizeSpectrogram (cheap). dB-floor and colormap changes now only re-colorize instead of recomputing the whole reassignment every frame — the dB slider and colormap switching are smooth on large files. - AutoScaleAmplitude no longer overwrites a dB floor the user set by hand (amplitudeUserSet flag, reset per file load). - Extract ResetForNewSignal() used by all three load paths; removes the duplicated reset blocks and the double ComputeSTFTInit per load. Drag-drop now resets the selection like the browser already did. - Remove the dead lastInteractedFrame field. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -112,28 +112,8 @@ static void LoadSelectedFile(void)
|
||||
if (app.browserIsDir[app.browserSelected]) {
|
||||
NavigateToDirectory(app.browserFiles[app.browserSelected]);
|
||||
} else if (FileExists(filePath) && LoadWavFile(filePath, &app.signal)) {
|
||||
app.loaded = true;
|
||||
app.stftComputed = false;
|
||||
app.loadingPhase = 0;
|
||||
app.loadingProgress = 0.0f;
|
||||
app.currentSTFTSegment = 0;
|
||||
app.skipFactor = 1;
|
||||
app.highResFinished = false;
|
||||
app.bgHighResSeg = 0;
|
||||
app.bgFinished = false;
|
||||
app.isBgProcessing = false;
|
||||
// Signal changed — free cache (results are tied to signal data)
|
||||
FreeAllCacheEntries(&app.fftCache);
|
||||
app.timeSelectionStart = app.viewStart = 0.0f;
|
||||
app.timeSelectionEnd = app.viewEnd = 1.0f;
|
||||
app.freqSelectionStart = 0.0f;
|
||||
app.freqSelectionEnd = 1.0f;
|
||||
ResetForNewSignal();
|
||||
app.showFileBrowser = false;
|
||||
ComputeSTFTInit(&app.signal, &app.stft, app.fftSize);
|
||||
// Invalidate visible texture cache
|
||||
if (app.visibleTexture.id != 0) UnloadTexture(app.visibleTexture);
|
||||
app.visibleTexture = (Texture2D){ 0 };
|
||||
app.visibleTextureValid = false;
|
||||
TraceLog(LOG_INFO, "Loaded: %s", filePath);
|
||||
}
|
||||
}
|
||||
@@ -382,6 +362,7 @@ void DrawSidebar(void)
|
||||
DrawSlider(dbSlider, dbValue);
|
||||
if (UpdateSlider(dbSlider, &dbValue)) {
|
||||
app.amplitudeFloorDb = -100.0f + dbValue * 80.0f;
|
||||
app.amplitudeUserSet = true; // stop auto-scale from overwriting this
|
||||
needsRegen = true;
|
||||
}
|
||||
y += 28 * scale;
|
||||
@@ -511,7 +492,8 @@ void DrawSidebar(void)
|
||||
}
|
||||
|
||||
if (needsRegen && app.stftComputed) {
|
||||
GenerateSpectrogramTexture(&app.stft, &app.spectrogramImage, &app.spectrogramTexture);
|
||||
// dB floor / colormap only — re-map the cached reassignment, don't recompute it.
|
||||
ColorizeSpectrogram(&app.spectrogramImage, &app.spectrogramTexture);
|
||||
app.visibleTextureValid = false; // Force cache invalidation
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user