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 |
---|---|---|
Audio |
config | The configuration. |
Fields
WasapiInBuffer
Pre-allocated temporary buffer for raising audio frames.
Declaration
protected DataBuffer WasapiInBuffer
Field Value
Type | Description |
---|---|
Data |
WasapiOutBuffer
Pre-allocated temporary buffer for raising audio frames.
Declaration
protected DataBuffer WasapiOutBuffer
Field Value
Type | Description |
---|---|
Data |
Properties
Label
Gets a label that identifies this class.
Declaration
public override string Label { get; }
Property Value
Type | Description |
---|---|
System. |
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. |
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. |
channels | |
System. |
buffer | |
System. |
length | |
System. |
convertedBuffer |
Returns
Type | Description |
---|---|
System. |
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. |
bits | |
System. |
channels | |
System. |
inBuffer | |
System. |
inLength | |
System. |
buffer | |
System. |
length |
DoStart()
Starts this instance.
Declaration
protected override Future<object> DoStart()
Returns
Type | Description |
---|---|
Future<System. |
Overrides
DoStop()
Stops this instance.
Declaration
protected override Future<object> DoStop()
Returns
Type | Description |
---|---|
Future<System. |
Overrides
GetBufferDelay(AudioConfig)
Get buffer delay.
Declaration
public static int GetBufferDelay(AudioConfig config)
Parameters
Type | Name | Description |
---|---|---|
Audio |
config | The config. |
Returns
Type | Description |
---|---|
System. |
GetInputs()
Gets the available inputs.
Declaration
public override Future<SourceInput[]> GetInputs()
Returns
Type | Description |
---|---|
Future<Source |