Beat jumping can now be done outside of the song range

This commit is contained in:
patben8 committed 2026-11-03 11:59:50 +01:00
1 parent 2a40106ea5
commit 5d1bfcf7f1
9 files changed
+126 -10

No files matched your search

+5 -3
View File
@@ -9,9 +9,11 @@ import type { Deck } from './useDeck'
/** mm:ss.f — tenths by default, as a CDJ does; `places` is the
* `timeReadoutDecimals` setting (0 drops the fraction). Truncates, never
* rounds, so the readout never shows a second before it has been reached. */
* rounds, so the readout never shows a second before it has been reached.
* Before the track (performance mode's lead-in) it counts up to it: −00:01.5. */
function fmtTime(secs: number, places: number): string {
if (!isFinite(secs) || secs < 0) secs = 0
if (!isFinite(secs)) secs = 0
if (secs < 0) return `−${fmtTime(-secs, places)}`
const scale = 10 ** places
// The epsilon keeps e.g. 0.3 s from reading 0.299 at 3 places.
const units = Math.floor(secs * scale + 1e-6)
@@ -109,7 +111,7 @@ export function DeckHeader({
<span aria-hidden className="my-2 w-px bg-line" />
<div className={cell}>
<span className="text-[10px] tracking-[0.08em] text-faint">REMAIN</span>
<span className={`font-mono font-medium ${compact ? 'text-[15px]' : 'text-[17px]'}`}>−{fmtTime(Math.max(0, duration - current), timeDecimals)}</span>
<span className={`font-mono font-medium ${compact ? 'text-[15px]' : 'text-[17px]'}`}>−{fmtTime(Math.max(0, duration - Math.max(0, current)), timeDecimals)}</span>
</div>
<span aria-hidden className="my-2 w-px bg-line" />
<div className={cell}>
+9 -1
View File
@@ -559,7 +559,9 @@ export function useDeck({
nStart = start + dir * len
nEnd = nStart + len
}
if (nStart < 0 || nEnd > duration) return // would leave the track
// Inside the track — but in performance mode a loop may sit past
// either edge (it loops silence there; decided 2026-11-03).
if (!tempoActive && (nStart < 0 || nEnd > duration)) return
// The playhead travels with the loop, keeping its place inside it. The
// NEW loop is set first: the engine's seek honours the loop in force, so
// seeking first would wrap the playhead straight back into the old one.
@@ -1221,6 +1223,12 @@ export function useDeck({
useEffect(() => {
playbackRef.current?.setKeylock(keylock)
}, [keylock, ready])
// Performance mode: a beat jump or loop move may land before the track
// (silence until it starts, still on the beat). Past the end a jump still
// stops the deck there, as the end of a track does (decided 2026-11-03).
useEffect(() => {
playbackRef.current?.setLeadIn(tempoActive)
}, [tempoActive, ready])
const setPitch = (p: number) => setPitchState(Math.max(-1, Math.min(1, p)))
/** An exact rate (SYNC), widening the range when the fader cannot reach it.
* Never called mid-bend: a bend releases the deck's SYNC. */