Class Mic.Device
Provides information and APIs for a single recording device.
Inheritance
Inherited Members
Namespace: Adrenak.UniMic
Assembly: cs.temp.dll.dll
Syntax
public class Device
Fields
DEFAULT_FRAME_DURATION_MS
The default duration of the frames in milliseconds
Declaration
public const int DEFAULT_FRAME_DURATION_MS = 20
Field Value
Type | Description |
---|---|
System.Int32 |
DEFAULT_SAMPLING_FREQUENCY
The default sampling frequency when in uncapped devices that support any frequency.
Declaration
public const int DEFAULT_SAMPLING_FREQUENCY = 48000
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
ChannelCount
The number of channels the audio is captured into. Note that this value is made available ONLY after recording starts and resets to 0 when it stops. Also note that depending on the device, channel count can be changed while the recording is ongoing use OnFrameCollected to react to such changes.
Declaration
public int ChannelCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
FrameDurationMS
The duration of the audio frame (in milliseconds) that would be reported by the device. Note that, for example, setting this value to 50 does not mean you would predictably receive 20 frames representing 50ms of audio at fixed and regular intervals. Often times, sent multiple may be sent multiple times in a single game frame or with varying intervals between the frames. For playback, consider creating a buffer. See MicAudioSource for references.
Declaration
public int FrameDurationMS { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
FrameLength
The length of a single PCM frame array that will be sent via OnFrameCollected
Declaration
public int FrameLength { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
IsRecording
Whether this device is currently recording audio
Declaration
public bool IsRecording { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
MaxFrequency
The maximum sampling frequency this device supports
Declaration
public int MaxFrequency { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
MinFrequency
The minimum sampling frequency this device supports
Declaration
public int MinFrequency { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Name
The name of the recording device
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
System.String |
SamplingFrequency
The sampling frequency this device is recording at
Declaration
public int SamplingFrequency { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
SupportsAnyFrequency
If this device is capable of supporting any sampling frequency
Declaration
public bool SupportsAnyFrequency { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
VolumeMultiplier
Multiplies the incoming PCM samples by the given value to increase/decrease the volume. Default: 1
Declaration
public float VolumeMultiplier { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
Methods
StartRecording(Int32)
Start recording audio using this device. If the device is capped (has a min and max frequency) it starts at the maximum frequency supported. If the device isn't capped (supports any frequency) it starts at 48KHz. The frameDuration is DEFAULT_FRAME_DURATION_MS unless specified.
Declaration
public void StartRecording(int frameDurationMS = 20)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | frameDurationMS | The audio length of one frame (in MS) |
StartRecording(Int32, Int32)
Start recording audio using this device at the provided sampling frequency and frame duration
Declaration
public void StartRecording(int samplingFrequency, int frameDurationMS = 20)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | samplingFrequency | |
System.Int32 | frameDurationMS |
StopRecording()
Stop recording audio
Declaration
public void StopRecording()
Events
OnFrameCollected
Invoked everytime an audio sample is collected. Params: (sampling frequency, channel count, PCM samples) You use the channel count provided to be able to react to it changing
Declaration
public event Action<int, int, float[]> OnFrameCollected
Event Type
Type | Description |
---|---|
System.Action<System.Int32, System.Int32, System.Single[]> |
OnStartRecording
Invoked when the instance starts Recording.
Declaration
public event Action OnStartRecording
Event Type
Type | Description |
---|---|
System.Action |
OnStopRecording
Invoked when the instance stop Recording.
Declaration
public event Action OnStopRecording
Event Type
Type | Description |
---|---|
System.Action |