Added in API level 9

OnDataCaptureListener

interface OnDataCaptureListener
android.media.audiofx.Visualizer.OnDataCaptureListener

The OnDataCaptureListener interface defines methods called by the Visualizer to periodically update the audio visualization capture. The client application can implement this interface and register the listener with the setDataCaptureListener(android.media.audiofx.Visualizer.OnDataCaptureListener,int,boolean,boolean) method.

Summary

Public methods
abstract Unit
onFftDataCapture(visualizer: Visualizer!, fft: ByteArray!, samplingRate: Int)

Method called when a new frequency capture is available.

abstract Unit
onWaveFormDataCapture(visualizer: Visualizer!, waveform: ByteArray!, samplingRate: Int)

Method called when a new waveform capture is available.

Public methods

onFftDataCapture

Added in API level 9
abstract fun onFftDataCapture(
    visualizer: Visualizer!,
    fft: ByteArray!,
    samplingRate: Int
): Unit

Method called when a new frequency capture is available.

Data in the fft buffer is valid only within the scope of the callback. Applications which need access to the fft data after returning from the callback should make a copy of the data instead of holding a reference.

For the explanation of the fft data array layout, and the example code for processing it, please see the documentation for getFft(byte[]) method.

Parameters
visualizer Visualizer!: Visualizer object on which the listener is registered.
fft ByteArray!: array of bytes containing the frequency representation.
samplingRate Int: sampling rate of the visualized audio.

onWaveFormDataCapture

Added in API level 9
abstract fun onWaveFormDataCapture(
    visualizer: Visualizer!,
    waveform: ByteArray!,
    samplingRate: Int
): Unit

Method called when a new waveform capture is available.

Data in the waveform buffer is valid only within the scope of the callback. Applications which need access to the waveform data after returning from the callback should make a copy of the data instead of holding a reference.

Parameters
visualizer Visualizer!: Visualizer object on which the listener is registered.
waveform ByteArray!: array of bytes containing the waveform representation.
samplingRate Int: sampling rate of the visualized audio.