AudioRecord
open class AudioRecord : AudioRecordingMonitor, AudioRouting, MicrophoneDirection
| kotlin.Any | |
| ↳ | android.media.AudioRecord |
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: read(byte[],int,int), read(short[],int,int) or read(ByteBuffer,int). 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.
Applications creating an AudioRecord instance need android.Manifest.permission#RECORD_AUDIO or the Builder will throw java.lang.UnsupportedOperationException on build(), and the constructor will return an instance in state STATE_UNINITIALIZED.
Summary
| Nested classes | |
|---|---|
| open |
Builder class for |
| abstract |
Interface definition for a callback to be invoked when an AudioRecord has reached a notification marker set by |
| abstract |
Defines the interface by which applications can receive notifications of routing changes for the associated |
| Constants | |
|---|---|
| static Int |
Denotes a generic operation failure. |
| static Int |
Denotes a failure due to the use of an invalid value. |
| static Int |
An error code indicating that the object reporting it is no longer valid and needs to be recreated. |
| static Int |
Denotes a failure due to the improper use of a method. |
| static Int |
The read mode indicating the read operation will block until all data requested has been read. |
| static Int |
The read mode indicating the read operation will return immediately after reading as much audio data as possible without blocking. |
| static Int |
indicates AudioRecord recording state is recording |
| static Int |
indicates AudioRecord recording state is not recording |
| static Int |
indicates AudioRecord state is ready to be used |
| static Int |
indicates AudioRecord state is not successfully initialized. |
| static Int |
Denotes a successful operation. |
| Inherited constants | |
|---|---|
| Public constructors | |
|---|---|
AudioRecord(audioSource: Int, sampleRateInHz: Int, channelConfig: Int, audioFormat: Int, bufferSizeInBytes: Int)Class constructor. |
|
| Public methods | |
|---|---|
| open Unit |
addOnRoutingChangedListener(listener: AudioRecord.OnRoutingChangedListener!, handler: Handler!)Adds an |
| open Unit |
addOnRoutingChangedListener(listener: AudioRouting.OnRoutingChangedListener!, handler: Handler!)Adds an |
| open MutableList<MicrophoneInfo!>! |
Returns a lists of |
| open AudioRecordingConfiguration? |
Returns the current active audio recording for this audio recorder. |
| open Int |
Returns the configured audio data encoding. |
| open Int |
Returns the audio session ID. |
| open Int |
Returns the audio recording source. |
| open Int |
Returns the frame count of the native |
| open Int |
Returns the configured channel position mask. |
| open Int |
Returns the configured number of channels. |
| open AudioFormat |
Returns the configured |
| open LogSessionId |
Returns the |
| open PersistableBundle! |
Return Metrics data about the current AudioTrack instance. |
| open static Int |
getMinBufferSize(sampleRateInHz: Int, channelConfig: Int, audioFormat: Int)Returns the minimum buffer size required for the successful creation of an AudioRecord object, in byte units. |
| open Int |
Returns the notification marker position expressed in frames. |
| open Int |
Returns the notification update period expressed in frames. |
| open AudioDeviceInfo! |
Returns the selected input specified by |
| open Int |
Returns the recording state of the AudioRecord instance. |
| open AudioDeviceInfo! |
Returns an |
| open MutableList<AudioDeviceInfo!> |
Returns a List of |
| open Int |
Returns the configured audio sink sample rate in Hz. |
| open Int |
getState()Returns the state of the AudioRecord instance. |
| open Int |
getTimestamp(outTimestamp: AudioTimestamp, timebase: Int)Poll for an |
| open Boolean |
Returns whether this AudioRecord is marked as privacy sensitive or not. |
| open Int |
Reads audio data from the audio hardware for recording into a byte array. |
| open Int |
Reads audio data from the audio hardware for recording into a byte array. |
| open Int |
read(audioData: FloatArray, offsetInFloats: Int, sizeInFloats: Int, readMode: Int)Reads audio data from the audio hardware for recording into a float array. |
| open Int |
read(audioBuffer: ByteBuffer, sizeInBytes: Int)Reads audio data from the audio hardware for recording into a direct buffer. |
| open Int |
read(audioBuffer: ByteBuffer, sizeInBytes: Int, readMode: Int)Reads audio data from the audio hardware for recording into a direct buffer. |
| open Int |
read(audioData: ShortArray, offsetInShorts: Int, sizeInShorts: Int)Reads audio data from the audio hardware for recording into a short array. |
| open Int |
read(audioData: ShortArray, offsetInShorts: Int, sizeInShorts: Int, readMode: Int)Reads audio data from the audio hardware for recording into a short array. |
| open Unit |
Register a callback to be notified of audio capture changes via a |
| open Unit |
release()Releases the native AudioRecord resources. |
| open Unit |
Removes an |
| open Unit |
Removes an |
| open Unit |
setLogSessionId(logSessionId: LogSessionId)Sets a |
| open Int |
setNotificationMarkerPosition(markerInFrames: Int)Sets the marker position at which the listener is called, if set with |
| open Int |
setPositionNotificationPeriod(periodInFrames: Int)Sets the period at which the listener is called, if set with |
| open Boolean |
setPreferredDevice(deviceInfo: AudioDeviceInfo!)Specifies an audio device (via an |
| open Boolean | |