# WaveformAudioBufferSink

# 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)

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/androidx/media3/exoplayer/audio/WaveformAudioBufferSink "View this page in Java")


```
@UnstableApi
class WaveformAudioBufferSink : TeeAudioProcessor.AudioBufferSink
```

<br />

*** ** * ** ***

A sink for audio buffers that produces [waveform bars](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/WaveformAudioBufferSink.WaveformBar).

## Summary

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

|                                                                                                                                                                                                                                                                                                            ### Public constructors                                                                                                                                                                                                                                                                                                            |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [WaveformAudioBufferSink](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/WaveformAudioBufferSink#WaveformAudioBufferSink(int,int,androidx.media3.exoplayer.audio.WaveformAudioBufferSink.Listener))`(` ` barsPerSecond: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` outputChannelCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` listener: `[WaveformAudioBufferSink.Listener](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/WaveformAudioBufferSink.Listener)`!` `)` Creates a new instance. |

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [flush](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/WaveformAudioBufferSink#flush(int,int,int))`(sampleRateHz: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, channelCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, @`[C.PcmEncoding](https://developer.android.com/reference/kotlin/androidx/media3/common/C.PcmEncoding)` encoding: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Called when the audio processor is flushed with a format of subsequent input. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [handleBuffer](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/WaveformAudioBufferSink#handleBuffer(java.nio.ByteBuffer))`(buffer: `[ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer.html)`!)` Called when data is written to the audio processor.                                                                                                                                                                                                                                                                                                     |

## Public constructors

### WaveformAudioBufferSink

```
WaveformAudioBufferSink(
    barsPerSecond: Int,
    outputChannelCount: Int,
    listener: WaveformAudioBufferSink.Listener!
)
```

Creates a new instance.  

|                                                                             Parameters                                                                             |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `barsPerSecond: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                       | The number of bars that should be generated per each second of audio.                                                                                                                                                                                                                                              |
| `outputChannelCount: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                  | 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 [default mixing matrix](https://developer.android.com/reference/kotlin/androidx/media3/common/audio/ChannelMixingMatrix#createForConstantGain(int,int)). |
| `listener: `[WaveformAudioBufferSink.Listener](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/audio/WaveformAudioBufferSink.Listener)`!` | The listener to be notified when a new waveform bar has been generated.                                                                                                                                                                                                                                            |

## Public functions

### flush

```
fun flush(sampleRateHz: Int, channelCount: Int, @C.PcmEncoding encoding: Int): Unit
```

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

### handleBuffer

```
fun handleBuffer(buffer: ByteBuffer!): Unit
```

Called when data is written to the audio processor.  

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