Android Guides | Samples

Android.Media.AudioRecord Class

The AudioRecord class manages the audio resources for Java applications to record audio from the audio input hardware of the platform.

See Also: AudioRecord

Syntax

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

Remarks

The AudioRecord class manages the audio resources for Java applications to record audio from the audio input hardware of the platform. This is achieved by "pulling" (reading) the data from the AudioRecord object. The application is responsible for polling the AudioRecord object in time using one of the following three methods: AudioRecord.Read(Byte[],Int32,Int32), AudioRecord.Read(Int16[],Int32,Int32) or AudioRecord.Read(ByteBuffer,Int32). The choice of which method to use will be based on the audio data storage format that is the most convenient for the user of AudioRecord.

Upon creation, an AudioRecord object initializes its associated audio buffer that it will fill with the new audio data. The size of this buffer, specified during the construction, determines how long an AudioRecord can record before "over-running" data that has not been read yet. Data should be read from the audio hardware in chunks of sizes inferior to the total recording buffer size.

[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

The members of Android.Media.AudioRecord are listed below.

See Also: Object

Public Constructors

Protected Constructors

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

Public Properties

[read-only]
AudioFormatEncoding. Returns the configured audio data encoding.
[read-only]
AudioSessionIdInt32. Returns the audio session ID.
[read-only]
AudioSourceAudioSource. Returns the audio recording source.
[read-only]
ChannelConfigurationChannelIn. Returns the configured channel position mask.
[read-only]
ChannelCountInt32. Returns the configured number of channels.
[read-only]
NotificationMarkerPositionInt32. Returns the notification marker position expressed in frames.
[read-only]
PositionNotificationPeriodInt32. Returns the notification update period expressed in frames.
[read-only]
RecordingStateRecordState. Returns the recording state of the AudioRecord instance.
[read-only]
SampleRateInt32. Returns the configured audio data sample rate in Hz
[read-only]
StateState. Returns the state of the AudioRecord instance.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

static
GetMinBufferSize(Int32, ChannelIn, Encoding) : Int32
Returns the minimum buffer size required for the successful creation of an AudioRecord object, in byte units.
Read(ByteBuffer, Int32) : Int32
Reads audio data from the audio hardware for recording into a direct buffer.
Read(Byte[], Int32, Int32) : Int32
Reads audio data from the audio hardware for recording into a byte array.
Read(Int16[], Int32, Int32) : Int32
Reads audio data from the audio hardware for recording into a short array.
ReadAsync(ByteBuffer, Int32) : System.Threading.Tasks.Task<int>
ReadAsync(Byte[], Int32, Int32) : System.Threading.Tasks.Task<int>
ReadAsync(Int16[], Int32, Int32) : System.Threading.Tasks.Task<int>
Release()
Releases the native AudioRecord resources.
SetNotificationMarkerPosition(Int32) : RecordStatus
Sets the marker position at which the listener is called, if set with AudioRecord.SetRecordPositionUpdateListener(.IOnRecordPositionUpdateListener) or AudioRecord.SetRecordPositionUpdateListener(.IOnRecordPositionUpdateListener, Android.OS.Handler).
SetPositionNotificationPeriod(Int32) : RecordStatus
Sets the period at which the listener is called, if set with AudioRecord.SetRecordPositionUpdateListener(.IOnRecordPositionUpdateListener) or AudioRecord.SetRecordPositionUpdateListener(.IOnRecordPositionUpdateListener, Android.OS.Handler).
SetRecordPositionUpdateListener(AudioRecord+IOnRecordPositionUpdateListener)
Sets the listener the AudioRecord notifies when a previously set marker is reached or for each periodic record head position update.
SetRecordPositionUpdateListener(AudioRecord+IOnRecordPositionUpdateListener, Handler)
Sets the listener the AudioRecord notifies when a previously set marker is reached or for each periodic record head position update.
StartRecording()
Starts recording from the AudioRecord instance.
StartRecording(MediaSyncEvent)
Starts recording from the AudioRecord instance when the specified synchronization event occurs on the specified audio session.
Stop()
Stops recording.

Public Events