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

See Also: AudioTrack Members

Syntax

[Android.Runtime.Register("android/media/AudioTrack", DoNotGenerateAcw=true)]
public class AudioTrack : Java.Lang.Object

Remarks

The AudioTrack class manages and plays a single audio resource for Java applications. It allows streaming of PCM audio buffers to the audio sink for playback. This is achieved by "pushing" the data to the AudioTrack object using one of the AudioTrack.Write(Byte[], System.Int32, System.Int32), AudioTrack.Write(Int16[], System.Int32, System.Int32), and AudioTrack.Write(Single[], System.Int32, System.Int32, System.Int32) methods.

An AudioTrack instance can operate under two modes: static or streaming.

In Streaming mode, the application writes a continuous stream of data to the AudioTrack, using one of the write() methods. These are blocking and return when the data has been transferred from the Java layer to the native layer and queued for playback. The streaming mode is most useful when playing blocks of audio data that for instance are:

The static mode should be chosen when dealing with short sounds that fit in memory and that need to be played with the smallest latency possible. The static mode will therefore be preferred for UI and game sounds that are played often, and with the smallest overhead possible.

Upon creation, an AudioTrack object initializes its associated audio buffer. The size of this buffer, specified during the construction, determines how long an AudioTrack can play before running out of data.

For an AudioTrack using the static mode, this size is the maximum size of the sound that can be played from it.

For the streaming mode, data will be written to the audio sink in chunks of sizes less than or equal to the total buffer size. AudioTrack is not final and thus permits subclasses, but such use is not recommended.

[Android Documentation]

Requirements

Namespace: Android.Media
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 3