Dela via


Visualizer Class

Definition

The Visualizer class enables application to retrieve part of the currently playing audio for visualization purpose.

[Android.Runtime.Register("android/media/audiofx/Visualizer", DoNotGenerateAcw=true)]
public class Visualizer : Java.Lang.Object
[<Android.Runtime.Register("android/media/audiofx/Visualizer", DoNotGenerateAcw=true)>]
type Visualizer = class
    inherit Object
Inheritance
Visualizer
Attributes

Remarks

The Visualizer class enables application to retrieve part of the currently playing audio for visualization purpose. It is not an audio recording interface and only returns partial and low quality audio content. However, to protect privacy of certain audio data (e.g voice mail) the use of the visualizer requires the permission android.permission.RECORD_AUDIO.

The audio session ID passed to the constructor indicates which audio content should be visualized:<br> <ul> <li>If the session is 0, the audio output mix is visualized</li> <li>If the session is not 0, the audio from a particular android.media.MediaPlayer or android.media.AudioTrack using this audio session is visualized </li> </ul>

Two types of representation of audio content can be captured: <br> <ul> <li>Waveform data: consecutive 8-bit (unsigned) mono samples by using the #getWaveForm(byte[]) method</li> <li>Frequency data: 8-bit magnitude FFT by using the #getFft(byte[]) method</li> </ul>

The length of the capture can be retrieved or specified by calling respectively #getCaptureSize() and #setCaptureSize(int) methods. The capture size must be a power of 2 in the range returned by #getCaptureSizeRange().

In addition to the polling capture mode described above with #getWaveForm(byte[]) and #getFft(byte[]) methods, a callback mode is also available by installing a listener by use of the #setDataCaptureListener(OnDataCaptureListener, int, boolean, boolean) method. The rate at which the listener capture method is called as well as the type of data returned is specified.

Before capturing data, the Visualizer must be enabled by calling the #setEnabled(boolean) method. When data capture is not needed any more, the Visualizer should be disabled.

It is good practice to call the #release() method when the Visualizer is not used anymore to free up native resources associated to the Visualizer instance.

Creating a Visualizer on the output mix (audio session 0) requires permission android.Manifest.permission#MODIFY_AUDIO_SETTINGS

The Visualizer class can also be used to perform measurements on the audio being played back. The measurements to perform are defined by setting a mask of the requested measurement modes with #setMeasurementMode(int). Supported values are #MEASUREMENT_MODE_NONE to cancel any measurement, and #MEASUREMENT_MODE_PEAK_RMS for peak and RMS monitoring. Measurements can be retrieved through #getMeasurementPeakRms(MeasurementPeakRms).

Java documentation for android.media.audiofx.Visualizer.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Visualizer(Int32)

Class constructor.

Visualizer(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Fields

AlreadyExists
Obsolete.

Internal operation status.

Error
Obsolete.

Unspecified error.

ErrorBadValue
Obsolete.

Operation failed due to bad parameter value.

ErrorDeadObject
Obsolete.

Operation failed due to dead remote object.

ErrorInvalidOperation
Obsolete.

Operation failed because it was requested in wrong state.

ErrorNoInit
Obsolete.

Operation failed due to bad object initialization.

ErrorNoMemory
Obsolete.

Operation failed due to lack of memory.

MeasurementModeNone
Obsolete.

Defines a measurement mode in which no measurements are performed.

MeasurementModePeakRms
Obsolete.

Defines a measurement mode which computes the peak and RMS value in mB below the "full scale", where 0mB is normally the maximum sample value (but see the note below).

ScalingModeAsPlayed
Obsolete.

Defines a capture mode where the playback volume will affect (scale) the range of the captured data.

ScalingModeNormalized
Obsolete.

Defines a capture mode where amplification is applied based on the content of the captured data.

StateEnabled
Obsolete.

State of a Visualizer object that is active.

StateInitialized
Obsolete.

State of a Visualizer object that is ready to be used.

StateUninitialized
Obsolete.

State of a Visualizer object that was not successfully initialized upon creation

Success
Obsolete.

Successful operation.

Properties

CaptureSize

Returns current capture size.

Class

Returns the runtime class of this Object.

(Inherited from Object)
Enabled

Get current activation state of the visualizer.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
MaxCaptureRate

Returns the maximum capture rate for the callback capture method.

MeasurementMode

Returns the current measurement modes performed by this audio effect

PeerReference (Inherited from Object)
SamplingRate

Returns the sampling rate of the captured audio.

ScalingMode

Returns the current scaling mode on the captured visualization data.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetCaptureSizeRange()

Returns the capture size range.

GetFft(Byte[])

Returns a frequency capture of currently playing audio content.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetMeasurementPeakRms(Visualizer+MeasurementPeakRms)

Retrieves the latest peak and RMS measurement.

GetWaveForm(Byte[])

Returns a waveform capture of currently playing audio content.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
Release()

Releases the native Visualizer resources.

SetCaptureSize(Int32)

Sets the capture size, i.

SetDataCaptureListener(Visualizer+IOnDataCaptureListener, Int32, Boolean, Boolean)

Registers an OnDataCaptureListener interface and specifies the rate at which the capture should be updated as well as the type of capture requested.

SetEnabled(Boolean)

Enable or disable the visualization engine.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetMeasurementMode(VisualizerMeasurementMode)

Sets the combination of measurement modes to be performed by this audio effect.

SetScalingMode(VisualizerScalingMode)

Set the type of scaling applied on the captured visualization data.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to