Implemented performance mode

This commit is contained in:
patben8 committed 2026-11-02 23:03:58 +01:00
1 parent 063463efdd
commit 9df73ddcd2
9 files changed
+552 -211

No files matched your search

+16 -1
View File
@@ -1363,7 +1363,22 @@ Two independent apps that talk over HTTP:
`lib/deckKeys.ts`, ONE window listener routing each key to the focused `lib/deckKeys.ts`, ONE window listener routing each key to the focused
deck (Alt/Option = the other deck, in performance mode; a key-up goes to deck (Alt/Option = the other deck, in performance mode; a key-up goes to
the deck its key-down went to). A deck's `persist` (loop size, cue bank) the deck its key-down went to). A deck's `persist` (loop size, cue bank)
and `leadsAmbient` (cover colours) are for deck A. **Header**: cover, title/artist · album · genre, a Read-only is deck A's; `leadsAmbient` (cover colours) the focused deck's.
**Performance mode** (P, or the decks button beside Auto hotcues; decided
2026-11-02, [the discussion](.claude/discussions/discuss-performance-mode-2026-11-02.md)):
deck B appears — the two headers side by side (`compact`, each led by its
letter, lit when focused), the two main waveforms STACKED at the one zoom
past one playhead line (each lane a drop target for its own deck, ringed
while focused), the overviews side by side, then each deck's controls
`stacked` (pads on a row of their own; the tempo group folds below 52rem),
a centre column between them for the mixer. App holds `decks: {A, B}`
(`DeckSlot`: track, origin, playRequest, cuesRefresh), `focusedDeck` and
`performance`; a load, Enter, a row's play button and a drop on the strip
go to the FOCUSED deck (A outside the mode), "Load to Deck A/B" to either,
and the table lights the focused deck's row. Entering with B empty focuses
B. B's `useDeck` stays MOUNTED while hidden — leaving pauses it, coming
back finds it as it was; a library switch empties both decks. Not
persisted. **Header**: cover, title/artist · album · genre, a Read-only
badge, the readout well (ELAPSED / REMAIN to tenths, KEY, and `BpmReadout` — badge, the readout well (ELAPSED / REMAIN to tenths, KEY, and `BpmReadout` —
click to type an exact BPM; with no grid, a typed or tapped BPM CREATES one at the playhead, and click to type an exact BPM; with no grid, a typed or tapped BPM CREATES one at the playhead, and
Set grid on a track with no BPM opens the readout to ask rather than failing), SNAP, Analyze, Auto hotcues. **Waveforms**: Set grid on a track with no BPM opens the readout to ask rather than failing), SNAP, Analyze, Auto hotcues. **Waveforms**:
+121 -58
View File
@@ -32,7 +32,7 @@ import { ConfirmDialog, type ConfirmRequest } from './components/ConfirmDialog'
import { PathMappingDialog } from './components/PathMappingDialog' import { PathMappingDialog } from './components/PathMappingDialog'
import { RelocateDialog } from './components/RelocateDialog' import { RelocateDialog } from './components/RelocateDialog'
import { HistoryPanel } from './components/HistoryPanel' import { HistoryPanel } from './components/HistoryPanel'
import { PrepStrip } from './components/PrepStrip' import { EMPTY_SLOT, PrepStrip, type DeckDrop, type DeckId, type DeckSlot } from './components/PrepStrip'
import { ImportDialog } from './components/ImportDialog' import { ImportDialog } from './components/ImportDialog'
import { AddFilesDialog, type AddTarget, type ForeignOrigin } from './components/AddFilesDialog' import { AddFilesDialog, type AddTarget, type ForeignOrigin } from './components/AddFilesDialog'
import { ConvertStemsDialog } from './components/ConvertStemsDialog' import { ConvertStemsDialog } from './components/ConvertStemsDialog'
@@ -61,6 +61,14 @@ function applyFilters(tracks: Track[], f: Filters): Track[] {
}) })
} }
/** `f` over both decks; the same object back when neither slot changed, so a
* no-op update does not re-render. */
function mapDecks(d: Record<DeckId, DeckSlot>, f: (s: DeckSlot) => DeckSlot): Record<DeckId, DeckSlot> {
const A = f(d.A)
const B = f(d.B)
return A === d.A && B === d.B ? d : { A, B }
}
export default function App() { export default function App() {
const qc = useQueryClient() const qc = useQueryClient()
const [source, setSource] = useState<Source>({ kind: 'all' }) const [source, setSource] = useState<Source>({ kind: 'all' })
@@ -77,12 +85,20 @@ export default function App() {
const [editing, setEditing] = useState<Track | null>(null) const [editing, setEditing] = useState<Track | null>(null)
const [showPaths, setShowPaths] = useState(false) const [showPaths, setShowPaths] = useState(false)
const [showHistory, setShowHistory] = useState(false) const [showHistory, setShowHistory] = useState(false)
const [prepTrack, setPrepTrack] = useState<Track | null>(null) // The decks: A always, B in performance mode (decided 2026-11-02). Each slot
const [deckPlaying, setDeckPlaying] = useState(false) // is its track, which library that came from — not the view's: browsing to a
// Which library the DECK's track came from — not the view's. Browsing to a
// playlist while a device or folder track is loaded must not switch the deck // playlist while a device or folder track is loaded must not switch the deck
// to endpoints that do not know that track. // to endpoints that do not know that track — and two counters App bumps.
const [prepOrigin, setPrepOrigin] = useState<TrackOrigin>('collection') const [decks, setDecks] = useState<Record<DeckId, DeckSlot>>({ A: EMPTY_SLOT, B: EMPTY_SLOT })
const [deckPlaying, setDeckPlaying] = useState<Record<DeckId, boolean>>({ A: false, B: false })
const [performance, setPerformance] = useState(false)
const [focusedDeck, setFocusedDeck] = useState<DeckId>('A')
// Where a load goes — the focused deck in performance mode, else A — and the
// deck the library's rows light up for. A ref too, for the load callbacks.
const targetDeck: DeckId = performance ? focusedDeck : 'A'
const targetDeckRef = useRef<DeckId>('A')
targetDeckRef.current = targetDeck
const prepTrack = decks[targetDeck].track
// The view's origin, read by the load callbacks below (defined before it). // The view's origin, read by the load callbacks below (defined before it).
const viewOriginRef = useRef<TrackOrigin>('collection') const viewOriginRef = useRef<TrackOrigin>('collection')
// The browsed folder's rows that ARE collection tracks: collection id → the // The browsed folder's rows that ARE collection tracks: collection id → the
@@ -94,7 +110,6 @@ export default function App() {
// How many dropped items are being read (a dropped folder is searched all // How many dropped items are being read (a dropped folder is searched all
// the way down, which can take a while): shown until the dialog opens. // the way down, which can take a while): shown until the dialog opens.
const [readingDrop, setReadingDrop] = useState(0) const [readingDrop, setReadingDrop] = useState(0)
const [playRequest, setPlayRequest] = useState(0) // bump → deck loads & auto-plays
const [importing, setImporting] = useState(false) const [importing, setImporting] = useState(false)
// Device tracks dropped on a collection playlist / export: Import, with // Device tracks dropped on a collection playlist / export: Import, with
// just those tracks and that target. // just those tracks and that target.
@@ -119,23 +134,48 @@ export default function App() {
const [stemReport, setStemReport] = useState<StemBatchResult | null>(null) const [stemReport, setStemReport] = useState<StemBatchResult | null>(null)
const [engineJob, setEngineJob] = useState<string | null>(null) const [engineJob, setEngineJob] = useState<string | null>(null)
const [batchCancelling, setBatchCancelling] = useState(false) const [batchCancelling, setBatchCancelling] = useState(false)
const [cuesRefresh, setCuesRefresh] = useState(0) // bump → deck re-reads its cues
// Every Remove ▸ action (and the playlist Delete key) confirms first. // Every Remove ▸ action (and the playlist Delete key) confirms first.
const [confirmReq, setConfirmReq] = useState<ConfirmRequest | null>(null) const [confirmReq, setConfirmReq] = useState<ConfirmRequest | null>(null)
const loadTrack = useCallback((t: Track, origin: TrackOrigin = viewOriginRef.current) => { const loadTrack = useCallback(
setPrepTrack(t) (t: Track, origin: TrackOrigin = viewOriginRef.current, deck: DeckId = targetDeckRef.current) => {
// A folder row the collection holds IS the collection track, so the deck // A folder row the collection holds IS the collection track, so the deck
// loads it as one: its cues and grid, and editable (decided 2026-10-10). // loads it as one: its cues and grid, and editable (decided 2026-10-10).
setPrepOrigin(origin === 'folder' && folderFilesRef.current[t.id] ? 'collection' : origin) const o = origin === 'folder' && folderFilesRef.current[t.id] ? 'collection' : origin
}, []) setDecks((d) => ({ ...d, [deck]: { ...d[deck], track: t, origin: o } }))
},
[],
)
const playTrack = useCallback( const playTrack = useCallback(
(t: Track) => { (t: Track) => {
loadTrack(t) const deck = targetDeckRef.current
setPlayRequest((n) => n + 1) loadTrack(t, undefined, deck)
setDecks((d) => ({ ...d, [deck]: { ...d[deck], playRequest: d[deck].playRequest + 1 } }))
}, },
[loadTrack], [loadTrack],
) )
// Every deck holding one of `ids`: re-read its cues (an outside edit wrote
// them), or unload it (the track left the collection).
const bumpDeckCues = useCallback((ids: string[]) => {
setDecks((d) => mapDecks(d, (s) => (s.track && ids.includes(s.track.id) ? { ...s, cuesRefresh: s.cuesRefresh + 1 } : s)))
}, [])
const unloadDecks = useCallback((ids: string[]) => {
setDecks((d) => mapDecks(d, (s) => (s.track && ids.includes(s.track.id) ? { ...s, track: null } : s)))
}, [])
const onDeckPlaying = useCallback((id: DeckId, playing: boolean) => {
setDeckPlaying((s) => (s[id] === playing ? s : { ...s, [id]: playing }))
}, [])
// Entering performance mode with deck B empty focuses B, so the next load
// goes there and deck A keeps playing what it has.
const decksRef = useRef(decks)
decksRef.current = decks
const performanceRef = useRef(performance)
performanceRef.current = performance
const togglePerformance = useCallback(() => {
const entering = !performanceRef.current
if (entering && !decksRef.current.B.track) setFocusedDeck('B')
setPerformance(entering)
}, [])
// ---- configurable library columns (persisted to userprefs.json) ---- // ---- configurable library columns (persisted to userprefs.json) ----
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>(DEFAULT_COLUMN_VISIBILITY) const [columnVisibility, setColumnVisibility] = useState<VisibilityState>(DEFAULT_COLUMN_VISIBILITY)
@@ -324,7 +364,7 @@ export default function App() {
const deviceCaps = useQuery({ const deviceCaps = useQuery({
queryKey: ['source-capabilities'], queryKey: ['source-capabilities'],
queryFn: api.sourceCapabilities, queryFn: api.sourceCapabilities,
enabled: viewingDevice || prepOrigin === 'device', enabled: viewingDevice || decks.A.origin === 'device' || decks.B.origin === 'device',
staleTime: Infinity, staleTime: Infinity,
}) })
@@ -474,7 +514,7 @@ export default function App() {
) )
// One dropped audio file on the deck: loaded to listen to, added to nothing. // One dropped audio file on the deck: loaded to listen to, added to nothing.
const loadDropped = useCallback( const loadDropped = useCallback(
async (path: string) => { async (path: string, deck: DeckId = targetDeckRef.current) => {
const r = await readDrop([path]) const r = await readDrop([path])
if (!r) return if (!r) return
const t = r.tracks[0] const t = r.tracks[0]
@@ -482,7 +522,7 @@ export default function App() {
onError('That is not an audio file this library can hold.') onError('That is not an audio file this library can hold.')
return return
} }
loadTrack(t, r.files[t.id] ? 'collection' : 'folder') loadTrack(t, r.files[t.id] ? 'collection' : 'folder', deck)
}, },
[readDrop, loadTrack, onError], [readDrop, loadTrack, onError],
) )
@@ -503,14 +543,25 @@ export default function App() {
const audioFormats = capabilities.data?.tracks.audio_formats const audioFormats = capabilities.data?.tracks.audio_formats
const isAudioPath = (path: string) => const isAudioPath = (path: string) =>
path.lastIndexOf('.') > 0 && !!audioFormats?.includes(path.slice(path.lastIndexOf('.')).toLowerCase()) path.lastIndexOf('.') > 0 && !!audioFormats?.includes(path.slice(path.lastIndexOf('.')).toLowerCase())
const [deckDropRef, deckOver] = useDropTarget<true>({ // A track (the row grabbed) or one audio file, dropped on a deck: loaded
// paused. In performance mode each waveform lane is a target for its own
// deck; anywhere else on the strip loads the focused one.
const deckDrop: DeckDrop = {
hint: (p) => hint: (p) =>
p.kind === 'tracks' || (p.kind === 'files' && p.paths.length === 1 && isAudioPath(p.paths[0])) ? true : null, p.kind === 'tracks' || (p.kind === 'files' && p.paths.length === 1 && isAudioPath(p.paths[0])) ? true : null,
label: (p) => (p.kind === 'tracks' && p.ids.length > 1 ? `Load “${p.lead.title || 'Untitled'}” into the deck` : 'Load into the deck'), label: (p, deck) => {
onDrop: (p) => { const into = performance ? `deck ${deck}` : 'the deck'
if (p.kind === 'tracks') loadTrack(p.lead, p.origin) return p.kind === 'tracks' && p.ids.length > 1 ? `Load “${p.lead.title || 'Untitled'}” into ${into}` : `Load into ${into}`
else if (p.kind === 'files') void loadDropped(p.paths[0])
}, },
onDrop: (p, deck) => {
if (p.kind === 'tracks') loadTrack(p.lead, p.origin, deck)
else if (p.kind === 'files') void loadDropped(p.paths[0], deck)
},
}
const [deckDropRef, deckOver] = useDropTarget<true>({
hint: deckDrop.hint,
label: (p) => deckDrop.label(p, targetDeck),
onDrop: (p) => deckDrop.onDrop(p, targetDeck),
}) })
// Files dropped anywhere no other target takes them: the collection. A // Files dropped anywhere no other target takes them: the collection. A
// library that cannot add tracks still takes the drop, to say why not — // library that cannot add tracks still takes the drop, to say why not —
@@ -569,8 +620,8 @@ export default function App() {
// tracks and edit as such, and a loose row asks to be added first // tracks and edit as such, and a loose row asks to be added first
// (`folderMayEdit`) rather than rendering inert. // (`folderMayEdit`) rather than rendering inert.
const viewCaps = viewingFolder ? capabilities.data! : capsFor(viewOriginRef.current) const viewCaps = viewingFolder ? capabilities.data! : capsFor(viewOriginRef.current)
// The deck follows its TRACK's library, not the view's. // A deck follows its TRACK's library, not the view's.
const deckCaps = capsFor(prepOrigin) const deckCaps = { A: capsFor(decks.A.origin), B: capsFor(decks.B.origin) }
const deviceLabel = openDevice.data?.label ?? 'device' const deviceLabel = openDevice.data?.label ?? 'device'
// One name for whatever is on screen, so the header and the status bar cannot // One name for whatever is on screen, so the header and the status bar cannot
@@ -628,14 +679,16 @@ export default function App() {
// PrepStrip keys its audio on the id, so a new object for the same id // PrepStrip keys its audio on the id, so a new object for the same id
// reloads nothing. // reloads nothing.
useEffect(() => { useEffect(() => {
if (!prepTrack) return setDecks((d) =>
const fresh = tracks.find((t) => t.id === prepTrack.id) mapDecks(d, (s) => {
if (!fresh) return if (!s.track) return s
const origin = const fresh = tracks.find((t) => t.id === s.track!.id)
viewOriginRef.current === 'folder' && folderFilesRef.current[fresh.id] ? 'collection' : viewOriginRef.current if (!fresh) return s
if (origin === prepOrigin && JSON.stringify(fresh) !== JSON.stringify(prepTrack)) setPrepTrack(fresh) const origin =
// Only a refetch of the list matters; prepTrack is read, not tracked. viewOriginRef.current === 'folder' && folderFilesRef.current[fresh.id] ? 'collection' : viewOriginRef.current
// eslint-disable-next-line react-hooks/exhaustive-deps return origin === s.origin && JSON.stringify(fresh) !== JSON.stringify(s.track) ? { ...s, track: fresh } : s
}),
)
}, [tracks]) }, [tracks])
const loading = viewingFolder const loading = viewingFolder
@@ -831,7 +884,7 @@ export default function App() {
const f = failures[0] const f = failures[0]
parts.push(`${failures.length} failed (${f.title}: ${f.reason}${failures.length > 1 ? ', …' : ''})`) parts.push(`${failures.length} failed (${f.title}: ${f.reason}${failures.length > 1 ? ', …' : ''})`)
} }
if (prepTrack && touched.includes(prepTrack.id)) setCuesRefresh((n) => n + 1) bumpDeckCues(touched)
notify(failures.length && touched.length === 0 ? 'error' : 'success', parts.filter(Boolean).join(' · ')) notify(failures.length && touched.length === 0 ? 'error' : 'success', parts.filter(Boolean).join(' · '))
// Only the job's finish matters here; prepTrack is read, not tracked. // Only the job's finish matters here; prepTrack is read, not tracked.
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -842,9 +895,8 @@ export default function App() {
setSource({ kind: 'all' }) setSource({ kind: 'all' })
setSelected(new Set()) setSelected(new Set())
setBatchJob(null) // the backend cancels it; its result is for the old library setBatchJob(null) // the backend cancels it; its result is for the old library
// The deck starts empty: its track belongs to the old library. // The decks start empty: their tracks belong to the old library.
setPrepTrack(null) setDecks({ A: EMPTY_SLOT, B: EMPTY_SLOT })
setPlayRequest(0)
setFilters(emptyFilters) setFilters(emptyFilters)
setSorting([]) setSorting([])
qc.invalidateQueries() // refetch everything for the newly-opened collection qc.invalidateQueries() // refetch everything for the newly-opened collection
@@ -884,10 +936,13 @@ export default function App() {
// A repointed track's id IS its location, so it changed: follow it with the // A repointed track's id IS its location, so it changed: follow it with the
// deck and the selection instead of leaving them on an id that is gone. // deck and the selection instead of leaving them on an id that is gone.
const renamed = r.renamed const renamed = r.renamed
if (prepTrack && renamed[prepTrack.id]) { setDecks((d) =>
setPrepTrack({ ...prepTrack, id: renamed[prepTrack.id], media_kind: 'stem' }) mapDecks(d, (s) =>
setCuesRefresh((n) => n + 1) s.track && renamed[s.track.id]
} ? { ...s, track: { ...s.track, id: renamed[s.track.id], media_kind: 'stem' }, cuesRefresh: s.cuesRefresh + 1 }
: s,
),
)
setSelected((sel) => new Set([...sel].map((id) => renamed[id] ?? id))) setSelected((sel) => new Set([...sel].map((id) => renamed[id] ?? id)))
const n = r.converted.length const n = r.converted.length
const parts = [ const parts = [
@@ -1074,7 +1129,7 @@ export default function App() {
qc.invalidateQueries({ queryKey: ['playlists'] }) qc.invalidateQueries({ queryKey: ['playlists'] })
qc.invalidateQueries({ queryKey: ['export-contents'] }) qc.invalidateQueries({ queryKey: ['export-contents'] })
qc.invalidateQueries({ queryKey: ['facets'] }) qc.invalidateQueries({ queryKey: ['facets'] })
if (cuesChanged && prepTrack && ids.includes(prepTrack.id)) setCuesRefresh((n) => n + 1) if (cuesChanged) bumpDeckCues(ids)
} }
const guard = async (fn: () => Promise<void>) => { const guard = async (fn: () => Promise<void>) => {
try { try {
@@ -1228,7 +1283,7 @@ export default function App() {
guard(async () => { guard(async () => {
const r = await api.removeTracks(ids) const r = await api.removeTracks(ids)
setSelected(new Set()) setSelected(new Set())
if (prepTrack && ids.includes(prepTrack.id)) setPrepTrack(null) unloadDecks(ids)
afterBulk(ids, false) afterBulk(ids, false)
notify('success', `Removed ${nTracks(r.removed)} from the collection`) notify('success', `Removed ${nTracks(r.removed)} from the collection`)
}), }),
@@ -1389,7 +1444,12 @@ export default function App() {
items={[ items={[
// Single-track actions are hidden, not disabled, for a multi-selection. // Single-track actions are hidden, not disabled, for a multi-selection.
...(menu.ids.length === 1 ...(menu.ids.length === 1
? [{ label: 'Load to Deck', onClick: () => loadTrack(menu.track) }] ? performance
? (['A', 'B'] as const).map((d) => ({
label: `Load to Deck ${d}`,
onClick: () => loadTrack(menu.track, undefined, d),
}))
: [{ label: 'Load to Deck', onClick: () => loadTrack(menu.track) }]
: []), : []),
// Offering "Edit Tags…" on a read-only library would open a dialog // Offering "Edit Tags…" on a read-only library would open a dialog
// whose every save is refused, so it is not offered at all. // whose every save is refused, so it is not offered at all.
@@ -1686,19 +1746,22 @@ export default function App() {
{deckOver && ( {deckOver && (
<div aria-hidden className="pointer-events-none absolute inset-0 z-10 rounded-[22px] ring-2 ring-accent" /> <div aria-hidden className="pointer-events-none absolute inset-0 z-10 rounded-[22px] ring-2 ring-accent" />
)} )}
<CapabilitiesContext.Provider value={deckCaps}> <CapabilitiesContext.Provider value={deckCaps[targetDeck]}>
<PrepStrip <PrepStrip
track={prepTrack} decks={decks}
playRequest={playRequest} caps={deckCaps}
performance={performance}
onTogglePerformance={togglePerformance}
focused={focusedDeck}
onFocus={setFocusedDeck}
drop={deckDrop}
onError={onError} onError={onError}
onNotify={notify} onNotify={notify}
origin={prepOrigin} onPlayingChange={onDeckPlaying}
cuesRefresh={cuesRefresh}
onPlayingChange={setDeckPlaying}
// As the context menu's: a library that would refuse the save is // As the context menu's: a library that would refuse the save is
// not offered the dialog, and a deck track outside the collection // not offered the dialog, and a deck track outside the collection
// (a device's, a loose file's) is not the collection's to edit. // (a device's, a loose file's) is not the collection's to edit.
onEditTags={canEdit && prepOrigin === 'collection' ? setEditing : undefined} onEditTags={canEdit ? setEditing : undefined}
/> />
</CapabilitiesContext.Provider> </CapabilitiesContext.Provider>
</div> </div>
@@ -1715,7 +1778,7 @@ export default function App() {
onDone={(msg) => notify('success', msg)} onDone={(msg) => notify('success', msg)}
onAddForeign={addForeign} onAddForeign={addForeign}
onOpenPathMapping={() => setShowPaths(true)} onOpenPathMapping={() => setShowPaths(true)}
onDiscarded={() => afterBulk(prepTrack ? [prepTrack.id] : [], true)} onDiscarded={() => afterBulk([decks.A.track?.id, decks.B.track?.id].filter((x): x is string => !!x), true)}
/> />
<CapabilitiesContext.Provider value={viewCaps}> <CapabilitiesContext.Provider value={viewCaps}>
@@ -1863,7 +1926,7 @@ export default function App() {
onPlay={playTrack} onPlay={playTrack}
onEditField={canEdit ? editField : undefined} onEditField={canEdit ? editField : undefined}
activeTrackId={prepTrack?.id ?? null} activeTrackId={prepTrack?.id ?? null}
activePlaying={deckPlaying} activePlaying={deckPlaying[targetDeck]}
columnVisibility={columnVisibility} columnVisibility={columnVisibility}
columnOrder={columnOrder} columnOrder={columnOrder}
columnSizing={columnSizing} columnSizing={columnSizing}
@@ -1905,7 +1968,7 @@ export default function App() {
onEditField={canEdit ? folderEditField : undefined} onEditField={canEdit ? folderEditField : undefined}
mayEdit={folderMayEdit} mayEdit={folderMayEdit}
activeTrackId={prepTrack?.id ?? null} activeTrackId={prepTrack?.id ?? null}
activePlaying={deckPlaying} activePlaying={deckPlaying[targetDeck]}
columnVisibility={columnVisibility} columnVisibility={columnVisibility}
columnOrder={columnOrder} columnOrder={columnOrder}
columnSizing={columnSizing} columnSizing={columnSizing}
@@ -1940,7 +2003,7 @@ export default function App() {
onHeaderContextMenu={(x, y) => setHeaderMenu({ x, y })} onHeaderContextMenu={(x, y) => setHeaderMenu({ x, y })}
onPlay={playTrack} onPlay={playTrack}
activeTrackId={prepTrack?.id ?? null} activeTrackId={prepTrack?.id ?? null}
activePlaying={deckPlaying} activePlaying={deckPlaying[targetDeck]}
columnVisibility={columnVisibility} columnVisibility={columnVisibility}
columnOrder={columnOrder} columnOrder={columnOrder}
columnSizing={columnSizing} columnSizing={columnSizing}
@@ -1965,7 +2028,7 @@ export default function App() {
onPlay={playTrack} onPlay={playTrack}
onEditField={canEdit ? editField : undefined} onEditField={canEdit ? editField : undefined}
activeTrackId={prepTrack?.id ?? null} activeTrackId={prepTrack?.id ?? null}
activePlaying={deckPlaying} activePlaying={deckPlaying[targetDeck]}
columnVisibility={columnVisibility} columnVisibility={columnVisibility}
columnOrder={columnOrder} columnOrder={columnOrder}
columnSizing={columnSizing} columnSizing={columnSizing}
@@ -2018,7 +2081,7 @@ export default function App() {
onPlay={playTrack} onPlay={playTrack}
onEditField={canEdit ? editField : undefined} onEditField={canEdit ? editField : undefined}
activeTrackId={prepTrack?.id ?? null} activeTrackId={prepTrack?.id ?? null}
activePlaying={deckPlaying} activePlaying={deckPlaying[targetDeck]}
columnVisibility={columnVisibility} columnVisibility={columnVisibility}
columnOrder={columnOrder} columnOrder={columnOrder}
columnSizing={columnSizing} columnSizing={columnSizing}
+201 -33
View File
@@ -1,33 +1,57 @@
import { useEffect, useRef, useState } from 'react' import { useCallback, useEffect, useRef, useState, type ReactNode } from 'react'
import { useQuery } from '@tanstack/react-query' import { useQuery } from '@tanstack/react-query'
import { api, type Track, type TrackOrigin } from '../api' import { api, type Capabilities, type Track, type TrackOrigin } from '../api'
import { useCaps } from '../lib/capabilities'
import { useDeckKeys, type DeckKeyTargets } from '../lib/deckKeys' import { useDeckKeys, type DeckKeyTargets } from '../lib/deckKeys'
import { useDropTarget, type DragPayload } from '../lib/drag'
import { Icon } from '../lib/icons'
import { usePrefsWriter } from '../lib/prefs' import { usePrefsWriter } from '../lib/prefs'
import { DeckControls } from './deck/DeckControls' import { DeckControls } from './deck/DeckControls'
import { DeckHeader } from './deck/DeckHeader' import { DeckHeader } from './deck/DeckHeader'
import { DeckOverlays } from './deck/DeckOverlays' import { DeckOverlays } from './deck/DeckOverlays'
import { DeckMainWave, DeckOverview, type DeckView } from './deck/DeckWaves' import { DeckMainWave, DeckOverview, type DeckView } from './deck/DeckWaves'
import { useDeck } from './deck/useDeck' import { useDeck, type Deck } from './deck/useDeck'
import { MIN_SEC, MAX_SEC, DEFAULT_SEC } from './MainWaveform' import { MIN_SEC, MAX_SEC, DEFAULT_SEC } from './MainWaveform'
interface Props { export type DeckId = 'A' | 'B'
/** The track currently loaded into the prep deck, if any. */ export const DECK_IDS: DeckId[] = ['A', 'B']
export const otherDeck = (id: DeckId): DeckId => (id === 'A' ? 'B' : 'A')
/** What App holds per deck: the track, whose library it is, and two counters
* it bumps (a row's play button; an outside edit of the track's cues). */
export interface DeckSlot {
track: Track | null track: Track | null
/** Bumped by the library's per-row play button to load + auto-play. */ origin: TrackOrigin
playRequest?: number playRequest: number
cuesRefresh: number
}
export const EMPTY_SLOT: DeckSlot = { track: null, origin: 'collection', playRequest: 0, cuesRefresh: 0 }
/** A track or file dragged onto a deck (App knows how to load each). */
export interface DeckDrop {
hint: (p: DragPayload) => true | null
label: (p: DragPayload, deck: DeckId) => string | null
onDrop: (p: DragPayload, deck: DeckId) => void
}
interface Props {
decks: Record<DeckId, DeckSlot>
/** Each deck's capabilities: its OWN track's library. */
caps: Record<DeckId, Capabilities>
/** Performance mode: deck B, stacked waveforms (decided 2026-11-02). */
performance: boolean
onTogglePerformance: () => void
/** The deck keys and loads go to (in performance mode). */
focused: DeckId
onFocus: (id: DeckId) => void
drop: DeckDrop
onError?: (msg: string) => void onError?: (msg: string) => void
/** Neutral/success feedback (e.g. Auto Hotcues result). */ /** Neutral/success feedback (e.g. Auto Hotcues result). */
onNotify?: (kind: 'success' | 'error', msg: string) => void onNotify?: (kind: 'success' | 'error', msg: string) => void
/** Which library the track belongs to (see `DeckOptions.origin`). */ /** Reports whether a deck is playing, so the library can light its row. */
origin?: TrackOrigin onPlayingChange: (id: DeckId, playing: boolean) => void
/** Bumped when something outside the deck (batch grid analysis) rewrote the /** Opens Edit Tags — passed only where the library will accept the edit;
* loaded track's cues/grid, so the deck re-reads them. */ * a deck offers it only for a collection track. */
cuesRefresh?: number
/** Reports whether the deck is playing, so the library can light its row. */
onPlayingChange?: (playing: boolean) => void
/** Opens Edit Tags for the loaded track — passed only where the library
* will accept the edit, so the cover popup offers it only then. */
onEditTags?: (track: Track) => void onEditTags?: (track: Track) => void
} }
@@ -61,29 +85,173 @@ function useDeckView(): DeckView {
} }
/** /**
* The DJ-style "prep strip" across the top of the window: the track and its * The DJ-style deck strip across the top of the window. The decks themselves —
* readouts, a scrolling zoomable main waveform above a whole-track overview, * state, audio, every action — are `useDeck` (components/deck/); this lays
* then transport, loop and hotcue controls. The deck itself — state, audio, * them out and routes the keyboard to them.
* every action — is `useDeck` (components/deck/); this lays it out and routes *
* the keyboard to it. Playback, loops and scratch run in the deck's audio * One deck normally. PERFORMANCE MODE (P, or the button beside Auto hotcues)
* worklet (lib/audio/). * adds deck B: the two headers side by side, the two main waveforms stacked at
* one zoom past one playhead line, the overviews side by side, then each
* deck's controls (the mixer goes between them). Keys go to the FOCUSED deck
* (click a deck), Alt/Option to the other. Deck B stays mounted while hidden,
* so leaving and coming back finds it as it was — paused on the way out.
*/ */
export function PrepStrip(props: Props) { export function PrepStrip({
const caps = useCaps() decks,
caps,
performance,
onTogglePerformance,
focused,
onFocus,
drop,
onError,
onNotify,
onPlayingChange,
onEditTags,
}: Props) {
const view = useDeckView() const view = useDeckView()
const deck = useDeck({ ...props, caps, secPerView: view.secPerView }) const lead: DeckId = performance ? focused : 'A'
const playingA = useCallback((p: boolean) => onPlayingChange('A', p), [onPlayingChange])
const playingB = useCallback((p: boolean) => onPlayingChange('B', p), [onPlayingChange])
const common = { secPerView: view.secPerView, onError, onNotify }
const editTags = (slot: DeckSlot) => (onEditTags && slot.origin === 'collection' ? onEditTags : undefined)
const a = useDeck({
...common,
...decks.A,
caps: caps.A,
onPlayingChange: playingA,
onEditTags: editTags(decks.A),
persist: true,
leadsAmbient: lead === 'A',
})
const b = useDeck({
...common,
...decks.B,
caps: caps.B,
onPlayingChange: playingB,
onEditTags: editTags(decks.B),
persist: false,
leadsAmbient: lead === 'B',
})
const deckOf = (id: DeckId) => (id === 'A' ? a : b)
// Leaving performance mode hides deck B: stop it, or it plays on unseen.
const pauseB = useRef(b.pause)
pauseB.current = b.pause
useEffect(() => {
if (!performance) pauseB.current()
}, [performance])
const keys = useRef<DeckKeyTargets>({ focused: null, other: null }) const keys = useRef<DeckKeyTargets>({ focused: null, other: null })
keys.current = { focused: deck.shortcuts, other: null } keys.current = {
focused: deckOf(lead).shortcuts,
other: performance ? deckOf(otherDeck(lead)).shortcuts : null,
togglePerformance: onTogglePerformance,
}
useDeckKeys(keys) useDeckKeys(keys)
const toggle = (
<button
onClick={onTogglePerformance}
aria-pressed={performance}
aria-label="Performance mode"
title={performance ? 'Leave performance mode (P)' : 'Performance mode — a second deck to try transitions (P)'}
className={`flex h-9 w-9 shrink-0 items-center justify-center rounded-full ${
performance ? 'is-selected text-text' : 'btn-glass text-muted'
}`}
>
<Icon name="decks" size={18} />
</button>
)
if (!performance) {
return (
<div className="glass flex h-[19.75rem] shrink-0 flex-col gap-2 p-4">
<DeckHeader deck={a} actions={toggle} />
<DeckMainWave deck={a} view={view} />
<DeckOverview deck={a} view={view} />
<DeckControls deck={a} />
<DeckOverlays deck={a} />
</div>
)
}
const pane = (id: DeckId, children: ReactNode, className = 'min-w-0 flex-1') => (
<div className={className} onPointerDownCapture={() => onFocus(id)}>
{children}
</div>
)
const badge = (id: DeckId) => (
<span
className={`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg font-mono text-[13px] font-semibold transition-colors ${
id === focused
? 'bg-accent text-ink-950 shadow-[0_0_14px_-2px_var(--color-accent)]'
: 'bg-ink-800 text-muted'
}`}
title={id === focused ? `Deck ${id} — the keys act on it` : `Deck ${id} — click it to focus (Alt/Option + key acts on it)`}
>
{id}
</span>
)
// The centre column: the toggle above, the mixer (phase 4) below.
const centre = 'w-9 shrink-0'
return ( return (
<div className="glass flex h-[19.75rem] shrink-0 flex-col gap-2 p-4"> <div className="glass flex h-[29rem] shrink-0 flex-col gap-2 p-4">
<DeckHeader deck={deck} /> <div className="flex shrink-0 items-center gap-3">
<DeckMainWave deck={deck} view={view} /> {pane('A', <DeckHeader deck={a} compact badge={badge('A')} />)}
<DeckOverview deck={deck} view={view} /> {toggle}
<DeckControls deck={deck} /> {pane('B', <DeckHeader deck={b} compact badge={badge('B')} />)}
<DeckOverlays deck={deck} /> </div>
{DECK_IDS.map((id) => (
<DeckLane key={id} id={id} deck={deckOf(id)} view={view} focused={id === focused} drop={drop} onFocus={onFocus} />
))}
<div className="flex h-7 shrink-0 gap-3">
{pane('A', <DeckOverview deck={a} view={view} />)}
<div className={centre} />
{pane('B', <DeckOverview deck={b} view={view} />)}
</div>
<div className="flex shrink-0 gap-3">
{pane('A', <DeckControls deck={a} stacked />, 'flex min-w-0 flex-1')}
<div className={centre} />
{pane('B', <DeckControls deck={b} stacked />, 'flex min-w-0 flex-1')}
</div>
<DeckOverlays deck={a} />
<DeckOverlays deck={b} />
</div>
)
}
/** One deck's main waveform in performance mode: its own drop target (a track
* dropped here loads into THIS deck), ringed while focused. */
function DeckLane({
id,
deck,
view,
focused,
drop,
onFocus,
}: {
id: DeckId
deck: Deck
view: DeckView
focused: boolean
drop: DeckDrop
onFocus: (id: DeckId) => void
}) {
const [ref, over] = useDropTarget<true>({
hint: drop.hint,
label: (p) => drop.label(p, id),
onDrop: (p) => drop.onDrop(p, id),
})
return (
<div
ref={ref}
onPointerDownCapture={() => onFocus(id)}
className={`relative flex min-h-0 flex-1 rounded-2xl transition-shadow ${
over ? 'ring-2 ring-accent' : focused ? 'ring-1 ring-accent/45' : ''
}`}
>
<DeckMainWave deck={deck} view={view} empty={`Deck ${id} — drop a track here, or focus it and load one`} />
</div> </div>
) )
} }
+139 -101
View File
@@ -17,8 +17,13 @@ const DIVIDER = <span aria-hidden className="h-7 w-px shrink-0 bg-line" />
* into one BPM button. That is the row's measured width just before the pad * into one BPM button. That is the row's measured width just before the pad
* bank would hit its minimum (with a lockable grid's extra Lock button, and the * bank would hit its minimum (with a lockable grid's extra Lock button, and the
* Hot / Mem toggle's ~3rem with its gap), so move it with the controls. * Hot / Mem toggle's ~3rem with its gap), so move it with the controls.
*
* `stacked` (half-width, in performance mode) gives the pads — or the grid or
* memory strip — a row of their own under the rest, which then folds the tempo
* group below 52rem (measured in the app: row one needs ~50rem before the
* tempo group overflows).
*/ */
export function DeckControls({ deck }: { deck: Deck }) { export function DeckControls({ deck, stacked = false }: { deck: Deck; stacked?: boolean }) {
const { const {
caps, caps,
track, track,
@@ -84,8 +89,8 @@ export function DeckControls({ deck }: { deck: Deck }) {
renameSlot, renameSlot,
tempoProps, tempoProps,
} = deck } = deck
return ( const transport = (
<div className="@container flex h-11 shrink-0 items-center gap-3"> <>
<button <button
onClick={toggle} onClick={toggle}
disabled={!ready} disabled={!ready}
@@ -122,107 +127,140 @@ export function DeckControls({ deck }: { deck: Deck }) {
> >
CUE CUE
</button> </button>
</>
)
const loopControls = (
<LoopControls
mode={loopMode}
onMode={setLoopMode}
hasGrid={grid != null}
ready={ready}
size={beatSize}
onSmaller={() => stepSize(-1)}
onBigger={() => stepSize(1)}
loopActive={loopActive}
sizeLit={loopActive && activeBeats === beatSize}
onToggleSize={toggleSizeLoop}
canToggle={loopRegion != null}
inArmed={loopInPoint != null}
manualSet={loopRegion != null && activeBeats == null}
onLoopIn={loopIn}
onLoopOut={loopOut}
onToggleLoop={toggleLoop}
onMove={moveOrJump}
/>
)
const bankSwitch = caps.cues.memory_cues && !gridMode && (
<ModeSwitch
label="Cue bank"
value={bankMode}
options={[
{ value: 'hot', text: 'HOT', title: 'Hot cues: the pads' },
{ value: 'memory', text: 'MEM', title: 'Memory cues: call one to make it the CUE point' },
]}
onChange={(m) => {
setBankMode(m)
setPadMenu(null)
setMemoryMenu(null)
setRenamingSlot(null)
setRenamingMemory(null)
}}
/>
)
const strip = gridMode ? (
<GridEditStrip
markerIndex={activeMarkerIndex}
markerCount={markerCount}
markerStart={activeMarker?.start ?? null}
atMarker={atMarker}
beforeFirst={beforeFirstMarker}
canReset={originalGridRef.current != null}
onPrevMarker={prevMarker}
onNextMarker={nextMarker}
onNudgeMarker={nudgeGrid}
onNudgeMarkerBeats={nudgeGridBeats}
onAddMarker={addMarkerHere}
onDeleteMarker={deleteMarkerHere}
onDeleteGrid={deleteGrid}
onReset={resetGrid}
/>
) : showMemory ? (
<MemoryCueStrip
cues={cueData?.cues ?? []}
cuePoint={cuePoint}
onCall={callMemoryCue}
onMenu={(cue, x, y) => setMemoryMenu({ cue, x, y })}
onAdd={() => void addMemoryCue()}
addRefusal={memoryAddRefusal}
renamingId={renamingMemory}
onRenameCommit={renameMemoryCue}
onRenameCancel={() => setRenamingMemory(null)}
/>
) : (
<HotcueBar
cues={cueData?.cues ?? []}
slotCount={slotCount}
slotLabel={slotLabel}
selectedSlot={selectedSlot}
onSlotPress={onSlotPress}
onSlotRelease={onSlotRelease}
onSlotMenu={(slot, x, y) => {
setSelectedSlot(slot)
if (hotcueAt(slot)) setPadMenu({ slot, x, y })
}}
renamingSlot={renamingSlot}
onRenameCommit={renameSlot}
onRenameCancel={() => setRenamingSlot(null)}
/>
)
const modeSwitch = (
<ModeSwitch
label="Deck mode"
value={gridMode ? 'grid' : 'cues'}
options={[
{ value: 'cues', text: 'CUES', title: 'Cues: the hotcue pads or memory cues' },
{ value: 'grid', text: 'GRID', title: 'Edit the beatgrid: markers, phase, reset' },
]}
disabled={!track}
onChange={(m) => {
setGridMode(m === 'grid')
setPadMenu(null)
setRenamingSlot(null)
setMemoryMenu(null)
setRenamingMemory(null)
}}
/>
)
if (stacked) {
return (
<div className="@container flex min-w-0 flex-1 flex-col gap-2">
<div className="flex h-11 shrink-0 items-center gap-3">
{transport}
{DIVIDER}
{loopControls}
<span className="flex-1" />
{bankSwitch}
{modeSwitch}
<TempoControls {...tempoProps} className="@max-[52rem]:hidden" />
<TempoFold locked={tempoProps.locked} className="hidden @max-[52rem]:flex">
<TempoControls {...tempoProps} />
</TempoFold>
</div>
<div className="flex h-11 shrink-0 items-center">{strip}</div>
</div>
)
}
return (
<div className="@container flex h-11 shrink-0 items-center gap-3">
{transport}
{DIVIDER} {DIVIDER}
<LoopControls {loopControls}
mode={loopMode}
onMode={setLoopMode}
hasGrid={grid != null}
ready={ready}
size={beatSize}
onSmaller={() => stepSize(-1)}
onBigger={() => stepSize(1)}
loopActive={loopActive}
sizeLit={loopActive && activeBeats === beatSize}
onToggleSize={toggleSizeLoop}
canToggle={loopRegion != null}
inArmed={loopInPoint != null}
manualSet={loopRegion != null && activeBeats == null}
onLoopIn={loopIn}
onLoopOut={loopOut}
onToggleLoop={toggleLoop}
onMove={moveOrJump}
/>
{DIVIDER} {DIVIDER}
{caps.cues.memory_cues && !gridMode && ( {bankSwitch}
<ModeSwitch {strip}
label="Cue bank"
value={bankMode}
options={[
{ value: 'hot', text: 'HOT', title: 'Hot cues: the pads' },
{ value: 'memory', text: 'MEM', title: 'Memory cues: call one to make it the CUE point' },
]}
onChange={(m) => {
setBankMode(m)
setPadMenu(null)
setMemoryMenu(null)
setRenamingSlot(null)
setRenamingMemory(null)
}}
/>
)}
{gridMode ? (
<GridEditStrip
markerIndex={activeMarkerIndex}
markerCount={markerCount}
markerStart={activeMarker?.start ?? null}
atMarker={atMarker}
beforeFirst={beforeFirstMarker}
canReset={originalGridRef.current != null}
onPrevMarker={prevMarker}
onNextMarker={nextMarker}
onNudgeMarker={nudgeGrid}
onNudgeMarkerBeats={nudgeGridBeats}
onAddMarker={addMarkerHere}
onDeleteMarker={deleteMarkerHere}
onDeleteGrid={deleteGrid}
onReset={resetGrid}
/>
) : showMemory ? (
<MemoryCueStrip
cues={cueData?.cues ?? []}
cuePoint={cuePoint}
onCall={callMemoryCue}
onMenu={(cue, x, y) => setMemoryMenu({ cue, x, y })}
onAdd={() => void addMemoryCue()}
addRefusal={memoryAddRefusal}
renamingId={renamingMemory}
onRenameCommit={renameMemoryCue}
onRenameCancel={() => setRenamingMemory(null)}
/>
) : (
<HotcueBar
cues={cueData?.cues ?? []}
slotCount={slotCount}
slotLabel={slotLabel}
selectedSlot={selectedSlot}
onSlotPress={onSlotPress}
onSlotRelease={onSlotRelease}
onSlotMenu={(slot, x, y) => {
setSelectedSlot(slot)
if (hotcueAt(slot)) setPadMenu({ slot, x, y })
}}
renamingSlot={renamingSlot}
onRenameCommit={renameSlot}
onRenameCancel={() => setRenamingSlot(null)}
/>
)}
{DIVIDER} {DIVIDER}
<ModeSwitch {modeSwitch}
label="Deck mode"
value={gridMode ? 'grid' : 'cues'}
options={[
{ value: 'cues', text: 'CUES', title: 'Cues: the hotcue pads or memory cues' },
{ value: 'grid', text: 'GRID', title: 'Edit the beatgrid: markers, phase, reset' },
]}
disabled={!track}
onChange={(m) => {
setGridMode(m === 'grid')
setPadMenu(null)
setRenamingSlot(null)
setMemoryMenu(null)
setRenamingMemory(null)
}}
/>
<TempoControls {...tempoProps} className="@max-[77rem]:hidden" /> <TempoControls {...tempoProps} className="@max-[77rem]:hidden" />
<TempoFold locked={tempoProps.locked} className="hidden @max-[77rem]:flex"> <TempoFold locked={tempoProps.locked} className="hidden @max-[77rem]:flex">
<TempoControls {...tempoProps} /> <TempoControls {...tempoProps} />
+37 -15
View File
@@ -23,8 +23,20 @@ function fmtTime(secs: number, places: number): string {
} }
/** The deck's header: the track, its readouts, the analysis actions — and /** The deck's header: the track, its readouts, the analysis actions — and
* `actions`, anything the layout adds after them. */ * `actions`, anything the layout adds after them. `compact` (half-width, in
export function DeckHeader({ deck, actions }: { deck: Deck; actions?: ReactNode }) { * performance mode) tightens the readouts and drops the action buttons'
* words; `badge` leads the row (the deck's letter). */
export function DeckHeader({
deck,
actions,
compact = false,
badge,
}: {
deck: Deck
actions?: ReactNode
compact?: boolean
badge?: ReactNode
}) {
const { const {
caps, caps,
track, track,
@@ -47,8 +59,13 @@ export function DeckHeader({ deck, actions }: { deck: Deck; actions?: ReactNode
canAutoCue, canAutoCue,
} = deck } = deck
const timeDecimals = useAppSetting('timeReadoutDecimals') const timeDecimals = useAppSetting('timeReadoutDecimals')
const cell = `flex flex-col justify-center gap-px ${compact ? 'px-2.5' : 'px-4'}`
const action = `btn-glass flex h-9 shrink-0 items-center justify-center gap-2 rounded-full text-[13px] font-medium disabled:opacity-40 ${
compact ? 'w-9' : 'px-3.5'
}`
return ( return (
<div className="flex h-12 shrink-0 items-center gap-3"> <div className={`flex h-12 min-w-0 shrink-0 items-center ${compact ? 'gap-2' : 'gap-3'}`}>
{badge}
<CoverThumb <CoverThumb
trackId={track && origin === 'collection' ? track.id : null} trackId={track && origin === 'collection' ? track.id : null}
onOpen={track ? () => setInfoOpen(true) : undefined} onOpen={track ? () => setInfoOpen(true) : undefined}
@@ -57,7 +74,10 @@ export function DeckHeader({ deck, actions }: { deck: Deck; actions?: ReactNode
{track ? ( {track ? (
<> <>
<div className="flex min-w-0 items-center gap-2"> <div className="flex min-w-0 items-center gap-2">
<span className="truncate text-[17px] font-semibold tracking-tight text-text" title={track.title ?? ''}> <span
className={`truncate font-semibold tracking-tight text-text ${compact ? 'text-[15px]' : 'text-[17px]'}`}
title={track.title ?? ''}
>
{track.title ?? 'Untitled'} {track.title ?? 'Untitled'}
</span> </span>
{/* The deck stays usable for listening on a read-only library, {/* The deck stays usable for listening on a read-only library,
@@ -72,7 +92,7 @@ export function DeckHeader({ deck, actions }: { deck: Deck; actions?: ReactNode
</span> </span>
)} )}
</div> </div>
<div className="truncate text-[13px] text-muted" title={subtitle}> <div className={`truncate text-muted ${compact ? 'text-[12px]' : 'text-[13px]'}`} title={subtitle}>
{subtitle} {subtitle}
</div> </div>
</> </>
@@ -82,20 +102,20 @@ export function DeckHeader({ deck, actions }: { deck: Deck; actions?: ReactNode
</div> </div>
<div className="well flex h-11 shrink-0 items-stretch rounded-xl"> <div className="well flex h-11 shrink-0 items-stretch rounded-xl">
<div className="flex flex-col justify-center gap-px px-4"> <div className={cell}>
<span className="text-[10px] tracking-[0.08em] text-faint">ELAPSED</span> <span className="text-[10px] tracking-[0.08em] text-faint">ELAPSED</span>
<span className="font-mono text-[17px] font-medium">{fmtTime(current, timeDecimals)}</span> <span className={`font-mono font-medium ${compact ? 'text-[15px]' : 'text-[17px]'}`}>{fmtTime(current, timeDecimals)}</span>
</div> </div>
<span aria-hidden className="my-2 w-px bg-line" /> <span aria-hidden className="my-2 w-px bg-line" />
<div className="flex flex-col justify-center gap-px px-4"> <div className={cell}>
<span className="text-[10px] tracking-[0.08em] text-faint">REMAIN</span> <span className="text-[10px] tracking-[0.08em] text-faint">REMAIN</span>
<span className="font-mono text-[17px] font-medium">−{fmtTime(Math.max(0, duration - current), timeDecimals)}</span> <span className={`font-mono font-medium ${compact ? 'text-[15px]' : 'text-[17px]'}`}>−{fmtTime(Math.max(0, duration - current), timeDecimals)}</span>
</div> </div>
<span aria-hidden className="my-2 w-px bg-line" /> <span aria-hidden className="my-2 w-px bg-line" />
<div className="flex flex-col justify-center gap-px px-4"> <div className={cell}>
<span className="text-[10px] tracking-[0.08em] text-faint">KEY</span> <span className="text-[10px] tracking-[0.08em] text-faint">KEY</span>
<span <span
className="font-mono text-[17px] font-semibold" className={`font-mono font-semibold ${compact ? 'text-[15px]' : 'text-[17px]'}`}
style={{ color: keyColor(track?.key_wheel ?? null) }} style={{ color: keyColor(track?.key_wheel ?? null) }}
> >
{track?.key || '—'} {track?.key || '—'}
@@ -127,10 +147,11 @@ export function DeckHeader({ deck, actions }: { deck: Deck; actions?: ReactNode
title={canEditGrid title={canEditGrid
? 'Detect BPM and first beat, then set the grid + hotcue 1 (fix the octave with ÷2 / ×2); measure loudness' ? 'Detect BPM and first beat, then set the grid + hotcue 1 (fix the octave with ÷2 / ×2); measure loudness'
: 'Measure loudness (this track’s grid cannot be edited here)'} : 'Measure loudness (this track’s grid cannot be edited here)'}
className="btn-glass flex h-9 shrink-0 items-center gap-2 rounded-full px-3.5 text-[13px] font-medium disabled:opacity-40" aria-label="Analyze"
className={action}
> >
<Icon name="wave" size={16} /> <Icon name="wave" size={16} />
{gridBusy ? 'Analyzing…' : 'Analyze'} {!compact && (gridBusy ? 'Analyzing…' : 'Analyze')}
</button> </button>
<button <button
onClick={openAutoHotcues} onClick={openAutoHotcues}
@@ -140,10 +161,11 @@ export function DeckHeader({ deck, actions }: { deck: Deck; actions?: ReactNode
? "Place hotcues on the track's drops, breakdowns and other sections" ? "Place hotcues on the track's drops, breakdowns and other sections"
: 'Set a beatgrid first' : 'Set a beatgrid first'
} }
className="btn-glass flex h-9 shrink-0 items-center gap-2 rounded-full px-3.5 text-[13px] font-medium disabled:opacity-40" aria-label="Auto hotcues"
className={action}
> >
<Icon name="sparkle" size={16} /> <Icon name="sparkle" size={16} />
Auto hotcues {!compact && 'Auto hotcues'}
</button> </button>
{actions} {actions}
</div> </div>
+12
View File
@@ -378,6 +378,17 @@ export function useDeck({
setCurrent(eng.getPosition()) setCurrent(eng.getPosition())
} }
/** Stop playing, if it is (performance mode pauses deck B on the way out). */
const pause = () => {
const eng = playbackRef.current
if (!eng?.playing) return
previewRef.current = null
setPreviewing(false)
eng.pause()
setPlaying(false)
setCurrent(eng.getPosition())
}
// Start a momentary "cue preview" from `start` for holder `id`: play now, and // Start a momentary "cue preview" from `start` for holder `id`: play now, and
// remember to stop + return on release (see endPreview) unless it's latched. // remember to stop + return on release (see endPreview) unless it's latched.
const beginPreview = (id: string, start: number) => { const beginPreview = (id: string, start: number) => {
@@ -1361,6 +1372,7 @@ export function useDeck({
slotCount, slotCount,
slotLabel, slotLabel,
toggle, toggle,
pause,
onCuePress, onCuePress,
onCueRelease, onCueRelease,
seekManual, seekManual,
+9 -1
View File
@@ -11,6 +11,7 @@
// ← / → beat jump, or move an engaged loop // ← / → beat jump, or move an engaged loop
// Shift+← / → step between grid markers // Shift+← / → step between grid markers
// Cmd/Ctrl+↑ / ↓ loop / jump size (Shift+↑/↓ is the track table's) // Cmd/Ctrl+↑ / ↓ loop / jump size (Shift+↑/↓ is the track table's)
// P performance mode on / off (not a deck's key)
// //
// Keys are read from `e.code` (layout- and Shift-independent). A new or changed // Keys are read from `e.code` (layout- and Shift-independent). A new or changed
// key needs `lib/shortcuts.ts` (the keyboard map) updating by hand. // key needs `lib/shortcuts.ts` (the keyboard map) updating by hand.
@@ -40,6 +41,8 @@ export interface DeckKeyTargets {
focused: DeckShortcuts | null focused: DeckShortcuts | null
/** The other deck, in performance mode (else null: Alt does nothing). */ /** The other deck, in performance mode (else null: Alt does nothing). */
other: DeckShortcuts | null other: DeckShortcuts | null
/** P: performance mode on / off. */
togglePerformance?: () => void
} }
export type DeckKeyAction = export type DeckKeyAction =
@@ -140,7 +143,12 @@ export function useDeckKeys(targets: RefObject<DeckKeyTargets>): void {
// Ignore while typing in a field. // Ignore while typing in a field.
const t = e.target as HTMLElement | null const t = e.target as HTMLElement | null
if (t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.isContentEditable)) return if (t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' || t.isContentEditable)) return
const { focused, other } = targets.current const { focused, other, togglePerformance } = targets.current
if (e.code === 'KeyP' && !e.repeat && !e.altKey && !e.metaKey && !e.ctrlKey && !e.shiftKey && togglePerformance) {
e.preventDefault()
togglePerformance()
return
}
const r = keyAction(e, (toOther) => (toOther ? other : focused)?.slotCount ?? 0, other != null) const r = keyAction(e, (toOther) => (toOther ? other : focused)?.slotCount ?? 0, other != null)
const sc = r && (r.toOther ? other : focused) const sc = r && (r.toOther ? other : focused)
if (!r || !sc) return if (!r || !sc) return
+8
View File
@@ -99,6 +99,14 @@ const PATHS = {
fadeOut: <path d="M3 5l18 14H3z" strokeLinejoin="round" />, fadeOut: <path d="M3 5l18 14H3z" strokeLinejoin="round" />,
eject: <path d="M12 4l8 9H4zM4 18h16" strokeLinejoin="round" />, eject: <path d="M12 4l8 9H4zM4 18h16" strokeLinejoin="round" />,
grid: <path d="M5 3v18M10 3v18M15 3v18M20 3v18" />, grid: <path d="M5 3v18M10 3v18M15 3v18M20 3v18" />,
// Two platters and a crossfader: performance mode.
decks: (
<>
<circle cx="6.5" cy="10" r="4" />
<circle cx="17.5" cy="10" r="4" />
<path d="M9 19h6M12 17.5v3" />
</>
),
mouse: ( mouse: (
<> <>
<rect x="6" y="3" width="12" height="18" rx="6" /> <rect x="6" y="3" width="12" height="18" rx="6" />
+9 -2
View File
@@ -1,6 +1,6 @@
// What every shortcut does, for the keyboard map in `ShortcutsDialog`. // What every shortcut does, for the keyboard map in `ShortcutsDialog`.
// Written out BY HAND, not derived from the handlers: keep it in step with // Written out BY HAND, not derived from the handlers: keep it in step with
// `PrepStrip` (deck), `TrackTable` (track list) and `SettingsMenu` (`?`). // `lib/deckKeys.ts` (deck), `TrackTable` (track list) and `SettingsMenu` (`?`).
import { cueTypeColor, GRID_MARKER_ACTIVE_COLOR } from './cues' import { cueTypeColor, GRID_MARKER_ACTIVE_COLOR } from './cues'
import { IS_MAC } from './modKey' import { IS_MAC } from './modKey'
@@ -47,7 +47,7 @@ const STEMS: [string, string][] = [
const STEM_CODES = ['KeyQ', 'KeyW', 'KeyE', 'KeyR'] const STEM_CODES = ['KeyQ', 'KeyW', 'KeyE', 'KeyR']
/** The digit keys of a bank of `slots` pads: 1–9, then 0 for the tenth, as /** The digit keys of a bank of `slots` pads: 1–9, then 0 for the tenth, as
* `PrepStrip`'s `slotForDigit` reads them. */ * `deckKeys`' `slotForDigit` reads them. */
export function padCodes(slots: number): string[] { export function padCodes(slots: number): string[] {
return Array.from({ length: Math.min(slots, 10) }, (_, i) => (i === 9 ? 'Digit0' : `Digit${i + 1}`)) return Array.from({ length: Math.min(slots, 10) }, (_, i) => (i === 9 ? 'Digit0' : `Digit${i + 1}`))
} }
@@ -79,6 +79,13 @@ export function bindings(slots: number): Bindings {
}) })
Object.assign(b.base, { Object.assign(b.base, {
Space: [{ area: 'deck', label: 'Play / pause', text: 'Play / pause' }], Space: [{ area: 'deck', label: 'Play / pause', text: 'Play / pause' }],
KeyP: [
{
area: 'deck',
label: 'Decks',
text: 'Performance mode: a second deck, to try transitions. Click a deck to aim the keys at it. Press again to leave.',
},
],
KeyC: [ KeyC: [
{ area: 'deck', label: 'CUE', color: 'var(--color-gold)', text: 'CUE: jump back to the cue point, set it while paused, or hold to preview' }, { area: 'deck', label: 'CUE', color: 'var(--color-gold)', text: 'CUE: jump back to the cue point, set it while paused, or hold to preview' },
], ],