Voice ring

A ring of light that bends with a voice, takes the colour of its mood and leans toward the speaker.

Listening
Processing
Mono, speaking
Mono, processing

These play a synthetic voice. The playground can listen to your microphone.

Playground

<script>
  import { VoiceRing } from 'runeglow/voice-ring';

  // A number from 0 to 1, or a function returning one, called every frame.
  let { level } = $props();
</script>

<VoiceRing state="listening" size={240} {level} />

Install

pnpm add runeglow

Or copy just this library’s source into your project, with the shadcn-svelte CLI:

npx shadcn-svelte@latest add https://runeglow.dev/r/voice-ring.json
import { VoiceRing, VoiceOrb, useMicrophone } from 'runeglow/voice-ring';

Usage

Place the ring and hand it a microphone stream. useMicrophone asks for it; call start from a click so the browser lets audio begin.

<script>
  import { VoiceRing, useMicrophone } from 'runeglow/voice-ring';

  const mic = useMicrophone();
</script>

<VoiceRing size={240} state="listening" stream={mic.stream} />
<button onclick={mic.start}>Listen</button>

Set state as the conversation moves. Listening and speaking draw the same way and differ only in what they follow: the microphone, or the assistant’s own audio through analyser or level.

<script>
  import { VoiceRing, useMicrophone } from 'runeglow/voice-ring';

  const mic = useMicrophone();
  // 'idle' | 'listening' | 'processing' | 'speaking', from your own app.
  let { turn, player } = $props();
</script>

{#if turn === 'speaking'}
  <!-- The assistant's voice: any AnalyserNode, or a level you compute. -->
  <VoiceRing state="speaking" analyser={player.analyser} />
{:else}
  <VoiceRing state={turn} stream={mic.stream} />
{/if}

An emotion tints it, a direction makes it lean, and hoverBend lets it reach for the cursor while it waits.

<VoiceRing
  type="mono"
  state="speaking"
  {level}
  emotion="calm"
  direction={-0.6}
  hoverBend
/>

Props

Prop Type Default Description
type 'ring' | 'mono' 'ring' ring is a glassy ribbon with a spectrum running round it. mono is two loops of grey tube that a voice opens into a turning globe.
state 'idle' | 'listening' | 'speaking' | 'processing' 'listening' The conversation state. Listening and speaking follow the source; idle and processing ignore it.
size number 160 Rendered size in CSS px. Designed at 200.
stream MediaStream | null – A live audio stream, usually mic.stream. Wins over analyser and level.
analyser AnalyserNode | null – An AnalyserNode you already have, such as the assistant’s voice playing back. Wins over level.
level number | (() => number) – Drive it yourself, 0 to 1. A function is called every frame.
sensitivity number 0.85 Input gain. Raise it for quiet sources.
threshold number 0.04 Noise gate: below this it hears silence.
attack number 0.06 Seconds to rise.
release number 0.32 Seconds to settle.
idle number 0.1 Breathing kept under the voice, so silence never looks dead.
calm number 0.4 The pace while it waits, as a share of the tuned speed.
speed number 1 Multiplier on the motion.
voiceSpeed number per type How much a voice speeds the motion up.
emotion 'positive' | 'negative' | 'calm' | null null Shifts the colour toward green, red or blue. It eases in and crossfades. Detection is yours to supply.
emotionColors Partial<Record<emotion, { r, g, b }>> – Your own colour for any emotion, 0 to 255 per channel.
direction number | (() => number) – Where the voice comes from, -1 left to 1 right. The ring leans that way while a voice is heard.
hoverBend boolean | number false Bends toward the cursor near the rim while idle or processing. true is 0.55; a number sets the strength.
theme 'auto' | 'dark' | 'light' 'auto' auto reads an ancestor’s data-theme or dark/light class, then the system setting.
paused boolean false Holds the current frame.
dots number 1 Density multiplier on the type’s dot and segment counts.
opts Record<string, number> – The type’s own knobs, such as { rings: 8, halo: 0.7 }. The playground lists them.
onLevel (level: number) => void – Called every frame with the shaped level, 0 to 1.
ref HTMLCanvasElement | null – The canvas. Bindable with bind:ref.
...rest HTMLCanvasAttributes – class, style, aria-label and other attributes are forwarded to the canvas.

Leaning toward a voice

These apply once direction is set. A browser microphone is mono, so the side has to come from you: a stereo capture, a diarised speaker, or where that person sits in your interface.

Prop Type Default Description
directionMove number per type How far it drifts toward the voice, as a share of its radius.
directionPull number per type How far its near side is pulled out beyond the far side.
directionDeform number per type How much the near flank bulges.
directionSquash number per type At the edge, how much it squashes against it, 0 to 1.
directionLens number per type At the edge, how strongly it is refracted into it, as through glass, 0 to 2.
directionStretch, directionSplit, directionBlur number per type The edge lens’s distortion, colour split and blur, 0 to 2.
directionBounce number per type How much it bounces as it meets the edge, 0 to 2.
directionMargin number 32 CSS px it stops short of the edge.
directionBounds Element | null – An element whose left and right edges it leans up to, instead of the screen’s. Give that element overflow: hidden.

VoiceOrb

The ring is drawn by a more general component that the package also exports. It has five more types, drawn in ink instead of light, which can take a colour gradient.

orbit
sash
signal
swell
pixel
<script>
  import { VoiceOrb } from 'runeglow/voice-ring';
</script>

<VoiceOrb type="swell" size={160} state="listening" {level} accent="green" />

It takes every prop above, and these as well:

Prop Type Default Description
type 'orbit' | 'sash' | 'signal' | 'swell' | 'pixel' | 'aura' | 'aura-mono' 'orbit' Which orb. aura and aura-mono are VoiceRing’s ring and mono.
accent 'green' | 'red' | 'blue' | null null A fixed colour for the gradient, shown even without an emotion.
saturation number 2 How strong the colour gets: 0 never, 1 the colour itself, up to 2 purer and deeper.
neutral number 1 1 starts the gradient in plain ink; 0 covers the orb in the colour.
colorBrightness, colorHue number 1.02, 0 The colour’s brightness, and degrees to turn its hue.
gradientAngle, gradientSpin number 99, 12 Which way the gradient runs in degrees, and how fast it turns in degrees per second.
gradientStart, gradientWidth number 0.1, 0.6 Where across the orb the colour begins, and how far it takes to arrive in full.
color string – An ink tint: #rgb, #rrggbb or rgb(). Depth shading is kept on it.
dotSize number per type Multiplier on every dot radius.
frame TypeFrame – Replace the type’s geometry with your own function.

Notes

  • Nothing is recorded or played back. The stream is only analysed.
  • It shares one audio context and one microphone helper with Voice, so a stream opened for one can drive the other.
  • If it stays still while you speak, the browser has probably opened an input that is switched off, such as a laptop’s built-in microphone while its lid is closed. Pick the input yourself with useMicrophone({ constraints: { deviceId } }).
  • With a direction, the canvas grows sideways into negative margins so the lean is never cut off. The layout still measures size by size.
  • It pauses while offscreen or on a hidden tab, and holds a still frame under prefers-reduced-motion.
  • The React package pairs with two separate models for detecting emotion and direction. They are not part of this port: pass your own values to emotion and direction.