Skip to main content

Overview

SoundText renders individual characters as interactive elements: hovering over each letter triggers a unique sine-wave tone generated via the Web Audio API, mapped to a pentatonic scale for a melodic effect. The character jumps, scales up, and glows purple in sync with the sound.
This component uses the Web Audio API. Audio is initialized on first user interaction to comply with browser autoplay policies. No microphone access is required — all audio is synthesized client-side.

Installation

Requires framer-motion as a peer dependency.

Usage

Props

string
default:"Hover over me"
The text content to display. Each non-space character becomes an independent interactive letter.
number
default:"300"
The root frequency in Hz for the pentatonic scale. Each character’s pitch is derived by multiplying this value by a scale ratio based on its index position. Higher values produce higher-pitched tones.
string
Additional Tailwind or CSS classes applied to the wrapper element. Use to control font size, color, and layout.

Examples

Default usage

Lower pitch, bass tones

Higher pitch, bright tones

Features

Web Audio API

Uses native browser audio synthesis — no audio files or external libraries required.

Pentatonic Scale

Each character maps to a harmonious frequency in a pentatonic scale, creating pleasant melodic interactions.

Spring Animations

Characters bounce upward, scale, and glow purple on hover using Framer Motion spring physics.

Lazy Audio Init

The AudioContext is created on first user interaction, ensuring compliance with browser autoplay policies.