Class Microphone
Provides microphones capture features.
public sealed class Microphone
- Inheritance
-
Microphone
- Inherited Members
Fields
Name
Returns the friendly name of the microphone.
public readonly string Name
Field Value
Properties
All
Returns all compatible microphones.
public static ReadOnlyCollection<Microphone> All { get; }
Property Value
BufferDuration
Gets or sets the capture buffer duration. This value must be greater than 100 milliseconds, lower than 1000 milliseconds, and must be 10 milliseconds aligned (BufferDuration % 10 == 10).
public TimeSpan BufferDuration { get; set; }
Property Value
Default
Returns the default microphone.
public static Microphone Default { get; }
Property Value
IsHeadset
Determines if the microphone is a wired headset. Note: XNA could know if a headset microphone was plugged in an Xbox 360 controller but MonoGame can't. Hence, this is always true on mobile platforms, and always false otherwise.
public bool IsHeadset { get; }
Property Value
SampleRate
Returns the sample rate of the captured audio. Note: default value is 44100hz
public int SampleRate { get; }
Property Value
State
Returns the state of the Microphone.
public MicrophoneState State { get; }
Property Value
Methods
GetData(byte[])
Gets the latest available data from the microphone.
public int GetData(byte[] buffer)
Parameters
buffer
byte[]Buffer, in bytes, of the captured data (16-bit PCM).
Returns
- int
The buffer size, in bytes, of the captured data.
GetData(byte[], int, int)
Gets the latest available data from the microphone.
public int GetData(byte[] buffer, int offset, int count)
Parameters
buffer
byte[]Buffer, in bytes, of the captured data (16-bit PCM).
offset
intByte offset.
count
intAmount, in bytes.
Returns
- int
The buffer size, in bytes, of the captured data.
GetSampleDuration(int)
Returns the duration based on the size of the buffer (assuming 16-bit PCM data).
public TimeSpan GetSampleDuration(int sizeInBytes)
Parameters
sizeInBytes
intSize, in bytes
Returns
- TimeSpan
TimeSpan of the duration.
GetSampleSizeInBytes(TimeSpan)
Returns the size, in bytes, of the array required to hold the specified duration of 16-bit PCM data.
public int GetSampleSizeInBytes(TimeSpan duration)
Parameters
duration
TimeSpanTimeSpan of the duration of the sample.
Returns
- int
Size, in bytes, of the buffer.
Start()
Starts microphone capture.
public void Start()
Stop()
Stops microphone capture.
public void Stop()
Events
BufferReady
Event fired when the audio data are available.
public event EventHandler<EventArgs> BufferReady