mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Implemented time readout accuracy setting
This commit is contained in:
1 parent
16c3552be6
commit
77b063ba0e
3 files changed
+42
-9
No files matched your search
@@ -14,6 +14,8 @@ export const APP_SETTING_DEFAULTS = {
|
||||
expandPlaylistFolders: false,
|
||||
/** Read by the backend when an export runs (`main.run_export`). */
|
||||
exportRootFolder: false,
|
||||
/** Decimal places on the deck's ELAPSED / REMAIN readouts (0–3). */
|
||||
timeReadoutDecimals: 1,
|
||||
}
|
||||
|
||||
type AppSettingKey = keyof typeof APP_SETTING_DEFAULTS
|
||||
@@ -29,6 +31,7 @@ export function AppSettings({ onClose }: { onClose: () => void }) {
|
||||
const qc = useQueryClient()
|
||||
const expandFolders = useAppSetting('expandPlaylistFolders')
|
||||
const exportRootFolder = useAppSetting('exportRootFolder')
|
||||
const timeDecimals = useAppSetting('timeReadoutDecimals')
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
@@ -95,6 +98,28 @@ export function AppSettings({ onClose }: { onClose: () => void }) {
|
||||
</span>
|
||||
</label>
|
||||
</section>
|
||||
<section className="space-y-2">
|
||||
<h3 className="text-[11px] font-semibold uppercase tracking-wider text-faint">Deck</h3>
|
||||
<label className="flex items-start justify-between gap-4">
|
||||
<span className="min-w-0">
|
||||
<span className="block text-sm text-text">Time readout precision</span>
|
||||
<span className="block text-xs text-faint">
|
||||
Decimal places on the Elapsed and Remain readouts. 1 shows tenths, 3 milliseconds.
|
||||
</span>
|
||||
</span>
|
||||
<select
|
||||
className="shrink-0 rounded-lg well px-2 py-1 text-sm text-text outline-none"
|
||||
value={timeDecimals}
|
||||
onChange={(e) => void set({ timeReadoutDecimals: Number(e.target.value) })}
|
||||
>
|
||||
{['00:00', '00:00.0', '00:00.00', '00:00.000'].map((sample, n) => (
|
||||
<option key={n} value={n}>
|
||||
{n} — {sample}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
</section>
|
||||
{error && <div className="text-xs text-pink">{error}</div>}
|
||||
</div>
|
||||
<div className="flex justify-end gap-2 border-t border-line px-5 py-3">
|
||||
|
||||
@@ -35,6 +35,7 @@ import { HotcueBar } from './HotcueBar'
|
||||
import { LoopControls, LOOP_SIZES, type LoopMode } from './LoopControls'
|
||||
import { MainWaveform, MIN_SEC, MAX_SEC, DEFAULT_SEC, type StemLane } from './MainWaveform'
|
||||
import { OverviewWaveform } from './OverviewWaveform'
|
||||
import { useAppSetting } from './AppSettings'
|
||||
import { usePrefsWriter } from '../lib/prefs'
|
||||
|
||||
/** Keys that mute stems 1-4 (Shift = solo), by `KeyboardEvent.code`. */
|
||||
@@ -66,13 +67,19 @@ interface Props {
|
||||
onEditTags?: (track: Track) => void
|
||||
}
|
||||
|
||||
/** m:ss.t — the deck's readouts show tenths, as a CDJ does. */
|
||||
function fmtTenths(secs: number): string {
|
||||
/** mm:ss.f — tenths by default, as a CDJ does; `places` is the
|
||||
* `timeReadoutDecimals` setting (0 drops the fraction). Truncates, never
|
||||
* rounds, so the readout never shows a second before it has been reached. */
|
||||
function fmtTime(secs: number, places: number): string {
|
||||
if (!isFinite(secs) || secs < 0) secs = 0
|
||||
const tenths = Math.floor(secs * 10)
|
||||
const m = Math.floor(tenths / 600)
|
||||
const s = Math.floor((tenths % 600) / 10)
|
||||
return `${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}.${tenths % 10}`
|
||||
const scale = 10 ** places
|
||||
// The epsilon keeps e.g. 0.3 s from reading 0.299 at 3 places.
|
||||
const units = Math.floor(secs * scale + 1e-6)
|
||||
const whole = Math.floor(units / scale)
|
||||
const m = Math.floor(whole / 60)
|
||||
const s = whole % 60
|
||||
const frac = places > 0 ? `.${(units % scale).toString().padStart(places, '0')}` : ''
|
||||
return `${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}${frac}`
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,6 +124,7 @@ export function PrepStrip({
|
||||
// which the pointer's :active alone cannot, since the key never touches it.
|
||||
const [cueHeld, setCueHeld] = useState(false)
|
||||
const [current, setCurrent] = useState(0)
|
||||
const timeDecimals = useAppSetting('timeReadoutDecimals')
|
||||
const [duration, setDuration] = useState(0)
|
||||
const [ready, setReady] = useState(false)
|
||||
const [cols, setCols] = useState<WaveColumn[] | null>(null)
|
||||
@@ -1338,12 +1346,12 @@ export function PrepStrip({
|
||||
<div className="well flex h-11 shrink-0 items-stretch rounded-xl">
|
||||
<div className="flex flex-col justify-center gap-px px-4">
|
||||
<span className="text-[10px] tracking-[0.08em] text-faint">ELAPSED</span>
|
||||
<span className="font-mono text-[17px] font-medium">{fmtTenths(current)}</span>
|
||||
<span className="font-mono text-[17px] font-medium">{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">
|
||||
<span className="text-[10px] tracking-[0.08em] text-faint">REMAIN</span>
|
||||
<span className="font-mono text-[17px] font-medium">−{fmtTenths(Math.max(0, duration - current))}</span>
|
||||
<span className="font-mono text-[17px] font-medium">−{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">
|
||||
|
||||
Reference in new issue
Block a user