diff --git a/src-tauri/src/analysis_cache.rs b/src-tauri/src/analysis_cache.rs
index b31e72c0..582d5ba3 100644
--- a/src-tauri/src/analysis_cache.rs
+++ b/src-tauri/src/analysis_cache.rs
@@ -14,9 +14,18 @@ use symphonia::core::meta::MetadataOptions;
use symphonia::core::probe::Hint;
use tauri::Manager;
-pub const WAVEFORM_ALGO_VERSION: i64 = 3;
+pub const WAVEFORM_ALGO_VERSION: i64 = 4;
pub const LOUDNESS_ALGO_VERSION: i64 = 1;
+/// Bins in waveform BLOB: `2 * bin_count` bytes (peak u8, then mean-abs u8 per time bin).
+pub fn waveform_cache_blob_len_ok(bins: &[u8], bin_count: i64) -> bool {
+ if bin_count <= 0 {
+ return false;
+ }
+ let n = bin_count as usize;
+ bins.len() == n.saturating_mul(2)
+}
+
#[derive(Debug, Clone)]
pub struct TrackKey {
pub track_id: String,
@@ -200,8 +209,9 @@ impl AnalysisCache {
pub fn get_waveform(&self, key: &TrackKey) -> Result