import { useLiveStreamStore } from "../../../features/liveStream/model/liveStream.store"; import { WsStatusBadge } from "../../../features/liveStream/ui/WsStatusBadge"; import { AudioMeter } from "./AudioMeter"; import { FrequencyHistoryChart } from "./FrequencyHistoryChart"; import { Card, CardContent, CardHeader, CardTitle, } from "../../../shared/ui/card"; import { freqToNote } from "../../../entities/audioSample/lib/note"; import { formatTimeHHMMSS, isStale } from "../../../shared/lib/time"; export function AudioLiveWidget() { const status = useLiveStreamStore((s) => s.status); const latest = useLiveStreamStore((s) => s.latest); const history60s = useLiveStreamStore((s) => s.history60s); const peakHoldDb3s = useLiveStreamStore((s) => s.peakHoldDb3s); const lastMessageAt = useLiveStreamStore((s) => s.lastMessageAt); const stale = isStale(lastMessageAt, 1500); const note = latest ? freqToNote(latest.freq_hz) : "--"; return (
Live status
Last update
{lastMessageAt ? formatTimeHHMMSS(lastMessageAt) : "—"} {stale ? "stale" : "ok"}
Frequency
{latest ? `${latest.freq_hz.toFixed(0)} Hz` : "—"}{" "} ({note})
RMS
{latest ? `${latest.rms_db.toFixed(1)} dB` : "—"}
); }