A lightweight Expo/React Native audio waveform widget that records microphone input and renders a real-time waveform. It works on iOS/Android (via Expo AV metering) and Web (via Web Audio AnalyserNode).
- Real-time waveform bars driven by normalized volume data (
0..1) - Simple, customizable
AudioWaveformcomponent (bar width/gap, colors, min/max height) useAudioRecorderhook that handles permissions and platform-specific volume capture
Run the app and tap the button to start/stop recording. The waveform updates while recording.
- Node.js + npm
- Expo CLI (optional;
npx expoalso works)
npm installnpm run startThen choose a platform:
- iOS: press
i - Android: press
a - Web: press
w
App.tsx shows the intended integration:
import AudioWaveform from './AudioWaveform';
import { useAudioRecorder } from './useAudioRecorder';
const { isRecording, volumeData, startRecording, stopRecording, error } = useAudioRecorder();
<AudioWaveform
data={volumeData}
barWidth={4}
barGap={6}
minHeight={12}
maxHeight={58}
barColor="#FFFFFF"
backgroundColor="#000000"
/>;AudioWaveform.tsx: waveform UI component (animated bars)useAudioRecorder.ts: recording + real-time volume capture (native metering / web analyser)App.tsx: example screen wiring everything togetherdist/: web build output (committed in this repo)
- Microphone permission is required. On Web, your browser will prompt; on mobile, Expo will request permission at runtime.
- On Web we compute volume from time-domain audio using RMS, then apply a mild gain + non-linear mapping to make the waveform more visible.
- On some devices
meteringmay be unavailable; the hook falls back to a small baseline value to avoid a “frozen” UI.
MIT