feat: per-user volume leveling preference, synced across devices (M464 #4998)
release / govulncheck (push) Successful in 22s
release / go (push) Successful in 1m17s
release / web (push) Failing after 1m5s
release / android (push) Failing after 1m51s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / integration (push) Canceled after 4m12s
release / Build signed APK (releases and dev) (push) Canceled after 3m21s
release / govulncheck (push) Successful in 22s
release / go (push) Successful in 1m17s
release / web (push) Failing after 1m5s
release / android (push) Failing after 1m51s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / integration (push) Canceled after 4m12s
release / Build signed APK (releases and dev) (push) Canceled after 3m21s
Mode (off, auto, track, album), target (-18, -16, -14 LUFS) and boost (within headroom, or fully with a limiter), stored per user on the server so the web player, the Android app and casts apply the same one. - Server: user_normalization_prefs (migration 0067), GET/PUT /api/me/normalization; a whole-body PUT, validated, last write wins. - Web: Settings > Playback > Volume leveling. Saves at once, restores the old choice if the save fails, and caches the value for the player. - Android: Settings card. The device keeps a copy for offline playback (Room v9 with an explicit migration, so the upgrade wipes nothing). Writes are offline-first: shown at once, PUT best effort, queued on failure (NORMALIZATION_SET, collapsed to the newest). A refresh never overwrites a change still queued. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { api } from './client';
|
||||
|
||||
// Loudness normalization preference (M464 #4998). One per user, stored on
|
||||
// the server so the web player, the Android app and casts agree.
|
||||
export type NormalizationMode = 'off' | 'auto' | 'track' | 'album';
|
||||
export type NormalizationTarget = -18 | -16 | -14;
|
||||
export type NormalizationBoost = 'headroom' | 'limiter';
|
||||
|
||||
export type NormalizationPrefs = {
|
||||
mode: NormalizationMode;
|
||||
target_lufs: NormalizationTarget;
|
||||
boost: NormalizationBoost;
|
||||
};
|
||||
|
||||
// Must match library.DefaultNormalizationPrefs on the server.
|
||||
export const DEFAULT_NORMALIZATION: NormalizationPrefs = {
|
||||
mode: 'auto',
|
||||
target_lufs: -18,
|
||||
boost: 'headroom'
|
||||
};
|
||||
|
||||
export const NORMALIZATION_MODES: NormalizationMode[] = ['off', 'auto', 'track', 'album'];
|
||||
export const NORMALIZATION_TARGETS: NormalizationTarget[] = [-18, -16, -14];
|
||||
|
||||
export function isNormalizationPrefs(v: unknown): v is NormalizationPrefs {
|
||||
if (typeof v !== 'object' || v === null) return false;
|
||||
const p = v as Record<string, unknown>;
|
||||
return (
|
||||
NORMALIZATION_MODES.includes(p.mode as NormalizationMode) &&
|
||||
NORMALIZATION_TARGETS.includes(p.target_lufs as NormalizationTarget) &&
|
||||
(p.boost === 'headroom' || p.boost === 'limiter')
|
||||
);
|
||||
}
|
||||
|
||||
export function getNormalization(): Promise<NormalizationPrefs> {
|
||||
return api.get<NormalizationPrefs>('/api/me/normalization');
|
||||
}
|
||||
|
||||
// The whole preference is sent every time; the server keeps the last write.
|
||||
export function putNormalization(p: NormalizationPrefs): Promise<NormalizationPrefs> {
|
||||
return api.put<NormalizationPrefs>('/api/me/normalization', p);
|
||||
}
|
||||
Reference in New Issue
Block a user