Paused decks now always scratch when jog wheel is moved

This commit is contained in:
patben8 committed 2026-11-05 11:33:45 +01:00
1 parent aaa7537d50
commit 2afba4557c
2 files changed
+51 -7

No files matched your search

+4 -2
View File
@@ -1552,8 +1552,10 @@ Two independent apps that talk over HTTP:
browse: All Tracks + the visible tree; a playlist opens as reached, a browse: All Tracks + the visible tree; a playlist opens as reached, a
folder opens on press). **Jog** (`useDeck`): touch = scratch through the folder opens on press). **Jog** (`useDeck`): touch = scratch through the
waveform-drag path, target sent straight to the worklet; no touch = waveform-drag path, target sent straight to the worklet; no touch =
nudge (a per-frame bend, also in prep mode) while playing, scrub while nudge (a per-frame bend, also in prep mode) while playing; while paused
paused; scale `JOG_SEC_PER_TICK` × the mapping's sensitivity. **UI**: a turn SCRATCHES too (decided 2026-11-05: grabbed on the first tick,
released `JOG_SCRATCH_IDLE_MS` after the last, so a jog without a touch
sensor still cues by ear); fast scrub stays a seek; scale `JOG_SEC_PER_TICK` × the mapping's sensitivity. **UI**:
Settings ▸ MIDI Controllers… (`MidiSettings`: per controller, Shift, jog Settings ▸ MIDI Controllers… (`MidiSettings`: per controller, Shift, jog
sensitivity / fast scrub, every action × Normal / Shift with Learn, sensitivity / fast scrub, every action × Normal / Shift with Learn,
encoding + Reversed per binding, Import / Export as encoding + Reversed per binding, Import / Export as
+47 -5
View File
@@ -56,6 +56,8 @@ const JOG_SEC_PER_TICK = 1.8 / 500
const JOG_NUDGE_PER_TICK = 0.004 const JOG_NUDGE_PER_TICK = 0.004
const JOG_NUDGE_MAX = 0.1 const JOG_NUDGE_MAX = 0.1
const JOG_NUDGE_IDLE_FRAMES = 4 const JOG_NUDGE_IDLE_FRAMES = 4
/** A paused deck's untouched jog scratches; this long without a tick lets go. */
const JOG_SCRATCH_IDLE_MS = 120
export interface DeckOptions { export interface DeckOptions {
/** The track loaded into this deck, if any. */ /** The track loaded into this deck, if any. */
@@ -647,11 +649,24 @@ export function useDeck({
// Touching the top SCRATCHES — the same engine path as dragging the // Touching the top SCRATCHES — the same engine path as dragging the
// waveform, the target sent straight to the worklet. A turn without touch // waveform, the target sent straight to the worklet. A turn without touch
// NUDGES while playing (a momentary bend, as the phase meter's drag) and // NUDGES while playing (a momentary bend, as the phase meter's drag) and
// SCRUBS while paused; `scrub` (Shift + jog) moves fast, playing or not. // SCRATCHES while paused too — the platter grabbed on the first tick and let
// go `JOG_SCRATCH_IDLE_MS` after the last, so a jog without a touch sensor
// still cues by ear; `scrub` (Shift + jog) moves fast, playing or not.
// Nudge and scrub are gathered per frame so a jog's flood of messages costs // Nudge and scrub are gathered per frame so a jog's flood of messages costs
// one render a frame. How many ticks a turn sends differs per controller, // one render a frame. How many ticks a turn sends differs per controller,
// so the scale is a starting point times the mapping's sensitivity. // so the scale is a starting point times the mapping's sensitivity.
const jogRef = useRef({ touching: false, target: 0, nudge: 0, scrub: 0, raf: 0, idle: 0, bending: false }) const jogRef = useRef({
touching: false,
/** Scratching from an untouched turn on a paused deck (released when idle). */
turning: false,
turnTimer: 0,
target: 0,
nudge: 0,
scrub: 0,
raf: 0,
idle: 0,
bending: false,
})
const jogLatest = useRef({ seekManual, duration }) const jogLatest = useRef({ seekManual, duration })
jogLatest.current = { seekManual, duration } jogLatest.current = { seekManual, duration }
const flushJog = () => { const flushJog = () => {
@@ -678,13 +693,26 @@ export function useDeck({
const scheduleJog = () => { const scheduleJog = () => {
if (!jogRef.current.raf) jogRef.current.raf = requestAnimationFrame(flushJog) if (!jogRef.current.raf) jogRef.current.raf = requestAnimationFrame(flushJog)
} }
useEffect(() => () => cancelAnimationFrame(jogRef.current.raf), []) useEffect(
() => () => {
cancelAnimationFrame(jogRef.current.raf)
clearTimeout(jogRef.current.turnTimer)
},
[],
)
/** Hand a turn-scratch over to a touch (or end it), without releasing it. */
const endTurn = () => {
const j = jogRef.current
clearTimeout(j.turnTimer)
j.turning = false
}
const jogTouch = (on: boolean) => { const jogTouch = (on: boolean) => {
const j = jogRef.current const j = jogRef.current
const eng = playbackRef.current const eng = playbackRef.current
if (on) { if (on) {
if (!eng || !eng.ready || j.touching) return if (!eng || !eng.ready || j.touching) return
endTurn()
j.touching = true j.touching = true
onScratchStart() onScratchStart()
j.target = eng.getPosition() j.target = eng.getPosition()
@@ -708,8 +736,22 @@ export function useDeck({
scheduleJog() scheduleJog()
return 'nudge' return 'nudge'
} }
j.scrub += ticks * JOG_SEC_PER_TICK * sensitivity // Paused (or coasting from a scratch): grab the platter and scratch.
scheduleJog() if (!j.turning || !engagedRef.current) {
onScratchStart()
if (!engagedRef.current) return null
j.turning = true
j.target = eng.getPosition()
}
j.target = Math.max(0, Math.min(duration, j.target + ticks * JOG_SEC_PER_TICK * sensitivity))
eng.scratchTarget(j.target)
clearTimeout(j.turnTimer)
j.turnTimer = window.setTimeout(() => {
j.turning = false
// Let go as a touch release does (a deck that was playing plays on);
// nothing if something else ended the scratch meanwhile.
if (!j.touching && engagedRef.current) playbackRef.current?.scratchRelease(wasPlayingRef.current)
}, JOG_SCRATCH_IDLE_MS)
return null return null
} }
const scrub = (ticks: number, sensitivity: number) => { const scrub = (ticks: number, sensitivity: number) => {