mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-21 22:15:40 +00:00
feat(player,queue): loudness strip controls and normalization readout fixes
- Add Tauri command to delete loudness_cache rows for a track and helpers in AnalysisCache. - Queue tech strip: click dB to reseed loudness; LUFS target picker via body portal; metric styling aligned with strip (no link chrome). - Player store: reseed clears local cache and replays analysis seed; show loudness dB from SQLite cache when live state is still null; allow first numeric normalization-state update through the short duplicate filter. - audio_update_replay_gain: resolve loudness from the requested gain when playback URL is not pinned yet.
This commit is contained in:
@@ -83,6 +83,25 @@ impl AnalysisCache {
|
||||
Ok(Self { conn: Mutex::new(conn) })
|
||||
}
|
||||
|
||||
/// Remove all `loudness_cache` rows for this logical track (bare id and `stream:` variant).
|
||||
pub fn delete_loudness_for_track_id(&self, track_id: &str) -> Result<u64, String> {
|
||||
if track_id.trim().is_empty() {
|
||||
return Ok(0);
|
||||
}
|
||||
let conn = self
|
||||
.conn
|
||||
.lock()
|
||||
.map_err(|_| "analysis_cache lock poisoned".to_string())?;
|
||||
let mut total: u64 = 0;
|
||||
for tid in track_id_cache_variants(track_id) {
|
||||
let n = conn
|
||||
.execute("DELETE FROM loudness_cache WHERE track_id = ?1", params![tid])
|
||||
.map_err(|e| e.to_string())?;
|
||||
total = total.saturating_add(n as u64);
|
||||
}
|
||||
Ok(total)
|
||||
}
|
||||
|
||||
pub fn touch_track_status(&self, key: &TrackKey, status: &str) -> Result<(), String> {
|
||||
let now = now_unix_ts();
|
||||
let conn = self.conn.lock().map_err(|_| "analysis_cache lock poisoned".to_string())?;
|
||||
|
||||
@@ -4053,9 +4053,13 @@ pub fn audio_update_replay_gain(
|
||||
} else {
|
||||
None
|
||||
};
|
||||
// If `current_playback_url` is not pinned yet, still honour JS `loudness_gain_db`
|
||||
// so `loudness_ui_current_gain_db` can show a number (otherwise `and_then`
|
||||
// drops the requested gain entirely).
|
||||
let resolved_loudness_gain_db = url_for_loudness
|
||||
.as_deref()
|
||||
.and_then(|u| resolve_loudness_gain_from_cache(&app, u, target_lufs, loudness_gain_db));
|
||||
.and_then(|u| resolve_loudness_gain_from_cache(&app, u, target_lufs, loudness_gain_db))
|
||||
.or(loudness_gain_db);
|
||||
let effective_loudness_db = if norm_mode == 2 {
|
||||
match url_for_loudness.as_deref() {
|
||||
Some(u) => loudness_gain_db_or_startup(&app, u, target_lufs, loudness_gain_db),
|
||||
|
||||
@@ -1250,6 +1250,14 @@ fn analysis_get_loudness_for_track(
|
||||
}}))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn analysis_delete_loudness_for_track(
|
||||
track_id: String,
|
||||
cache: tauri::State<'_, analysis_cache::AnalysisCache>,
|
||||
) -> Result<u64, String> {
|
||||
cache.delete_loudness_for_track_id(&track_id)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn analysis_enqueue_seed_from_url(
|
||||
track_id: String,
|
||||
@@ -4099,6 +4107,7 @@ pub fn run() {
|
||||
analysis_get_waveform,
|
||||
analysis_get_waveform_for_track,
|
||||
analysis_get_loudness_for_track,
|
||||
analysis_delete_loudness_for_track,
|
||||
analysis_enqueue_seed_from_url,
|
||||
download_track_offline,
|
||||
delete_offline_track,
|
||||
|
||||
Reference in New Issue
Block a user