mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Fixed some UI issues
This commit is contained in:
1 parent
14f93bedc0
commit
40866aed79
5 files changed
+168
-44
No files matched your search
@@ -34,7 +34,8 @@ Two independent apps that talk over HTTP:
|
||||
picker's "Automatic" option; sorts newest Traktor version first.
|
||||
- `prefs.py` — tiny persisted user-prefs store in `userprefs.json` (resolved
|
||||
relative to the package so it travels with the app; gitignored). Holds the
|
||||
last-opened collection path and the library column layout. Best-effort I/O.
|
||||
last-opened collection path, the library column layout, and the prep deck's
|
||||
main-waveform zoom (`mainZoomSec`). Best-effort I/O.
|
||||
- `schemas.py` — Pydantic response/request models.
|
||||
- `main.py` — FastAPI routes (all under `/api`). Holds an `AppState` with the
|
||||
currently-loaded collection; it starts **unloaded** and the collection is
|
||||
@@ -56,8 +57,11 @@ Two independent apps that talk over HTTP:
|
||||
(right-click → multi-field metadata + album-art edit), `StatusBar`,
|
||||
`RatingStars` (read-only, or click-to-set when given `onChange`), `Toast`.
|
||||
- **Prep strip** (DJ deck across the top of the window): `PrepStrip` owns it —
|
||||
transport (play/pause, CUE), two waveforms (`MainWaveform` scrolling+zoomable,
|
||||
`OverviewWaveform` whole-track), `LoopControls`, `HotcueBar`, `GridControls`.
|
||||
transport (play/pause, CUE), two waveforms (`MainWaveform` scrolling+zoomable
|
||||
— its zoom is owned by `PrepStrip` so it survives track switches and persists,
|
||||
`OverviewWaveform` whole-track), `LoopControls`, `HotcueBar`, `GridControls`
|
||||
(BPM readout/editor, fine ±0.01 / coarse ±0.25 BPM nudge, /2·×2, tap tempo,
|
||||
grid-phase nudge, set beat 1, lock, delete grid).
|
||||
Prep libs live in `src/lib/`: `playbackEngine.ts` (Web Audio, seamless loops),
|
||||
`scratchEngine.ts` (drag-to-scratch), `waveform.ts` (frequency-colored
|
||||
analysis + paint), `cues.ts` (draw cues/loop/beatgrid/cue-point). See "Prep
|
||||
@@ -71,7 +75,9 @@ Two independent apps that talk over HTTP:
|
||||
button flushes to disk. Styling is Tailwind v4 with tokens in `src/index.css`.
|
||||
Library column layout (visibility/order/width) persists to `userprefs.json`
|
||||
via `GET`/`PATCH /api/prefs` (debounced; hydrated on launch, merged against
|
||||
defaults so newly-added columns still appear).
|
||||
defaults so newly-added columns still appear). The prep deck's main-waveform
|
||||
zoom persists the same way (`mainZoomSec`, hydrated in `PrepStrip` from the
|
||||
shared `['prefs']` query).
|
||||
|
||||
## Commands
|
||||
|
||||
@@ -157,7 +163,7 @@ frontend at `http://localhost:5173`.
|
||||
- ✅ Track prep — audio playback, frequency-colored scrolling waveform, scratch,
|
||||
beatgrid display + editing, cue/hotcue create/jump/delete, loops; keyboard
|
||||
shortcuts (Space = play/pause, 1–8 = hotcues, Shift+1–8 = delete). See "Prep engine".
|
||||
- ⬜ Track prep Tier 2 — cue-point fine editing / audio export polish
|
||||
- ✅ Track prep Tier 2 — cue-point fine editing / audio export polish
|
||||
- ⬜ Bulk metadata editing; ⬜ Phase 4 — polish + optional Tauri desktop packaging
|
||||
|
||||
## Write path (playlists + track metadata + prep)
|
||||
|
||||
@@ -43,20 +43,28 @@ file Traktor uses, so everything you do shows up next time you open Traktor.
|
||||
## Getting started
|
||||
|
||||
Konduktor runs as two small local servers (a Python backend and a web
|
||||
frontend). One-time setup, then a single command to launch.
|
||||
frontend). Do the one-time setup, then start them — the same steps work on
|
||||
macOS, Linux, and Windows.
|
||||
|
||||
### 1. Install (once)
|
||||
|
||||
**Backend** — needs Python 3.11+:
|
||||
**Backend** — needs Python 3.11+. Create a virtual environment and install the
|
||||
dependencies:
|
||||
|
||||
```bash
|
||||
cd backend
|
||||
python3 -m venv .venv && source .venv/bin/activate
|
||||
python3 -m venv .venv # Windows: python -m venv .venv
|
||||
```
|
||||
|
||||
Activate it, then install:
|
||||
|
||||
```bash
|
||||
source .venv/bin/activate # Windows (PowerShell): .\.venv\Scripts\Activate.ps1
|
||||
pip install -r requirements.txt
|
||||
cd ..
|
||||
```
|
||||
|
||||
**Frontend** — needs Node 18+:
|
||||
**Frontend** — needs Node 18+ (same on every platform):
|
||||
|
||||
```bash
|
||||
cd frontend
|
||||
@@ -66,14 +74,28 @@ cd ..
|
||||
|
||||
### 2. Run it (development)
|
||||
|
||||
Konduktor runs as two local servers (backend on `:8000`, frontend on `:5173`).
|
||||
|
||||
**macOS / Linux** — one command starts both:
|
||||
|
||||
```bash
|
||||
./dev.sh
|
||||
```
|
||||
|
||||
This starts both servers; open **http://localhost:5173** in your browser. Press
|
||||
`Ctrl-C` to stop. This is the fastest way to try Konduktor or hack on it — the
|
||||
frontend hot-reloads as you edit. To package a real double-clickable app
|
||||
instead, see [Build a standalone app](#build-a-standalone-app-production) below.
|
||||
**Windows** — start each server in its own terminal:
|
||||
|
||||
```powershell
|
||||
# Terminal 1 — backend
|
||||
cd backend; .\.venv\Scripts\Activate.ps1; uvicorn konduktor.main:app --reload --port 8000
|
||||
|
||||
# Terminal 2 — frontend
|
||||
cd frontend; npm run dev
|
||||
```
|
||||
|
||||
Either way, open **http://localhost:5173** in your browser (`Ctrl-C` stops a
|
||||
server). This is the fastest way to try Konduktor or hack on it — the frontend
|
||||
hot-reloads as you edit. To package a real double-clickable app instead, see
|
||||
[Build a standalone app](#build-a-standalone-app-production) below.
|
||||
|
||||
### 3. Open your collection
|
||||
|
||||
@@ -100,38 +122,55 @@ On top of the Python 3.11+ and Node 18+ from above:
|
||||
- **Rust** — install from <https://rustup.rs> (the app shell is Tauri/Rust).
|
||||
- **PyInstaller** — into the backend venv:
|
||||
`pip install -r backend/requirements-build.txt`
|
||||
- **Windows only:** also the MSVC C++ build tools and the WebView2 runtime — see
|
||||
[BUILDING-WINDOWS.md](BUILDING-WINDOWS.md) for the one-time toolchain setup.
|
||||
|
||||
### macOS
|
||||
The build is a two-step recipe on both platforms: **freeze the backend into a
|
||||
sidecar binary**, then **build the app**. The only difference is which sidecar
|
||||
script you run — `.sh` on macOS/Linux, `.ps1` on Windows. Each build runs on its
|
||||
own OS (the app can't be cross-compiled).
|
||||
|
||||
### macOS / Linux
|
||||
|
||||
```bash
|
||||
# 1) Freeze the backend into a sidecar binary (run from the backend venv)
|
||||
cd backend && source .venv/bin/activate
|
||||
./build_sidecar.sh
|
||||
cd ..
|
||||
# 1) Freeze the backend into a sidecar binary (from the activated backend venv)
|
||||
cd backend && source .venv/bin/activate && ./build_sidecar.sh && cd ..
|
||||
|
||||
# 2) Build the app
|
||||
cd frontend
|
||||
npx tauri build
|
||||
cd frontend && npx tauri build
|
||||
```
|
||||
|
||||
You'll get an installer at
|
||||
The installer lands at
|
||||
`frontend/src-tauri/target/release/bundle/dmg/Konduktor_<version>_aarch64.dmg`
|
||||
(with the `.app` beside it). Builds are currently **unsigned**, so the first
|
||||
launch needs a right-click → **Open** to get past Gatekeeper. The `.dmg` is
|
||||
Apple-Silicon (`aarch64`) only.
|
||||
|
||||
> **Faster local builds:** `npx tauri build --debug --bundles app` skips the
|
||||
> optimizer and the `.dmg`, giving you a runnable `.app` in seconds — handy while
|
||||
> iterating.
|
||||
(with the `.app` beside it).
|
||||
|
||||
### Windows
|
||||
|
||||
Windows can't be cross-built from macOS — the (near-identical) steps to run on a
|
||||
Windows machine are in **[BUILDING-WINDOWS.md](BUILDING-WINDOWS.md)**.
|
||||
```powershell
|
||||
# 1) Freeze the backend into a sidecar binary (from the activated backend venv)
|
||||
cd backend; .\.venv\Scripts\Activate.ps1; .\build_sidecar.ps1; cd ..
|
||||
|
||||
# 2) Build the app
|
||||
cd frontend; npx tauri build
|
||||
```
|
||||
|
||||
The installers land in `frontend\src-tauri\target\release\bundle\` (an `.msi` and
|
||||
an NSIS `-setup.exe`). See [BUILDING-WINDOWS.md](BUILDING-WINDOWS.md) for the full
|
||||
walkthrough and Windows-specific notes.
|
||||
|
||||
> **Note:** builds are currently **unsigned**, so the first launch is flagged by
|
||||
> the OS — on macOS right-click → **Open** to get past Gatekeeper; on Windows
|
||||
> click **More info → Run anyway** past SmartScreen. The macOS `.dmg` is
|
||||
> Apple-Silicon (`aarch64`) only.
|
||||
|
||||
> **Faster local builds:** `npx tauri build --debug --bundles app` skips the
|
||||
> optimizer and the installer, giving you a runnable app in seconds — handy while
|
||||
> iterating.
|
||||
|
||||
### Rebuilding after changes
|
||||
|
||||
Changed **backend** Python? Re-run `./build_sidecar.sh`, then `npx tauri build`.
|
||||
Changed **backend** Python? Re-run the sidecar script for your OS
|
||||
(`./build_sidecar.sh` or `.\build_sidecar.ps1`), then `npx tauri build`.
|
||||
Frontend-only change? Just `npx tauri build` — it rebuilds the web app for you.
|
||||
|
||||
---
|
||||
|
||||
@@ -5,6 +5,7 @@ interface Props {
|
||||
locked: boolean
|
||||
hasGrid: boolean
|
||||
onSetBpm: (bpm: number) => void
|
||||
onNudgeBpm: (delta: number) => void
|
||||
onHalve: () => void
|
||||
onDouble: () => void
|
||||
onNudge: (deltaMs: number) => void
|
||||
@@ -20,15 +21,17 @@ const BTN =
|
||||
'disabled:hover:border-line'
|
||||
|
||||
/**
|
||||
* Beatgrid / tempo panel (Traktor grid-control equivalent): editable BPM, half/
|
||||
* double, tap tempo, grid-phase nudge (±1/±10 ms), set beat 1 at the playhead,
|
||||
* reset to the loaded values, lock, and delete grid.
|
||||
* Beatgrid / tempo panel (Traktor grid-control equivalent): editable BPM, BPM
|
||||
* nudge (fine ±0.01 / coarse ±0.25), half/double, tap tempo, grid-phase nudge
|
||||
* (±1/±10 ms), set beat 1 at the playhead, reset to the loaded values, lock,
|
||||
* and delete grid.
|
||||
*/
|
||||
export function GridControls({
|
||||
bpm,
|
||||
locked,
|
||||
hasGrid,
|
||||
onSetBpm,
|
||||
onNudgeBpm,
|
||||
onHalve,
|
||||
onDouble,
|
||||
onNudge,
|
||||
@@ -91,6 +94,45 @@ export function GridControls({
|
||||
<div className="text-[10px] font-semibold uppercase tracking-wider text-faint">BPM</div>
|
||||
</div>
|
||||
|
||||
{/* BPM nudge — coarse ±0.25 (outer) / fine ±0.01 (inner) */}
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="mr-0.5 text-[10px] font-semibold uppercase tracking-wider text-faint">
|
||||
BPM
|
||||
</span>
|
||||
<button
|
||||
className={BTN}
|
||||
onClick={() => onNudgeBpm(-0.25)}
|
||||
disabled={bpm == null}
|
||||
title="Nudge BPM −0.25 (coarse)"
|
||||
>
|
||||
−.25
|
||||
</button>
|
||||
<button
|
||||
className={BTN}
|
||||
onClick={() => onNudgeBpm(-0.01)}
|
||||
disabled={bpm == null}
|
||||
title="Nudge BPM −0.01 (fine)"
|
||||
>
|
||||
−.01
|
||||
</button>
|
||||
<button
|
||||
className={BTN}
|
||||
onClick={() => onNudgeBpm(0.01)}
|
||||
disabled={bpm == null}
|
||||
title="Nudge BPM +0.01 (fine)"
|
||||
>
|
||||
+.01
|
||||
</button>
|
||||
<button
|
||||
className={BTN}
|
||||
onClick={() => onNudgeBpm(0.25)}
|
||||
disabled={bpm == null}
|
||||
title="Nudge BPM +0.25 (coarse)"
|
||||
>
|
||||
+.25
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* halve / double / tap / reset */}
|
||||
<div className="flex gap-1">
|
||||
<button className={BTN} onClick={onHalve} disabled={bpm == null} title="Halve BPM">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useEffect, useRef } from 'react'
|
||||
import type { CuePoint } from '../api'
|
||||
import { drawBeatgrid, drawCuePoint, drawCues, drawLoop } from '../lib/cues'
|
||||
import { paintWave, type WaveColumn } from '../lib/waveform'
|
||||
@@ -12,6 +12,10 @@ interface Props {
|
||||
bpm: number | null
|
||||
gridAnchor: number | null
|
||||
loop: { start: number; end: number } | null
|
||||
/** Seconds across the view — the zoom level, owned by the parent so it
|
||||
survives track switches and persists to prefs. */
|
||||
secPerView: number
|
||||
onZoomChange: (secPerView: number) => void
|
||||
onSeek: (t: number) => void
|
||||
onScratchStart: () => void
|
||||
onScratchMove: (t: number) => void
|
||||
@@ -20,9 +24,9 @@ interface Props {
|
||||
|
||||
const DRAG_THRESHOLD = 3 // px before a press becomes a scratch (vs a click-seek)
|
||||
|
||||
const MIN_SEC = 2 // most zoomed-in (seconds across the view)
|
||||
const MAX_SEC = 64 // most zoomed-out
|
||||
const DEFAULT_SEC = 16
|
||||
export const MIN_SEC = 2 // most zoomed-in (seconds across the view)
|
||||
export const MAX_SEC = 64 // most zoomed-out
|
||||
export const DEFAULT_SEC = 16
|
||||
|
||||
/**
|
||||
* Traktor-style scrolling main waveform: the playhead is fixed at the centre and
|
||||
@@ -39,6 +43,8 @@ export function MainWaveform({
|
||||
bpm,
|
||||
gridAnchor,
|
||||
loop,
|
||||
secPerView,
|
||||
onZoomChange,
|
||||
onSeek,
|
||||
onScratchStart,
|
||||
onScratchMove,
|
||||
@@ -46,7 +52,6 @@ export function MainWaveform({
|
||||
}: Props) {
|
||||
const wrapRef = useRef<HTMLDivElement>(null)
|
||||
const canvasRef = useRef<HTMLCanvasElement>(null)
|
||||
const [secPerView, setSecPerView] = useState(DEFAULT_SEC)
|
||||
// Drag state for scratching. startTime is the playhead position at press;
|
||||
// dragging maps horizontal movement to a time offset (right = earlier, so the
|
||||
// waveform follows the cursor like grabbing a record).
|
||||
@@ -172,8 +177,8 @@ export function MainWaveform({
|
||||
else onSeek(timeAtClientX(e.clientX, e.currentTarget.getBoundingClientRect()))
|
||||
}
|
||||
|
||||
const zoomIn = () => setSecPerView((s) => Math.max(MIN_SEC, s / 2))
|
||||
const zoomOut = () => setSecPerView((s) => Math.min(MAX_SEC, s * 2))
|
||||
const zoomIn = () => onZoomChange(Math.max(MIN_SEC, secPerView / 2))
|
||||
const zoomOut = () => onZoomChange(Math.min(MAX_SEC, secPerView * 2))
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type Track, type TrackCues } from '../api'
|
||||
import { analyzeWaveform, type WaveColumn } from '../lib/waveform'
|
||||
import { ScratchEngine } from '../lib/scratchEngine'
|
||||
@@ -7,7 +7,7 @@ import { PlaybackEngine } from '../lib/playbackEngine'
|
||||
import { GridControls } from './GridControls'
|
||||
import { HotcueBar } from './HotcueBar'
|
||||
import { LoopControls } from './LoopControls'
|
||||
import { MainWaveform } from './MainWaveform'
|
||||
import { MainWaveform, MIN_SEC, MAX_SEC, DEFAULT_SEC } from './MainWaveform'
|
||||
import { OverviewWaveform } from './OverviewWaveform'
|
||||
|
||||
interface Props {
|
||||
@@ -53,6 +53,7 @@ export function PrepStrip({ track, playRequest = 0, onError }: Props) {
|
||||
const [snap, setSnap] = useState(true)
|
||||
const [selectedSlot, setSelectedSlot] = useState<number | null>(null)
|
||||
const [cuePoint, setCuePoint] = useState(0) // floating "CUE" point (frontend-only)
|
||||
const [secPerView, setSecPerView] = useState(DEFAULT_SEC) // main-waveform zoom (persisted)
|
||||
|
||||
// Loop state (transient — persisted only when saved as a hotcue later).
|
||||
const [loopRegion, setLoopRegion] = useState<{ start: number; end: number } | null>(null)
|
||||
@@ -73,6 +74,32 @@ export function PrepStrip({ track, playRequest = 0, onError }: Props) {
|
||||
|
||||
const trackId = track?.id ?? null
|
||||
|
||||
// Main-waveform zoom persists to userprefs.json so it survives track switches
|
||||
// (MainWaveform unmounts during each load) and app restarts. Hydrate once from
|
||||
// the shared ['prefs'] query, then persist changes debounced (mirrors the
|
||||
// column-layout prefs flow in App).
|
||||
const prefsQuery = useQuery({ queryKey: ['prefs'], queryFn: api.getPrefs })
|
||||
const zoomHydratedRef = useRef(false)
|
||||
const zoomSaveTimer = useRef<number | null>(null)
|
||||
useEffect(() => {
|
||||
if (zoomHydratedRef.current || !prefsQuery.data) return
|
||||
zoomHydratedRef.current = true
|
||||
const z = (prefsQuery.data as { mainZoomSec?: unknown }).mainZoomSec
|
||||
if (typeof z === 'number' && isFinite(z)) {
|
||||
setSecPerView(Math.min(MAX_SEC, Math.max(MIN_SEC, z)))
|
||||
}
|
||||
}, [prefsQuery.data])
|
||||
useEffect(() => {
|
||||
if (!zoomHydratedRef.current) return // don't clobber saved prefs pre-hydration
|
||||
if (zoomSaveTimer.current) window.clearTimeout(zoomSaveTimer.current)
|
||||
zoomSaveTimer.current = window.setTimeout(() => {
|
||||
api.patchPrefs({ mainZoomSec: secPerView }).catch(() => {})
|
||||
}, 500)
|
||||
return () => {
|
||||
if (zoomSaveTimer.current) window.clearTimeout(zoomSaveTimer.current)
|
||||
}
|
||||
}, [secPerView])
|
||||
|
||||
const getCtx = (): AudioContext => {
|
||||
if (!audioCtxRef.current) {
|
||||
audioCtxRef.current = new (window.AudioContext ??
|
||||
@@ -531,6 +558,8 @@ export function PrepStrip({ track, playRequest = 0, onError }: Props) {
|
||||
}
|
||||
}
|
||||
const setBpm = (bpm: number) => editGrid({ bpm })
|
||||
const nudgeBpm = (delta: number) =>
|
||||
gridBpm && editGrid({ bpm: Math.round((gridBpm + delta) * 1000) / 1000 })
|
||||
const halveBpm = () => gridBpm && editGrid({ bpm: gridBpm / 2 })
|
||||
const doubleBpm = () => gridBpm && editGrid({ bpm: gridBpm * 2 })
|
||||
const nudgeGrid = (deltaMs: number) => {
|
||||
@@ -565,7 +594,7 @@ export function PrepStrip({ track, playRequest = 0, onError }: Props) {
|
||||
const activeLoop = loopActive && loopRegion ? loopRegion : null
|
||||
|
||||
return (
|
||||
<div className="flex h-72 shrink-0 items-stretch gap-px border-b border-line bg-ink-950">
|
||||
<div className="flex h-[21rem] shrink-0 items-stretch gap-px border-b border-line bg-ink-950">
|
||||
{/* Controls */}
|
||||
<div className="flex w-72 shrink-0 flex-col gap-3 bg-ink-900 px-4 py-3">
|
||||
<div className="min-w-0">
|
||||
@@ -589,6 +618,7 @@ export function PrepStrip({ track, playRequest = 0, onError }: Props) {
|
||||
locked={cueData?.locked ?? false}
|
||||
hasGrid={gridAnchor != null}
|
||||
onSetBpm={setBpm}
|
||||
onNudgeBpm={nudgeBpm}
|
||||
onHalve={halveBpm}
|
||||
onDouble={doubleBpm}
|
||||
onNudge={nudgeGrid}
|
||||
@@ -659,6 +689,8 @@ export function PrepStrip({ track, playRequest = 0, onError }: Props) {
|
||||
bpm={cueData?.bpm ?? null}
|
||||
gridAnchor={cueData?.grid_anchor ?? null}
|
||||
loop={activeLoop}
|
||||
secPerView={secPerView}
|
||||
onZoomChange={setSecPerView}
|
||||
onSeek={seekManual}
|
||||
onScratchStart={onScratchStart}
|
||||
onScratchMove={onScratchMove}
|
||||
|
||||
Reference in new issue
Block a user