Gapless playback, crossfade and volume levelling

- Two-deck player keeps the next song loaded and buffered, and blends it in 20 ms
  before the current one ends, so albums and playlists play without gaps
- Skipping to the next song uses the preloaded deck, so it starts instantly
- Optional crossfade (up to 12 s); songs from the same album stay gapless
- Optional volume levelling: uses ReplayGain tags or measures each song once
  (-14 LUFS, capped so boosts never clip); files are never changed
- Playback section at the top of Settings
This commit is contained in:
Christian
2026-11-18 22:25:12 -05:00
parent f6db780bca
commit 93db117243
9 changed files with 371 additions and 31 deletions
+27
View File
@@ -330,3 +330,30 @@ function bindPlayer() {
updateTime();
updateVolume();
}
/* playback settings */
function renderPlaybackSettings() {
const r = $("#xfRange");
if (!r) return;
if (document.activeElement !== r) r.value = String(Player.crossfade);
rangeFill(r);
$("#xfVal").textContent = Player.crossfade ? `${Player.crossfade} s` : "Off";
$("#xfNote").textContent = Player.crossfade
? `Songs blend over ${Player.crossfade} seconds. Songs from the same album still play gapless, so live and continuous albums flow.`
: "Off. The next song is always loaded ahead, so songs play back to back with no gap.";
$("#levelToggle").checked = Player.leveling;
}
function bindPlaybackSettings() {
const r = $("#xfRange");
if (!r) return;
r.addEventListener("input", () => {
Player.setCrossfade(r.value);
renderPlaybackSettings();
});
$("#levelToggle").addEventListener("change", (e) => Player.setLeveling(e.target.checked));
window.addEventListener("player", (e) => {
if (e.detail.type === "settings") renderPlaybackSettings();
});
renderPlaybackSettings();
}