Components Media and time

LevelMeter

Audio levels with peak hold, drawn on a canvas.

import { LevelMeter } from '@kition/tessera-ui'
Playground

Props

What is shown
import { LevelMeter } from '@kition/tessera-ui'

<LevelMeter peaks={[-9, -14]} holds={[-4, -8]} labels={['L', 'R']} />

Examples

Stereo
level-meter.tsx
import { useEffect, useState } from 'react'
import { LevelMeter } from '@kition/tessera-ui'

export default function Demo() {
  const [peaks, setPeaks] = useState([-12, -9])
  useEffect(() => {
    const timer = setInterval(() => setPeaks([-6 - Math.random() * 30, -4 - Math.random() * 30]), 100)
    return () => clearInterval(timer)
  }, [])
  return (
    <div style={{ height: 180 }}>
      <LevelMeter peaks={peaks} labels={['L', 'R']} />
    </div>
  )
}

Props

LevelMeter

PropTypeDefaultDescription
peaksrequiredreadonly number[]—Current peak per channel, linear 0..1+ (above 1 clips).
floornumber-60dB at the bottom of the scale (upstream meters: -60).
holdsreadonly number[]—Peak hold per channel, linear.
orientation'vertical' | 'horizontal''vertical'
labelsreadonly string[]—Channel captions under the bars ("S" "S" in upstream's solo buttons row, or "L" "R").
refRef<LevelMeterHandle>—Draws live levels without a React render.
testIdstring—

Used in

1 of Kition's 16 kits use this component.

  • Film