Home / Function/ BarVisualizerComponent() — ui Function Reference

BarVisualizerComponent() — ui Function Reference

Architecture documentation for the BarVisualizerComponent() function in elevenlabs.tsx from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  f7c88c80_61a2_5745_3423_ce9c217de6c5["BarVisualizerComponent()"]
  a1a6ebaf_3f49_5bb2_b404_b9f06dce2cab["elevenlabs.tsx"]
  f7c88c80_61a2_5745_3423_ce9c217de6c5 -->|defined in| a1a6ebaf_3f49_5bb2_b404_b9f06dce2cab
  e44c6358_72b2_3916_b4f2_57dd5af079e2["useMultibandVolume()"]
  f7c88c80_61a2_5745_3423_ce9c217de6c5 -->|calls| e44c6358_72b2_3916_b4f2_57dd5af079e2
  59e15c16_c47d_dcd9_417a_4962ff2a5a1a["useBarAnimator()"]
  f7c88c80_61a2_5745_3423_ce9c217de6c5 -->|calls| 59e15c16_c47d_dcd9_417a_4962ff2a5a1a
  style f7c88c80_61a2_5745_3423_ce9c217de6c5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/v4/registry/bases/base/blocks/elevenlabs.tsx lines 480–619

  (
    {
      state,
      barCount = 15,
      mediaStream,
      minHeight = 20,
      maxHeight = 100,
      demo = false,
      centerAlign = false,
      className,
      style,
      ...props
    },
    ref
  ) => {
    // Audio processing
    const realVolumeBands = useMultibandVolume(mediaStream, {
      bands: barCount,
      loPass: 100,
      hiPass: 200,
    })

    // Generate fake volume data for demo mode using refs to avoid state updates
    const fakeVolumeBandsRef = useRef<number[]>(new Array(barCount).fill(0.2))
    const [fakeVolumeBands, setFakeVolumeBands] = useState<number[]>(() =>
      new Array(barCount).fill(0.2)
    )
    const fakeAnimationRef = useRef<number | undefined>(undefined)

    // Animate fake volume bands for speaking and listening states
    useEffect(() => {
      if (!demo) return

      if (state !== "speaking" && state !== "listening") {
        const bands = new Array(barCount).fill(0.2)
        fakeVolumeBandsRef.current = bands
        setTimeout(() => {
          setFakeVolumeBands(bands)
        }, 0)
        return
      }

      let lastUpdate = 0
      const updateInterval = 50
      const startTime = Date.now() / 1000

      const updateFakeVolume = (timestamp: number) => {
        if (timestamp - lastUpdate >= updateInterval) {
          const time = Date.now() / 1000 - startTime
          const newBands = new Array(barCount)

          for (let i = 0; i < barCount; i++) {
            const waveOffset = i * 0.5
            const baseVolume = Math.sin(time * 2 + waveOffset) * 0.3 + 0.5
            const randomNoise = Math.random() * 0.2
            newBands[i] = Math.max(0.1, Math.min(1, baseVolume + randomNoise))
          }

          // Only update if values changed significantly
          let hasChanged = false
          for (let i = 0; i < barCount; i++) {
            if (Math.abs(newBands[i] - fakeVolumeBandsRef.current[i]) > 0.05) {
              hasChanged = true
              break
            }
          }

          if (hasChanged) {
            fakeVolumeBandsRef.current = newBands
            setFakeVolumeBands(newBands)
          }

          lastUpdate = timestamp
        }

        fakeAnimationRef.current = requestAnimationFrame(updateFakeVolume)
      }

      fakeAnimationRef.current = requestAnimationFrame(updateFakeVolume)

      return () => {

Subdomains

Frequently Asked Questions

What does BarVisualizerComponent() do?
BarVisualizerComponent() is a function in the ui codebase, defined in apps/v4/registry/bases/base/blocks/elevenlabs.tsx.
Where is BarVisualizerComponent() defined?
BarVisualizerComponent() is defined in apps/v4/registry/bases/base/blocks/elevenlabs.tsx at line 480.
What does BarVisualizerComponent() call?
BarVisualizerComponent() calls 2 function(s): useBarAnimator, useMultibandVolume.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free