Class Source
An NAudio-based source to capture sound from a microphone.
Inheritance
Implements
Inherited Members
Namespace: FM.LiveSwitch.NAudio
Assembly: FM.LiveSwitch.NAudio.dll
Syntax
public class Source : AudioSource, IAudioOutput, IMediaOutput<IAudioOutput, IAudioInput, AudioFrame, AudioBuffer, AudioBufferCollection, AudioFormat>, IOutput<IAudioOutput, IAudioInput, AudioFrame, AudioBuffer, AudioBufferCollection, AudioFormat>, IAudioElement, IMediaElement, IElement
Constructors
Source(AudioConfig)
Initializes a new instance of the Source class.
Declaration
public Source(AudioConfig config)
Parameters
Type | Name | Description |
---|---|---|
AudioConfig | config | The configuration. |
Fields
WasapiInBuffer
Pre-allocated temporary buffer for raising audio frames.
Declaration
protected DataBuffer WasapiInBuffer
Field Value
Type | Description |
---|---|
DataBuffer |
WasapiOutBuffer
Pre-allocated temporary buffer for raising audio frames.
Declaration
protected DataBuffer WasapiOutBuffer
Field Value
Type | Description |
---|---|
DataBuffer |
Properties
Label
Gets a label that identifies this class.
Declaration
public override string Label { get; }
Property Value
Type | Description |
---|---|
System.String |
Overrides
NameSelector
Gets or sets the audio-name-based selector function.
Declaration
public Function1<string, bool> NameSelector { get; set; }
Property Value
Type | Description |
---|---|
Function1<System.String, System.Boolean> |
Methods
ConvertMultiChannelToStereo(Int32, Byte[], Int32, out Byte[])
NAudio only supports converting mono or stereo data, so if a multi-channel surround source (4, 6, or 8 channels, for example) is received, it must be combined into a stereo stream. If the source is already mono or stereo, then this method returns the same buffer.
Buffer must contain PCM data with a bits per sample of 16.
Declaration
protected static int ConvertMultiChannelToStereo(int channels, byte[] buffer, int length, out byte[] convertedBuffer)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | channels | |
System.Byte[] | buffer | |
System.Int32 | length | |
System.Byte[] | convertedBuffer |
Returns
Type | Description |
---|---|
System.Int32 | Length of the convertedBuffer. |
ConvertToValidBuffer(Int32, Int32, Byte[], Int32, out Byte[], out Int32)
Convert a captured buffer to 16 bit samples, stereo or mono, so it can be processed by NAudio.
Declaration
protected void ConvertToValidBuffer(int bits, int channels, byte[] inBuffer, int inLength, out byte[] buffer, out int length)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | bits | |
System.Int32 | channels | |
System.Byte[] | inBuffer | |
System.Int32 | inLength | |
System.Byte[] | buffer | |
System.Int32 | length |
DoStart()
Starts this instance.
Declaration
protected override Future<object> DoStart()
Returns
Type | Description |
---|---|
Future<System.Object> |
Overrides
DoStop()
Stops this instance.
Declaration
protected override Future<object> DoStop()
Returns
Type | Description |
---|---|
Future<System.Object> |
Overrides
GetBufferDelay(AudioConfig)
Get buffer delay.
Declaration
public static int GetBufferDelay(AudioConfig config)
Parameters
Type | Name | Description |
---|---|---|
AudioConfig | config | The config. |
Returns
Type | Description |
---|---|
System.Int32 |
GetInputs()
Gets the available inputs.
Declaration
public override Future<SourceInput[]> GetInputs()
Returns
Type | Description |
---|---|
Future<SourceInput[]> |