AudioWaveform

fun AudioWaveform(amplitudes: List<Float>, modifier: Modifier = Modifier, style: WaveformStyle = WaveformStyle.Bar(), colors: WaveformColors = WaveformColors.default(), progress: Float = 1.0f, onProgressChange: (Float) -> Unit? = null, animate: Boolean = true, animationSpec: AnimationSpec<Float> = spring( dampingRatio = Spring.DampingRatioMediumBouncy, stiffness = Spring.StiffnessLow ))

A highly customizable audio waveform visualization composable.

Supports multiple visualization styles, smooth animations, playback progress tracking, and interactive seeking.

Basic Usage

AudioWaveform(
amplitudes = recorderState.liveAmplitudes,
modifier = Modifier.fillMaxWidth().height(64.dp)
)

With Custom Style

AudioWaveform(
amplitudes = amplitudes,
style = WaveformStyle.Mirrored(barWidth = 4.dp, gap = 4.dp),
colors = WaveformColors.PurpleGradient,
modifier = Modifier.fillMaxWidth().height(80.dp)
)

With Playback Progress

AudioWaveform(
amplitudes = amplitudes,
progress = playbackProgress,
onProgressChange = { newProgress -> seekTo(newProgress) },
colors = WaveformColors(
waveColor = SolidColor(Color.Gray),
progressColor = SolidColor(Color.Green),
),
modifier = Modifier.fillMaxWidth().height(48.dp)
)

Available Styles

Parameters

amplitudes

List of amplitude values (0.0 to 1.0). Values outside this range are clamped.

modifier

Modifier for the waveform. Must include size constraints (e.g., fillMaxWidth(), height()).

style

Visualization style. Defaults to WaveformStyle.Bar.

colors

Color configuration. Defaults to WaveformColors.default.

progress

Playback progress (0.0 to 1.0). Bars before this point use progressColor.

onProgressChange

Callback when user seeks via tap/drag. Pass null to disable interaction.

animate

Whether to animate amplitude changes. Defaults to true.

animationSpec

Animation specification for amplitude transitions.

See also


fun AudioWaveform(amplitudes: List<Float>, modifier: Modifier = Modifier, style: WaveformStyle = WaveformStyle.Bar(), colors: WaveformColors = WaveformColors.default(), animate: Boolean = true)

Simplified overload for basic waveform display without progress tracking.

Parameters

amplitudes

List of amplitude values (0.0 to 1.0)

modifier

Modifier for the waveform

style

Visualization style

colors

Color configuration

animate

Whether to animate amplitude changes