mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Jumping to a hot cue outside a loop now cancels the loop
This commit is contained in:
1 parent
513808a6d2
commit
24b9dfe49f
1 file changed
+16
-3
@@ -405,6 +405,7 @@ export function PrepStrip({
|
|||||||
setCueHeld(true)
|
setCueHeld(true)
|
||||||
getCtx()
|
getCtx()
|
||||||
if (eng.playing) {
|
if (eng.playing) {
|
||||||
|
leaveLoopFor(cuePoint)
|
||||||
eng.pause()
|
eng.pause()
|
||||||
eng.seek(cuePoint)
|
eng.seek(cuePoint)
|
||||||
setPlaying(false)
|
setPlaying(false)
|
||||||
@@ -417,6 +418,7 @@ export function PrepStrip({
|
|||||||
eng.seek(t)
|
eng.seek(t)
|
||||||
setCurrent(t)
|
setCurrent(t)
|
||||||
} else {
|
} else {
|
||||||
|
leaveLoopFor(cuePoint)
|
||||||
beginPreview('cue', cuePoint)
|
beginPreview('cue', cuePoint)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -474,6 +476,16 @@ export function PrepStrip({
|
|||||||
setCurrent(t)
|
setCurrent(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A cue jump that lands outside the engaged loop leaves it, Traktor-style.
|
||||||
|
// Without this the loop stays in force and Web Audio, started past a loop's
|
||||||
|
// end, wraps straight back into it. A jump inside the loop keeps it.
|
||||||
|
const leaveLoopFor = (t: number) => {
|
||||||
|
if (!loopActive || !loopRegion) return
|
||||||
|
if (t >= loopRegion.start && t < loopRegion.end) return
|
||||||
|
playbackRef.current?.setLoopEnabled(false)
|
||||||
|
setLoopActive(false)
|
||||||
|
}
|
||||||
|
|
||||||
// User-driven seek from the waveforms: navigating away drops the active loop
|
// User-driven seek from the waveforms: navigating away drops the active loop
|
||||||
// (otherwise it would just pull playback back into the loop region).
|
// (otherwise it would just pull playback back into the loop region).
|
||||||
const seekManual = (t: number) => {
|
const seekManual = (t: number) => {
|
||||||
@@ -770,13 +782,14 @@ export function PrepStrip({
|
|||||||
const eng = playbackRef.current
|
const eng = playbackRef.current
|
||||||
if (!eng || !eng.ready) return
|
if (!eng || !eng.ready) return
|
||||||
getCtx()
|
getCtx()
|
||||||
// A loop hotcue jumps to its start AND re-engages a loop of its length.
|
// A loop hotcue jumps to its start AND engages a loop of its length — the
|
||||||
|
// new loop FIRST, so the seek is not wrapped back into the old one.
|
||||||
if (cue.type === 'loop' && cue.length > 0) {
|
if (cue.type === 'loop' && cue.length > 0) {
|
||||||
seek(cue.start)
|
|
||||||
engagLoop(cue.start, cue.start + cue.length, beatsForLoop(cue.start, cue.length))
|
engagLoop(cue.start, cue.start + cue.length, beatsForLoop(cue.start, cue.length))
|
||||||
} else {
|
} else {
|
||||||
seek(cue.start)
|
leaveLoopFor(cue.start)
|
||||||
}
|
}
|
||||||
|
seek(cue.start)
|
||||||
// Paused at press → momentary preview: play while held.
|
// Paused at press → momentary preview: play while held.
|
||||||
if (!eng.playing) beginPreview(`hc:${slot}`, cue.start)
|
if (!eng.playing) beginPreview(`hc:${slot}`, cue.start)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user