Stay organized with collections
Save and categorize content based on your preferences.
OnDataCaptureListener
interface 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 |
Method called when a new frequency capture is available.
|
abstract Unit |
Method called when a new waveform capture is available.
|
Public methods
onFftDataCapture
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. |
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. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# Visualizer.OnDataCaptureListener\n\nAdded in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnDataCaptureListener\n=====================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/media/audiofx/Visualizer.OnDataCaptureListener \"View this page in Java\") \n\n```\ninterface OnDataCaptureListener\n```\n\n|-------------------------------------------------------------|\n| [android.media.audiofx.Visualizer.OnDataCaptureListener](#) |\n\nThe 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)](/reference/kotlin/android/media/audiofx/Visualizer#setDataCaptureListener(android.media.audiofx.Visualizer.OnDataCaptureListener,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Boolean)) method.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onFftDataCapture](#onFftDataCapture(android.media.audiofx.Visualizer,%20kotlin.ByteArray,%20kotlin.Int))`(`visualizer:` `[Visualizer](/reference/kotlin/android/media/audiofx/Visualizer)!`, `fft:` `[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!`, `samplingRate:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Method called when a new frequency capture is available. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onWaveFormDataCapture](#onWaveFormDataCapture(android.media.audiofx.Visualizer,%20kotlin.ByteArray,%20kotlin.Int))`(`visualizer:` `[Visualizer](/reference/kotlin/android/media/audiofx/Visualizer)!`, `waveform:` `[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!`, `samplingRate:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Method called when a new waveform capture is available. |\n\nPublic methods\n--------------\n\n### onFftDataCapture\n\nAdded in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onFftDataCapture(\n visualizer: Visualizer!, \n fft: ByteArray!, \n samplingRate: Int\n): Unit\n```\n\nMethod called when a new frequency capture is available.\n\nData 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.\n\nFor the explanation of the fft data array layout, and the example code for processing it, please see the documentation for [getFft(byte[])](/reference/kotlin/android/media/audiofx/Visualizer#getFft(kotlin.ByteArray)) method.\n\n| Parameters ||\n|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------|\n| `visualizer` | [Visualizer](/reference/kotlin/android/media/audiofx/Visualizer)!: Visualizer object on which the listener is registered. |\n| `fft` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!: array of bytes containing the frequency representation. |\n| `samplingRate` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): sampling rate of the visualized audio. |\n\n### onWaveFormDataCapture\n\nAdded in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onWaveFormDataCapture(\n visualizer: Visualizer!, \n waveform: ByteArray!, \n samplingRate: Int\n): Unit\n```\n\nMethod called when a new waveform capture is available.\n\nData 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.\n\n| Parameters ||\n|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------|\n| `visualizer` | [Visualizer](/reference/kotlin/android/media/audiofx/Visualizer)!: Visualizer object on which the listener is registered. |\n| `waveform` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!: array of bytes containing the waveform representation. |\n| `samplingRate` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): sampling rate of the visualized audio. |"]]