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:
+11
-1
@@ -139,10 +139,17 @@ typedef struct {
|
||||
// Display settings
|
||||
float amplitudeFloorDb;
|
||||
float amplitudeCeilingDb;
|
||||
bool amplitudeUserSet; // true once the user adjusts the dB floor; suppresses auto-scale
|
||||
ColormapType colormap;
|
||||
bool showGrid;
|
||||
int fftSize; // Current FFT size (128-2048)
|
||||
|
||||
// Cached synchrosqueezed energy (the expensive reassignment result).
|
||||
// Reused across dB-floor / colormap changes — only re-colorized, not recomputed.
|
||||
float* reassignBuffer;
|
||||
int reassignWidth;
|
||||
int reassignHeight;
|
||||
|
||||
// File browser state
|
||||
bool showFileBrowser;
|
||||
char browserPath[512];
|
||||
@@ -174,7 +181,6 @@ typedef struct {
|
||||
// filled in at full resolution in the background while the user is idle.
|
||||
int bgHighResSeg; // next segment index to compute at high-res
|
||||
bool bgFinished; // true when all segments are computed at high-res
|
||||
int lastInteractedFrame; // frame counter when last user interaction occurred
|
||||
bool isBgProcessing; // true while background task is actively computing
|
||||
|
||||
// FFT size cache — LRU cache of previously computed STFT results.
|
||||
@@ -202,6 +208,10 @@ extern Sound AudioPlaybackSound;
|
||||
extern Texture2D colormapTexture;
|
||||
extern Font mainFont;
|
||||
|
||||
// Reset all per-signal state after a new signal is loaded into app.signal
|
||||
// (defined in spectrogram.c; used by every load path).
|
||||
void ResetForNewSignal(void);
|
||||
|
||||
// ============================================================================
|
||||
// Small math helpers (header-inline so every module can use them)
|
||||
// ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user