# WaveformAudioBufferSink

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/audio/WaveformAudioBufferSink.java+class:androidx.media3.exoplayer.audio.WaveformAudioBufferSink)

*** ** * ** ***


```
@UnstableApi
public class WaveformAudioBufferSink implements TeeAudioProcessor.AudioBufferSink
```

<br />

*** ** * ** ***

A sink for audio buffers that produces `https://developer.android.com/reference/androidx/media3/exoplayer/audio/WaveformAudioBufferSink.WaveformBar`.

## Summary

| ### Nested types |
|---|
| `public interface https://developer.android.com/reference/androidx/media3/exoplayer/audio/WaveformAudioBufferSink.Listener` Listener for the audio waveform generation. |
| `public class https://developer.android.com/reference/androidx/media3/exoplayer/audio/WaveformAudioBufferSink.WaveformBar` Aggregates a group of audio samples. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/audio/WaveformAudioBufferSink#WaveformAudioBufferSink(int,int,androidx.media3.exoplayer.audio.WaveformAudioBufferSink.Listener)( int barsPerSecond, int outputChannelCount, https://developer.android.com/reference/androidx/media3/exoplayer/audio/WaveformAudioBufferSink.Listener listener )` Creates a new instance. |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/WaveformAudioBufferSink#flush(int,int,int)(int sampleRateHz, int channelCount, @https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding int encoding)` Called when the audio processor is flushed with a format of subsequent input. |
| `void` | `https://developer.android.com/reference/androidx/media3/exoplayer/audio/WaveformAudioBufferSink#handleBuffer(java.nio.ByteBuffer)(https://developer.android.com/reference/java/nio/ByteBuffer.html buffer)` Called when data is written to the audio processor. |

## Public constructors

### WaveformAudioBufferSink

```
public WaveformAudioBufferSink(
    int barsPerSecond,
    int outputChannelCount,
    WaveformAudioBufferSink.Listener listener
)
```

Creates a new instance.

| Parameters |
|---|---|
| `int barsPerSecond` | The number of bars that should be generated per each second of audio. |
| `int outputChannelCount` | The number of channels that the output waveform should contain. If this is different than the number of input channels, the audio will be mixed using the `https://developer.android.com/reference/androidx/media3/common/audio/ChannelMixingMatrix#createForConstantGain(int,int)`. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/audio/WaveformAudioBufferSink.Listener listener` | The listener to be notified when a new waveform bar has been generated. |

## Public methods

### flush

```
public void flush(int sampleRateHz, int channelCount, @C.PcmEncoding int encoding)
```

Called when the audio processor is flushed with a format of subsequent input.

### handleBuffer

```
public void handleBuffer(ByteBuffer buffer)
```

Called when data is written to the audio processor.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/nio/ByteBuffer.html buffer` | A read-only buffer containing input which the audio processor will handle. |