Skip to content

Component Volume Knob

Reese Hodge edited this page Nov 16, 2026 · 4 revisions

Component Volume Knob

The volume knob is an invisible clickable hit area over the TV artwork plus an 11-segment LED bar. It exists today as a controlled React component; volume storage is local to Component-Frontend-App, and gain application happens through Component-Audio-Chain. The related feature page is Feature-Volume-Knob.

Files

  • packages/frontend/src/components/VolumeKnob.tsx renders the control and converts continuous gain to discrete steps.
  • packages/frontend/src/App.tsx owns [volume, setVolume] = useState(6 / 11), passes props into VolumeKnob, and calls audioChain.setVolume(volume) (the chain is a lazy useState value, not a ref).
  • packages/frontend/src/App.css positions .volume-knob-wrapper, styles .volume-knob, .volume-led-bar, .volume-led, .volume-led--lit, .volume-led--dim, and .volume-led--max.
  • packages/frontend/src/stores/voiceStore.ts was checked because it is related voice state, but it does not contain volume state today.

Exported functions and props

VolumeKnob.tsx exports:

export function VolumeKnob({
  volume,
  onVolumeChange,
  disabled,
}: VolumeKnobProps)

Internal prop shape:

interface VolumeKnobProps {
  volume: number;
  onVolumeChange: (volume: number) => void;
  disabled: boolean;
}

Internal helpers:

  • gainToStep(volume: number): number rounds volume * 11 and clamps to 0..11.
  • stepToGain(step: number): number returns 0 for step 0, otherwise step / 11.

voiceStore.ts exports useVoiceStore, whose state is isSpeaking, isMouthOpen, isMicActive, and isGreeting; it has no volume, setVolume, or persisted audio-level action.

Current behavior

  • MAX_STEP = 11 and LED_COUNT = 11.
  • The app starts at step 6 for audible base volume. The indicator maps every volume step proportionally across the calibrated arc from -235 degrees at step 0 (bottom-left) to 45 degrees at step 11 (down-right), placing step 6 at about 55% of the arc.
  • Clicking cycles 0 -> 1 -> ... -> 11 -> 0.
  • External volume remains the normalized gain contract 0..1.
  • The button exposes aria-valuemin={0}, aria-valuemax={11}, aria-valuenow={step}, and aria-valuetext.
  • Step 11 changes aria-valuetext to 11 of 11 — one louder.
  • LED segments 1..step are lit unless disabled.
  • The eleventh LED gets volume-led--max and, when lit, a warm accent color.
  • The component does not handle drag, wheel, keyboard-specific increments, or persisted volume.

Styling and placement

App places VolumeKnob in controlPanel, which CrtFrame renders inside .crt-panel. CSS positions the wrapper at top: 40.1% inside the panel. The button itself is transparent and circular (width: 55%; aspect-ratio: 1 / 1) so it acts as a hit target over the painted brass knob in the TV image. The LED bar sits below it with 11 flexed segments.

Gotchas

  • The current implementation is click-to-cycle only. Any specified richer physical knob behavior is not present in code today.
  • Volume is not owned by voiceStore; it is local React state in App.tsx. Reloading the app resets it to step 6 (6 / 11 gain). Turning the TV off and on preserves the selected step.
  • Disabled state dims LEDs by leaving them unlit even if the underlying volume state is non-zero.

Clone this wiki locally