Share via


AudioRecord Constructors

Definition

Overloads

AudioRecord(IntPtr, JniHandleOwnership)

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

AudioRecord(AudioSource, Int32, ChannelIn, Encoding, Int32)

Class constructor.

AudioRecord(IntPtr, JniHandleOwnership)

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

protected AudioRecord (IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer);
new Android.Media.AudioRecord : nativeint * Android.Runtime.JniHandleOwnership -> Android.Media.AudioRecord

Parameters

javaReference
IntPtr

nativeint

A IntPtrcontaining a Java Native Interface (JNI) object reference.

transfer
JniHandleOwnership

A JniHandleOwnershipindicating how to handle javaReference

Remarks

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.

Applies to

AudioRecord(AudioSource, Int32, ChannelIn, Encoding, Int32)

Class constructor.

[Android.Runtime.Register(".ctor", "(IIIII)V", "")]
[Android.Runtime.RequiresPermission("android.permission.RECORD_AUDIO")]
public AudioRecord (Android.Media.AudioSource audioSource, int sampleRateInHz, Android.Media.ChannelIn channelConfig, Android.Media.Encoding audioFormat, int bufferSizeInBytes);
[<Android.Runtime.Register(".ctor", "(IIIII)V", "")>]
[<Android.Runtime.RequiresPermission("android.permission.RECORD_AUDIO")>]
new Android.Media.AudioRecord : Android.Media.AudioSource * int * Android.Media.ChannelIn * Android.Media.Encoding * int -> Android.Media.AudioRecord

Parameters

audioSource
AudioSource

the recording source. See MediaRecorder.AudioSource for the recording source definitions.

sampleRateInHz
Int32

the sample rate expressed in Hertz. 44100Hz is currently the only rate that is guaranteed to work on all devices, but other rates such as 22050, 16000, and 11025 may work on some devices. AudioFormat#SAMPLE_RATE_UNSPECIFIED means to use a route-dependent value which is usually the sample rate of the source. #getSampleRate() can be used to retrieve the actual sample rate chosen.

channelConfig
ChannelIn

describes the configuration of the audio channels. See AudioFormat#CHANNEL_IN_MONO and AudioFormat#CHANNEL_IN_STEREO. AudioFormat#CHANNEL_IN_MONO is guaranteed to work on all devices.

audioFormat
Encoding

the format in which the audio data is to be returned. See AudioFormat#ENCODING_PCM_8BIT, AudioFormat#ENCODING_PCM_16BIT, and AudioFormat#ENCODING_PCM_FLOAT.

bufferSizeInBytes
Int32

the total size (in bytes) of the buffer where audio data is written to during the recording. New audio data can be read from this buffer in smaller chunks than this size. See #getMinBufferSize(int, int, int) to determine the minimum required buffer size for the successful creation of an AudioRecord instance. Using values smaller than getMinBufferSize() will result in an initialization failure.

Attributes

Exceptions

Remarks

Class constructor. Though some invalid parameters will result in an IllegalArgumentException exception, other errors do not. Thus you should call #getState() immediately after construction to confirm that the object is usable.

Java documentation for android.media.AudioRecord.AudioRecord(int, int, int, int, int).

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.

Applies to