Aracılığıyla paylaş


AudioRecord.Read Method

Definition

Overloads

Read(Single[], Int32, Int32, Int32)

Reads audio data from the audio hardware for recording into a float array.

Read(Byte[], Int32, Int32, Int32)

Reads audio data from the audio hardware for recording into a byte array.

Read(Int16[], Int32, Int32)

Reads audio data from the audio hardware for recording into a short array.

Read(Int16[], Int32, Int32, Int32)

Reads audio data from the audio hardware for recording into a short array.

Read(ByteBuffer, Int32, Int32)

Reads audio data from the audio hardware for recording into a direct buffer.

Read(Byte[], Int32, Int32)

Reads audio data from the audio hardware for recording into a byte array.

Read(ByteBuffer, Int32)

Reads audio data from the audio hardware for recording into a direct buffer.

Read(Single[], Int32, Int32, Int32)

Reads audio data from the audio hardware for recording into a float array.

[Android.Runtime.Register("read", "([FIII)I", "GetRead_arrayFIIIHandler", ApiSince=23)]
public virtual int Read (float[] audioData, int offsetInFloats, int sizeInFloats, int readMode);
[<Android.Runtime.Register("read", "([FIII)I", "GetRead_arrayFIIIHandler", ApiSince=23)>]
abstract member Read : single[] * int * int * int -> int
override this.Read : single[] * int * int * int -> int

Parameters

audioData
Single[]

the array to which the recorded audio data is written.

offsetInFloats
Int32

index in audioData from which the data is written. Must not be negative, or cause the data access to go out of bounds of the array.

sizeInFloats
Int32

the number of requested floats. Must not be negative, or cause the data access to go out of bounds of the array.

readMode
Int32

one of #READ_BLOCKING, #READ_NON_BLOCKING. <br>With #READ_BLOCKING, the read will block until all the requested data is read. <br>With #READ_NON_BLOCKING, the read will return immediately after reading as much audio data as possible without blocking.

Returns

zero or the positive number of floats that were read, or one of the following error codes. The number of floats will be a multiple of the channel count not to exceed sizeInFloats. <ul> <li>#ERROR_INVALID_OPERATION if the object isn't properly initialized</li> <li>#ERROR_BAD_VALUE if the parameters don't resolve to valid data and indexes</li> <li>#ERROR_DEAD_OBJECT if the object is not valid anymore and needs to be recreated. The dead object error code is not returned if some data was successfully transferred. In this case, the error is returned at the next read()</li> <li>#ERROR in case of other error</li> </ul>

Attributes

Remarks

Reads audio data from the audio hardware for recording into a float array. The format specified in the AudioRecord constructor should be AudioFormat#ENCODING_PCM_FLOAT to correspond to the data in the array.

Java documentation for android.media.AudioRecord.read(float[], 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

Read(Byte[], Int32, Int32, Int32)

Reads audio data from the audio hardware for recording into a byte array.

[Android.Runtime.Register("read", "([BIII)I", "GetRead_arrayBIIIHandler", ApiSince=23)]
public virtual int Read (byte[] audioData, int offsetInBytes, int sizeInBytes, int readMode);
[<Android.Runtime.Register("read", "([BIII)I", "GetRead_arrayBIIIHandler", ApiSince=23)>]
abstract member Read : byte[] * int * int * int -> int
override this.Read : byte[] * int * int * int -> int

Parameters

audioData
Byte[]

the array to which the recorded audio data is written.

offsetInBytes
Int32

index in audioData to which the data is written expressed in bytes. Must not be negative, or cause the data access to go out of bounds of the array.

sizeInBytes
Int32

the number of requested bytes. Must not be negative, or cause the data access to go out of bounds of the array.

readMode
Int32

one of #READ_BLOCKING, #READ_NON_BLOCKING. <br>With #READ_BLOCKING, the read will block until all the requested data is read. <br>With #READ_NON_BLOCKING, the read will return immediately after reading as much audio data as possible without blocking.

Returns

zero or the positive number of bytes that were read, or one of the following error codes. The number of bytes will be a multiple of the frame size in bytes not to exceed sizeInBytes. <ul> <li>#ERROR_INVALID_OPERATION if the object isn't properly initialized</li> <li>#ERROR_BAD_VALUE if the parameters don't resolve to valid data and indexes</li> <li>#ERROR_DEAD_OBJECT if the object is not valid anymore and needs to be recreated. The dead object error code is not returned if some data was successfully transferred. In this case, the error is returned at the next read()</li> <li>#ERROR in case of other error</li> </ul>

Attributes

Remarks

Reads audio data from the audio hardware for recording into a byte array. The format specified in the AudioRecord constructor should be AudioFormat#ENCODING_PCM_8BIT to correspond to the data in the array. The format can be AudioFormat#ENCODING_PCM_16BIT, but this is deprecated.

Java documentation for android.media.AudioRecord.read(byte[], 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

Read(Int16[], Int32, Int32)

Reads audio data from the audio hardware for recording into a short array.

[Android.Runtime.Register("read", "([SII)I", "GetRead_arraySIIHandler")]
public virtual int Read (short[] audioData, int offsetInShorts, int sizeInShorts);
[<Android.Runtime.Register("read", "([SII)I", "GetRead_arraySIIHandler")>]
abstract member Read : int16[] * int * int -> int
override this.Read : int16[] * int * int -> int

Parameters

audioData
Int16[]

the array to which the recorded audio data is written.

offsetInShorts
Int32

index in audioData to which the data is written expressed in shorts. Must not be negative, or cause the data access to go out of bounds of the array.

sizeInShorts
Int32

the number of requested shorts. Must not be negative, or cause the data access to go out of bounds of the array.

Returns

zero or the positive number of shorts that were read, or one of the following error codes. The number of shorts will be a multiple of the channel count not to exceed sizeInShorts. <ul> <li>#ERROR_INVALID_OPERATION if the object isn't properly initialized</li> <li>#ERROR_BAD_VALUE if the parameters don't resolve to valid data and indexes</li> <li>#ERROR_DEAD_OBJECT if the object is not valid anymore and needs to be recreated. The dead object error code is not returned if some data was successfully transferred. In this case, the error is returned at the next read()</li> <li>#ERROR in case of other error</li> </ul>

Attributes

Remarks

Reads audio data from the audio hardware for recording into a short array. The format specified in the AudioRecord constructor should be AudioFormat#ENCODING_PCM_16BIT to correspond to the data in the array.

Java documentation for android.media.AudioRecord.read(short[], 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

Read(Int16[], Int32, Int32, Int32)

Reads audio data from the audio hardware for recording into a short array.

[Android.Runtime.Register("read", "([SIII)I", "GetRead_arraySIIIHandler", ApiSince=23)]
public virtual int Read (short[] audioData, int offsetInShorts, int sizeInShorts, int readMode);
[<Android.Runtime.Register("read", "([SIII)I", "GetRead_arraySIIIHandler", ApiSince=23)>]
abstract member Read : int16[] * int * int * int -> int
override this.Read : int16[] * int * int * int -> int

Parameters

audioData
Int16[]

the array to which the recorded audio data is written.

offsetInShorts
Int32

index in audioData from which the data is written expressed in shorts. Must not be negative, or cause the data access to go out of bounds of the array.

sizeInShorts
Int32

the number of requested shorts. Must not be negative, or cause the data access to go out of bounds of the array.

readMode
Int32

one of #READ_BLOCKING, #READ_NON_BLOCKING. <br>With #READ_BLOCKING, the read will block until all the requested data is read. <br>With #READ_NON_BLOCKING, the read will return immediately after reading as much audio data as possible without blocking.

Returns

zero or the positive number of shorts that were read, or one of the following error codes. The number of shorts will be a multiple of the channel count not to exceed sizeInShorts. <ul> <li>#ERROR_INVALID_OPERATION if the object isn't properly initialized</li> <li>#ERROR_BAD_VALUE if the parameters don't resolve to valid data and indexes</li> <li>#ERROR_DEAD_OBJECT if the object is not valid anymore and needs to be recreated. The dead object error code is not returned if some data was successfully transferred. In this case, the error is returned at the next read()</li> <li>#ERROR in case of other error</li> </ul>

Attributes

Remarks

Reads audio data from the audio hardware for recording into a short array. The format specified in the AudioRecord constructor should be AudioFormat#ENCODING_PCM_16BIT to correspond to the data in the array.

Java documentation for android.media.AudioRecord.read(short[], 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

Read(ByteBuffer, Int32, Int32)

Reads audio data from the audio hardware for recording into a direct buffer.

[Android.Runtime.Register("read", "(Ljava/nio/ByteBuffer;II)I", "GetRead_Ljava_nio_ByteBuffer_IIHandler", ApiSince=23)]
public virtual int Read (Java.Nio.ByteBuffer audioBuffer, int sizeInBytes, int readMode);
[<Android.Runtime.Register("read", "(Ljava/nio/ByteBuffer;II)I", "GetRead_Ljava_nio_ByteBuffer_IIHandler", ApiSince=23)>]
abstract member Read : Java.Nio.ByteBuffer * int * int -> int
override this.Read : Java.Nio.ByteBuffer * int * int -> int

Parameters

audioBuffer
ByteBuffer

the direct buffer to which the recorded audio data is written. Data is written to audioBuffer.position().

sizeInBytes
Int32

the number of requested bytes. It is recommended but not enforced that the number of bytes requested be a multiple of the frame size (sample size in bytes multiplied by the channel count).

readMode
Int32

one of #READ_BLOCKING, #READ_NON_BLOCKING. <br>With #READ_BLOCKING, the read will block until all the requested data is read. <br>With #READ_NON_BLOCKING, the read will return immediately after reading as much audio data as possible without blocking.

Returns

zero or the positive number of bytes that were read, or one of the following error codes. The number of bytes will not exceed sizeInBytes and will be truncated to be a multiple of the frame size. <ul> <li>#ERROR_INVALID_OPERATION if the object isn't properly initialized</li> <li>#ERROR_BAD_VALUE if the parameters don't resolve to valid data and indexes</li> <li>#ERROR_DEAD_OBJECT if the object is not valid anymore and needs to be recreated. The dead object error code is not returned if some data was successfully transferred. In this case, the error is returned at the next read()</li> <li>#ERROR in case of other error</li> </ul>

Attributes

Remarks

Reads audio data from the audio hardware for recording into a direct buffer. If this buffer is not a direct buffer, this method will always return 0. Note that the value returned by java.nio.Buffer#position() on this buffer is unchanged after a call to this method. The representation of the data in the buffer will depend on the format specified in the AudioRecord constructor, and will be native endian.

Java documentation for android.media.AudioRecord.read(java.nio.ByteBuffer, 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

Read(Byte[], Int32, Int32)

Reads audio data from the audio hardware for recording into a byte array.

[Android.Runtime.Register("read", "([BII)I", "GetRead_arrayBIIHandler")]
public virtual int Read (byte[] audioData, int offsetInBytes, int sizeInBytes);
[<Android.Runtime.Register("read", "([BII)I", "GetRead_arrayBIIHandler")>]
abstract member Read : byte[] * int * int -> int
override this.Read : byte[] * int * int -> int

Parameters

audioData
Byte[]

the array to which the recorded audio data is written.

offsetInBytes
Int32

index in audioData from which the data is written expressed in bytes.

sizeInBytes
Int32

the number of requested bytes.

Returns

zero or the positive number of bytes that were read, or one of the following error codes. The number of bytes will not exceed sizeInBytes. <ul> <li>#ERROR_INVALID_OPERATION if the object isn't properly initialized</li> <li>#ERROR_BAD_VALUE if the parameters don't resolve to valid data and indexes</li> <li>#ERROR_DEAD_OBJECT if the object is not valid anymore and needs to be recreated. The dead object error code is not returned if some data was successfully transferred. In this case, the error is returned at the next read()</li> <li>#ERROR in case of other error</li> </ul>

Attributes

Remarks

Reads audio data from the audio hardware for recording into a byte array. The format specified in the AudioRecord constructor should be AudioFormat#ENCODING_PCM_8BIT to correspond to the data in the array.

Java documentation for android.media.AudioRecord.read(byte[], 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

Read(ByteBuffer, Int32)

Reads audio data from the audio hardware for recording into a direct buffer.

[Android.Runtime.Register("read", "(Ljava/nio/ByteBuffer;I)I", "GetRead_Ljava_nio_ByteBuffer_IHandler")]
public virtual int Read (Java.Nio.ByteBuffer audioBuffer, int sizeInBytes);
[<Android.Runtime.Register("read", "(Ljava/nio/ByteBuffer;I)I", "GetRead_Ljava_nio_ByteBuffer_IHandler")>]
abstract member Read : Java.Nio.ByteBuffer * int -> int
override this.Read : Java.Nio.ByteBuffer * int -> int

Parameters

audioBuffer
ByteBuffer

the direct buffer to which the recorded audio data is written. Data is written to audioBuffer.position().

sizeInBytes
Int32

the number of requested bytes. It is recommended but not enforced that the number of bytes requested be a multiple of the frame size (sample size in bytes multiplied by the channel count).

Returns

zero or the positive number of bytes that were read, or one of the following error codes. The number of bytes will not exceed sizeInBytes and will be truncated to be a multiple of the frame size. <ul> <li>#ERROR_INVALID_OPERATION if the object isn't properly initialized</li> <li>#ERROR_BAD_VALUE if the parameters don't resolve to valid data and indexes</li> <li>#ERROR_DEAD_OBJECT if the object is not valid anymore and needs to be recreated. The dead object error code is not returned if some data was successfully transferred. In this case, the error is returned at the next read()</li> <li>#ERROR in case of other error</li> </ul>

Attributes

Remarks

Reads audio data from the audio hardware for recording into a direct buffer. If this buffer is not a direct buffer, this method will always return 0. Note that the value returned by java.nio.Buffer#position() on this buffer is unchanged after a call to this method. The representation of the data in the buffer will depend on the format specified in the AudioRecord constructor, and will be native endian.

Java documentation for android.media.AudioRecord.read(java.nio.ByteBuffer, 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