RunningWaveForm

fun RunningWaveForm(restartKey: Any, newValueKey: Int, latestValue: Int?, modifier: Modifier = Modifier, maxInputValue: Int = 20, barMinHeight: Float = 0.1f, barWidth: Dp = 8.dp, barGap: Dp = 2.dp, barCornerRadius: CornerRadius = CornerRadius(barWidth.value / 2.5f, barWidth.value / 2.5f), barBrush: Brush = Brush.linearGradient( Pair(0f, ChatTheme.colors.primaryAccent), Pair(1f, ChatTheme.colors.primaryAccent), ))

A stateful composable that creates a "waveform" visualizer used to display mic input during recording. You should poll the amplitude of the audio input and update the composable's latestValue input when each new value is emitted. Null values are ignored.

Since the composable is stateful, restartKey is used to remember the state. If you want to reset the composable's state simply pass in a new key.

Parameters

restartKey

Used to reset the state of the composable when a value different to the previous value is passed in.

newValueKey

Should be incremented upon every new latestValue. Used so that if the same latestValue is posted twice in a valid way, we add a new bar for each emission.

latestValue

Represents the latest value from the audio input. The composable will draw a new bar for each latest value passed in.

modifier

Modifier for styling.

maxInputValue

The maximum amplitude of the input. A latestValue equaling maxInputValue will result in the bar height equaling the height of the whole composable.

barMinHeight

Minimum bar height, expressed as a percentage of the complete height of the composable.

barWidth

The width of a single bar representing audio input.

barGap

The gap between two bars.

barCornerRadius

The corner radius if the bars.

barBrush

The brush used to outline the bars.