Condividi tramite


AudioRecord Class

Definition

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

[Android.Runtime.Register("android/media/AudioRecord", DoNotGenerateAcw=true)]
public class AudioRecord : Java.Lang.Object, Android.Media.IAudioRecordingMonitor, Android.Media.IAudioRouting, Android.Media.IMicrophoneDirection, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/media/AudioRecord", DoNotGenerateAcw=true)>]
type AudioRecord = class
    inherit Object
    interface IAudioRecordingMonitor
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
    interface IAudioRouting
    interface IMicrophoneDirection
Inheritance
AudioRecord
Attributes
Implements

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: #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 android.media.AudioRecord.Builder#build build(), and the constructor will return an instance in state #STATE_UNINITIALIZED.

Java documentation for android.media.AudioRecord.

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.

Constructors

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.

Properties

ActiveMicrophones

Returns a lists of MicrophoneInfo representing the active microphones.

ActiveRecordingConfiguration

Returns the current active audio recording for this audio recorder.

AudioFormat

Returns the configured audio data encoding.

AudioSessionId

Returns the audio session ID.

AudioSource

Returns the audio recording source.

BufferSizeInFrames

Returns the frame count of the native AudioRecord buffer.

ChannelConfiguration

Returns the configured channel position mask.

ChannelCount

Returns the configured number of channels.

Class

Returns the runtime class of this Object.

(Inherited from Object)
Format

Returns the configured AudioRecord format.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsPrivacySensitive

Returns whether this AudioRecord is marked as privacy sensitive or not.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
LogSessionId

Returns the LogSessionId. -or- Sets a LogSessionId instance to this AudioRecord for metrics collection.

Metrics

Return Metrics data about the current AudioTrack instance.

NotificationMarkerPosition

Returns the notification marker position expressed in frames.

PeerReference (Inherited from Object)
PositionNotificationPeriod

Returns the notification update period expressed in frames.

PreferredDevice

Returns the selected input specified by #setPreferredDevice.

RecordingState

Returns the recording state of the AudioRecord instance.

RoutedDevice

Returns an AudioDeviceInfo identifying the current routing of this AudioRecord.

SampleRate

Returns the configured audio sink sample rate in Hz.

State

Returns the state of the AudioRecord instance.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

AddOnRoutingChangedListener(AudioRecord+IOnRoutingChangedListener, Handler)

Adds an AudioRouting.OnRoutingChangedListener to receive notifications of routing changes on this AudioRecord.

AddOnRoutingChangedListener(IAudioRoutingOnRoutingChangedListener, Handler)

Adds an AudioRouting.OnRoutingChangedListener to receive notifications of routing changes on this AudioRecord.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetMinBufferSize(Int32, ChannelIn, Encoding)

Returns the minimum buffer size required for the successful creation of an AudioRecord object, in byte units.

GetTimestamp(AudioTimestamp, AudioTimebase)

Poll for an AudioTimestamp on demand.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
Read(Byte[], Int32, Int32, Int32)

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

Read(Byte[], Int32, Int32)

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

Read(ByteBuffer, Int32, Int32)

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

Read(ByteBuffer, Int32)

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

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

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

Read(Int16[], Int32, Int32)

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

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

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

ReadAsync(Byte[], Int32, Int32, Int32)
ReadAsync(Byte[], Int32, Int32)
ReadAsync(ByteBuffer, Int32, Int32)
ReadAsync(ByteBuffer, Int32)
ReadAsync(Int16[], Int32, Int32, Int32)
ReadAsync(Int16[], Int32, Int32)
ReadAsync(Single[], Int32, Int32, Int32)
RegisterAudioRecordingCallback(IExecutor, AudioManager+AudioRecordingCallback)

Register a callback to be notified of audio capture changes via a AudioManager.AudioRecordingCallback.

Release()

Releases the native AudioRecord resources.

RemoveOnRoutingChangedListener(AudioRecord+IOnRoutingChangedListener)

Removes an AudioRouting.OnRoutingChangedListener which has been previously added to receive rerouting notifications.

RemoveOnRoutingChangedListener(IAudioRoutingOnRoutingChangedListener)

Removes an AudioRouting.OnRoutingChangedListener which has been previously added to receive rerouting notifications.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetNotificationMarkerPosition(Int32)

Sets the marker position at which the listener is called, if set with #setRecordPositionUpdateListener(OnRecordPositionUpdateListener) or #setRecordPositionUpdateListener(OnRecordPositionUpdateListener, Handler).

SetPositionNotificationPeriod(Int32)

Sets the period at which the listener is called, if set with #setRecordPositionUpdateListener(OnRecordPositionUpdateListener) or #setRecordPositionUpdateListener(OnRecordPositionUpdateListener, Handler).

SetPreferredDevice(AudioDeviceInfo)

Specifies an audio device (via an AudioDeviceInfo object) to route the input to this AudioRecord.

SetPreferredMicrophoneDirection(MicDirection)

Specifies the logical microphone (for processing).

SetPreferredMicrophoneFieldDimension(Single)

Specifies the zoom factor (i.

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.

SetRecordPositionUpdateListener(AudioRecord+IOnRecordPositionUpdateListener)

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.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterAudioRecordingCallback(AudioManager+AudioRecordingCallback)

Unregister an audio recording callback previously registered with #registerAudioRecordingCallback(Executor, AudioManager.AudioRecordingCallback).

UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Events

MarkerReached
PeriodicNotification
RoutingChanged

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to