feat(web): crossfade between tracks (Tier C11)
test-web / test (push) Successful in 31s
test-go / test (pull_request) Successful in 34s
test-web / test (pull_request) Successful in 42s
android / Build + lint + test (pull_request) Successful in 5m4s
android / Build signed release APK (pull_request) Has been skipped
test-go / integration (pull_request) Successful in 11m1s
test-web / test (push) Successful in 31s
test-go / test (pull_request) Successful in 34s
test-web / test (pull_request) Successful in 42s
android / Build + lint + test (pull_request) Successful in 5m4s
android / Build signed release APK (pull_request) Has been skipped
test-go / integration (pull_request) Successful in 11m1s
Operator-tunable 0-12s crossfade in Settings → Playback. Default 0 (off). Most albums sound best at 0 — gapless masters, classical, and live recordings all suffer noticeable crossfades. Implementation: pure-function position-derived volume scalar. `deriveFadeScalar(position, duration, crossfadeSec)` ramps from 0 to 1 over the leading X seconds, 1 to 0 over the trailing X seconds, and stays at 1 in between. Tracks shorter than 2X don't fade. The layout's audio-volume effect now multiplies player.volume by the fade scalar — no timers, no AudioContext, no element swapping. Re-renders at the ~4Hz `timeupdate` cadence give 16 discrete steps over a 4s fade, audibly close to smooth. Smoothing to per-frame ramps via rAF is a follow-up if needed. Setting persists to localStorage as `minstrel.crossfade` (matches the existing volume-storage convention). Tests cover the pure derivation (off, too-short track, fade-in, fade-out) + clamp/persist on setCrossfade + invalid-input recovery on readStoredCrossfade.
This commit is contained in:
@@ -18,7 +18,8 @@
|
||||
reportStateFromAudio,
|
||||
player,
|
||||
closeQueueDrawer,
|
||||
consumePendingRestorePosition
|
||||
consumePendingRestorePosition,
|
||||
deriveFadeScalar
|
||||
} from '$lib/player/store.svelte';
|
||||
import { useMediaSession } from '$lib/player/mediaSession.svelte';
|
||||
import { useEventsDispatcher } from '$lib/player/events.svelte';
|
||||
@@ -89,7 +90,12 @@
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (audioEl) audioEl.volume = player.volume;
|
||||
if (!audioEl) return;
|
||||
// Per-position fade scalar: 1 normally, ramping in/out of the
|
||||
// crossfade window at track boundaries. Pure function of position
|
||||
// + duration + the operator's chosen crossfade duration.
|
||||
const scalar = deriveFadeScalar(player.position, player.duration, player.crossfadeSec);
|
||||
audioEl.volume = player.volume * scalar;
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
|
||||
Reference in New Issue
Block a user