AudioTrack AudioTrack Class

Definition

The AudioTrack class manages and plays a single audio resource for Java applications.

[Android.Runtime.Register("android/media/AudioTrack", ApiSince=3, DoNotGenerateAcw=true)]
public class AudioTrack : Java.Lang.Object, Android.Media.IVolumeAutomation, IDisposable
type AudioTrack = class
    inherit Object
    interface IVolumeAutomation
    interface IJavaObject
    interface IDisposable
Inheritance
AudioTrackAudioTrack
Attributes
Implements

Remarks

Android platform documentation

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

AudioTrack(AudioAttributes, AudioFormat, Int32, AudioTrackMode, Int32) AudioTrack(AudioAttributes, AudioFormat, Int32, AudioTrackMode, Int32)

Class constructor with AudioAttributes and AudioFormat.

AudioTrack(IntPtr, JniHandleOwnership) AudioTrack(IntPtr, JniHandleOwnership)

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

AudioTrack(Stream, Int32, ChannelConfiguration, Encoding, Int32, AudioTrackMode) AudioTrack(Stream, Int32, ChannelConfiguration, Encoding, Int32, AudioTrackMode)

Class constructor.

AudioTrack(Stream, Int32, ChannelConfiguration, Encoding, Int32, AudioTrackMode, Int32) AudioTrack(Stream, Int32, ChannelConfiguration, Encoding, Int32, AudioTrackMode, Int32)

Class constructor with audio session.

AudioTrack(Stream, Int32, ChannelOut, Encoding, Int32, AudioTrackMode) AudioTrack(Stream, Int32, ChannelOut, Encoding, Int32, AudioTrackMode)

Class constructor.

AudioTrack(Stream, Int32, ChannelOut, Encoding, Int32, AudioTrackMode, Int32) AudioTrack(Stream, Int32, ChannelOut, Encoding, Int32, AudioTrackMode, Int32)

Class constructor with audio session.

Fields

Error Error

Denotes a generic operation failure.

ErrorBadValue ErrorBadValue

Denotes a failure due to the use of an invalid value.

ErrorDeadObject ErrorDeadObject
ErrorInvalidOperation ErrorInvalidOperation

Denotes a failure due to the improper use of a method.

Success Success

Denotes a successful operation.

Properties

AudioFormat AudioFormat

Returns the configured audio data encoding.

AudioSessionId AudioSessionId

Returns the audio session ID.

BufferCapacityInFrames BufferCapacityInFrames
BufferSizeInFrames BufferSizeInFrames
ChannelConfiguration ChannelConfiguration

Returns the configured channel position mask.

ChannelCount ChannelCount

Returns the configured number of channels.

Class Class

Returns the unique instance of Class that represents this object's class.

(Inherited from Object)
Format Format
Handle Handle

The handle to the underlying Android instance.

(Inherited from Object)
IJavaObjectEx.IsProxy IJavaObjectEx.IsProxy Inherited from Object
IJavaObjectEx.KeyHandle IJavaObjectEx.KeyHandle Inherited from Object
IJavaObjectEx.NeedsActivation IJavaObjectEx.NeedsActivation Inherited from Object
IJavaPeerable.JniManagedPeerState IJavaPeerable.JniManagedPeerState Inherited from Object
JniIdentityHashCode JniIdentityHashCode Inherited from Object
JniPeerMembers JniPeerMembers
MaxVolume MaxVolume

Returns the maximum gain value, which is greater than or equal to 1.

MinVolume MinVolume

Returns the minimum gain value, which is the constant 0.

NativeFrameCount NativeFrameCount

Returns the frame count of the native AudioTrack buffer.

NotificationMarkerPosition NotificationMarkerPosition

Returns marker position expressed in frames.

PeerReference PeerReference Inherited from Object
PerformanceMode PerformanceMode
PlaybackHeadPosition PlaybackHeadPosition

Returns the playback head position expressed in frames.

PlaybackParams PlaybackParams
PlaybackRate PlaybackRate

Returns the current playback sample rate rate in Hz.

PlayState PlayState

Returns the playback state of the AudioTrack instance.

PositionNotificationPeriod PositionNotificationPeriod

Returns the notification update period expressed in frames.

PreferredDevice PreferredDevice
RoutedDevice RoutedDevice
SampleRate SampleRate

Returns the configured audio data sample rate in Hz

State State

Returns the state of the AudioTrack instance.

StreamType StreamType

Returns the type of audio stream this AudioTrack is configured for.

ThresholdClass ThresholdClass

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

ThresholdType ThresholdType

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

UnderrunCount UnderrunCount

Methods

AddOnRoutingChangedListener(AudioTrack+IOnRoutingChangedListener, Handler) AddOnRoutingChangedListener(AudioTrack+IOnRoutingChangedListener, Handler)
AttachAuxEffect(Int32) AttachAuxEffect(Int32)

Attaches an auxiliary effect to the audio track.

Clone() Clone()

Creates and returns a copy of this Object.

(Inherited from Object)
CreateVolumeShaper(VolumeShaper+Configuration) CreateVolumeShaper(VolumeShaper+Configuration)
Dispose() Dispose() Inherited from Object
Dispose(Boolean) Dispose(Boolean) Inherited from Object
Equals(Object) Equals(Object)

Compares this instance with the specified object and indicates if they are equal.

(Inherited from Object)
Flush() Flush()

Flushes the audio data currently queued for playback.

GetHashCode() GetHashCode()

Returns an integer hash code for this object.

(Inherited from Object)
GetMinBufferSize(Int32, ChannelOut, Encoding) GetMinBufferSize(Int32, ChannelOut, Encoding)

Returns the minimum buffer size required for the successful creation of an AudioTrack object to be created in the Stream mode.

GetNativeOutputSampleRate(Stream) GetNativeOutputSampleRate(Stream)

Returns the output sample rate in Hz for the specified stream type.

GetTimestamp(AudioTimestamp) GetTimestamp(AudioTimestamp)

Poll for a timestamp on demand.

JavaFinalize() JavaFinalize()

Invoked when the garbage collector has detected that this instance is no longer reachable.

(Inherited from Object)
Notify() Notify()

Causes a thread which is waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
NotifyAll() NotifyAll()

Causes all threads which are waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
Pause() Pause()

Pauses the playback of the audio data.

Play() Play()

Starts playing an AudioTrack.

Release() Release()

Releases the native AudioTrack resources.

ReloadStaticData() ReloadStaticData()

Sets the playback head position within the static buffer to zero, that is it rewinds to start of static buffer.

RemoveOnRoutingChangedListener(AudioTrack+IOnRoutingChangedListener) RemoveOnRoutingChangedListener(AudioTrack+IOnRoutingChangedListener)
SetAuxEffectSendLevel(Single) SetAuxEffectSendLevel(Single)

Sets the send level of the audio track to the attached auxiliary effect AttachAuxEffect(Int32).

SetBufferSizeInFrames(Int32) SetBufferSizeInFrames(Int32)
SetHandle(IntPtr, JniHandleOwnership) SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetLoopPoints(Int32, Int32, Int32) SetLoopPoints(Int32, Int32, Int32)

Sets the loop points and the loop count.

SetNotificationMarkerPosition(Int32) SetNotificationMarkerPosition(Int32)

Sets the position of the notification marker.

SetPlaybackHeadPosition(Int32) SetPlaybackHeadPosition(Int32)

Sets the playback head position within the static buffer.

SetPlaybackPositionUpdateListener(AudioTrack+IOnPlaybackPositionUpdateListener) SetPlaybackPositionUpdateListener(AudioTrack+IOnPlaybackPositionUpdateListener)

Sets the listener the AudioTrack notifies when a previously set marker is reached or for each periodic playback head position update.

SetPlaybackPositionUpdateListener(AudioTrack+IOnPlaybackPositionUpdateListener, Handler) SetPlaybackPositionUpdateListener(AudioTrack+IOnPlaybackPositionUpdateListener, Handler)

Sets the listener the AudioTrack notifies when a previously set marker is reached or for each periodic playback head position update.

SetPlaybackRate(Int32) SetPlaybackRate(Int32)

Sets the playback sample rate for this track.

SetPositionNotificationPeriod(Int32) SetPositionNotificationPeriod(Int32)

Sets the period for the periodic notification event.

SetPreferredDevice(AudioDeviceInfo) SetPreferredDevice(AudioDeviceInfo)
SetState(Int32) SetState(Int32)

Sets the initialization state of the instance.

SetStereoVolume(Single, Single) SetStereoVolume(Single, Single)

Sets the specified left and right output gain values on the AudioTrack.

SetVolume(Single) SetVolume(Single)

Sets the specified output gain value on all channels of this track.

Stop() Stop()

Stops playing the audio data.

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

Returns a string containing a concise, human-readable description of this object.

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

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.

(Inherited from Object)
Wait(Int64) Wait(Int64)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)
Wait(Int64, Int32) Wait(Int64, Int32)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)
Write(ByteBuffer, Int32, WriteMode) Write(ByteBuffer, Int32, WriteMode)

Writes the audio data to the audio sink for playback (streaming mode), or copies audio data for later playback (static buffer mode).

Write(ByteBuffer, Int32, WriteMode, Int64) Write(ByteBuffer, Int32, WriteMode, Int64)
Write(Byte[], Int32, Int32) Write(Byte[], Int32, Int32)

Writes the audio data to the audio sink for playback (streaming mode), or copies audio data for later playback (static buffer mode).

Write(Byte[], Int32, Int32, WriteMode) Write(Byte[], Int32, Int32, WriteMode)
Write(Int16[], Int32, Int32) Write(Int16[], Int32, Int32)

Writes the audio data to the audio sink for playback (streaming mode), or copies audio data for later playback (static buffer mode).

Write(Int16[], Int32, Int32, WriteMode) Write(Int16[], Int32, Int32, WriteMode)
Write(Single[], Int32, Int32, WriteMode) Write(Single[], Int32, Int32, WriteMode)

Writes the audio data to the audio sink for playback (streaming mode), or copies audio data for later playback (static buffer mode).

WriteAsync(ByteBuffer, Int32, WriteMode) WriteAsync(ByteBuffer, Int32, WriteMode)
WriteAsync(ByteBuffer, Int32, WriteMode, Int64) WriteAsync(ByteBuffer, Int32, WriteMode, Int64)
WriteAsync(Byte[], Int32, Int32) WriteAsync(Byte[], Int32, Int32)
WriteAsync(Byte[], Int32, Int32, WriteMode) WriteAsync(Byte[], Int32, Int32, WriteMode)
WriteAsync(Int16[], Int32, Int32) WriteAsync(Int16[], Int32, Int32)
WriteAsync(Int16[], Int32, Int32, WriteMode) WriteAsync(Int16[], Int32, Int32, WriteMode)
WriteAsync(Single[], Int32, Int32, WriteMode) WriteAsync(Single[], Int32, Int32, WriteMode)

Events

MarkerReached MarkerReached
PeriodicNotification PeriodicNotification

Explicit Interface Implementations

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

Extension Methods

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable) GetJniTypeName(IJavaPeerable)

Applies to