mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Implemented performance mode
This commit is contained in:
1 parent
063463efdd
commit
9df73ddcd2
9 files changed
+552
-211
No files matched your search
@@ -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 { api, type Track, type TrackOrigin } from '../api'
|
||||
import { useCaps } from '../lib/capabilities'
|
||||
import { api, type Capabilities, type Track, type TrackOrigin } from '../api'
|
||||
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 { DeckControls } from './deck/DeckControls'
|
||||
import { DeckHeader } from './deck/DeckHeader'
|
||||
import { DeckOverlays } from './deck/DeckOverlays'
|
||||
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'
|
||||
|
||||
interface Props {
|
||||
/** The track currently loaded into the prep deck, if any. */
|
||||
export type DeckId = 'A' | 'B'
|
||||
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
|
||||
/** Bumped by the library's per-row play button to load + auto-play. */
|
||||
playRequest?: number
|
||||
origin: TrackOrigin
|
||||
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
|
||||
/** Neutral/success feedback (e.g. Auto Hotcues result). */
|
||||
onNotify?: (kind: 'success' | 'error', msg: string) => void
|
||||
/** Which library the track belongs to (see `DeckOptions.origin`). */
|
||||
origin?: TrackOrigin
|
||||
/** Bumped when something outside the deck (batch grid analysis) rewrote the
|
||||
* loaded track's cues/grid, so the deck re-reads them. */
|
||||
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. */
|
||||
/** Reports whether a deck is playing, so the library can light its row. */
|
||||
onPlayingChange: (id: DeckId, playing: boolean) => void
|
||||
/** Opens Edit Tags — passed only where the library will accept the edit;
|
||||
* a deck offers it only for a collection track. */
|
||||
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
|
||||
* readouts, a scrolling zoomable main waveform above a whole-track overview,
|
||||
* then transport, loop and hotcue controls. The deck itself — state, audio,
|
||||
* 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
|
||||
* worklet (lib/audio/).
|
||||
* The DJ-style deck strip across the top of the window. The decks themselves —
|
||||
* state, audio, every action — are `useDeck` (components/deck/); this lays
|
||||
* them out and routes the keyboard to them.
|
||||
*
|
||||
* One deck normally. PERFORMANCE MODE (P, or the button beside Auto hotcues)
|
||||
* 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) {
|
||||
const caps = useCaps()
|
||||
export function PrepStrip({
|
||||
decks,
|
||||
caps,
|
||||
performance,
|
||||
onTogglePerformance,
|
||||
focused,
|
||||
onFocus,
|
||||
drop,
|
||||
onError,
|
||||
onNotify,
|
||||
onPlayingChange,
|
||||
onEditTags,
|
||||
}: Props) {
|
||||
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 })
|
||||
keys.current = { focused: deck.shortcuts, other: null }
|
||||
keys.current = {
|
||||
focused: deckOf(lead).shortcuts,
|
||||
other: performance ? deckOf(otherDeck(lead)).shortcuts : null,
|
||||
togglePerformance: onTogglePerformance,
|
||||
}
|
||||
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 (
|
||||
<div className="glass flex h-[19.75rem] shrink-0 flex-col gap-2 p-4">
|
||||
<DeckHeader deck={deck} />
|
||||
<DeckMainWave deck={deck} view={view} />
|
||||
<DeckOverview deck={deck} view={view} />
|
||||
<DeckControls deck={deck} />
|
||||
<DeckOverlays deck={deck} />
|
||||
<div className="glass flex h-[29rem] shrink-0 flex-col gap-2 p-4">
|
||||
<div className="flex shrink-0 items-center gap-3">
|
||||
{pane('A', <DeckHeader deck={a} compact badge={badge('A')} />)}
|
||||
{toggle}
|
||||
{pane('B', <DeckHeader deck={b} compact badge={badge('B')} />)}
|
||||
</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>
|
||||
)
|
||||
}
|
||||
@@ -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
|
||||
* 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.
|
||||
*
|
||||
* `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 {
|
||||
caps,
|
||||
track,
|
||||
@@ -84,8 +89,8 @@ export function DeckControls({ deck }: { deck: Deck }) {
|
||||
renameSlot,
|
||||
tempoProps,
|
||||
} = deck
|
||||
return (
|
||||
<div className="@container flex h-11 shrink-0 items-center gap-3">
|
||||
const transport = (
|
||||
<>
|
||||
<button
|
||||
onClick={toggle}
|
||||
disabled={!ready}
|
||||
@@ -122,107 +127,140 @@ export function DeckControls({ deck }: { deck: Deck }) {
|
||||
>
|
||||
CUE
|
||||
</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}
|
||||
<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}
|
||||
/>
|
||||
{loopControls}
|
||||
{DIVIDER}
|
||||
{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)
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{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)}
|
||||
/>
|
||||
)}
|
||||
{bankSwitch}
|
||||
{strip}
|
||||
{DIVIDER}
|
||||
<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)
|
||||
}}
|
||||
/>
|
||||
{modeSwitch}
|
||||
<TempoControls {...tempoProps} className="@max-[77rem]:hidden" />
|
||||
<TempoFold locked={tempoProps.locked} className="hidden @max-[77rem]:flex">
|
||||
<TempoControls {...tempoProps} />
|
||||
|
||||
@@ -23,8 +23,20 @@ function fmtTime(secs: number, places: number): string {
|
||||
}
|
||||
|
||||
/** The deck's header: the track, its readouts, the analysis actions — and
|
||||
* `actions`, anything the layout adds after them. */
|
||||
export function DeckHeader({ deck, actions }: { deck: Deck; actions?: ReactNode }) {
|
||||
* `actions`, anything the layout adds after them. `compact` (half-width, in
|
||||
* 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 {
|
||||
caps,
|
||||
track,
|
||||
@@ -47,8 +59,13 @@ export function DeckHeader({ deck, actions }: { deck: Deck; actions?: ReactNode
|
||||
canAutoCue,
|
||||
} = deck
|
||||
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 (
|
||||
<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
|
||||
trackId={track && origin === 'collection' ? track.id : null}
|
||||
onOpen={track ? () => setInfoOpen(true) : undefined}
|
||||
@@ -57,7 +74,10 @@ export function DeckHeader({ deck, actions }: { deck: Deck; actions?: ReactNode
|
||||
{track ? (
|
||||
<>
|
||||
<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'}
|
||||
</span>
|
||||
{/* 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>
|
||||
)}
|
||||
</div>
|
||||
<div className="truncate text-[13px] text-muted" title={subtitle}>
|
||||
<div className={`truncate text-muted ${compact ? 'text-[12px]' : 'text-[13px]'}`} title={subtitle}>
|
||||
{subtitle}
|
||||
</div>
|
||||
</>
|
||||
@@ -82,20 +102,20 @@ export function DeckHeader({ deck, actions }: { deck: Deck; actions?: ReactNode
|
||||
</div>
|
||||
|
||||
<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="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>
|
||||
<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="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>
|
||||
<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="font-mono text-[17px] font-semibold"
|
||||
className={`font-mono font-semibold ${compact ? 'text-[15px]' : 'text-[17px]'}`}
|
||||
style={{ color: keyColor(track?.key_wheel ?? null) }}
|
||||
>
|
||||
{track?.key || '—'}
|
||||
@@ -127,10 +147,11 @@ export function DeckHeader({ deck, actions }: { deck: Deck; actions?: ReactNode
|
||||
title={canEditGrid
|
||||
? '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)'}
|
||||
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} />
|
||||
{gridBusy ? 'Analyzing…' : 'Analyze'}
|
||||
{!compact && (gridBusy ? 'Analyzing…' : 'Analyze')}
|
||||
</button>
|
||||
<button
|
||||
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"
|
||||
: '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} />
|
||||
Auto hotcues
|
||||
{!compact && 'Auto hotcues'}
|
||||
</button>
|
||||
{actions}
|
||||
</div>
|
||||
|
||||
@@ -378,6 +378,17 @@ export function useDeck({
|
||||
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
|
||||
// remember to stop + return on release (see endPreview) unless it's latched.
|
||||
const beginPreview = (id: string, start: number) => {
|
||||
@@ -1361,6 +1372,7 @@ export function useDeck({
|
||||
slotCount,
|
||||
slotLabel,
|
||||
toggle,
|
||||
pause,
|
||||
onCuePress,
|
||||
onCueRelease,
|
||||
seekManual,
|
||||
|
||||
Reference in new issue
Block a user