Class AudioBuffer
An audio buffer.
Inheritance
Inherited Members
Namespace: FM.LiveSwitch
Assembly: FM.LiveSwitch.dll
Syntax
public class AudioBuffer : MediaBuffer<AudioFormat, AudioBuffer>
Constructors
AudioBuffer()
Initializes a new instance of the AudioBuffer class.
Declaration
protected AudioBuffer()
AudioBuffer(DataBuffer, AudioFormat)
Initializes a new instance of the AudioBuffer class.
Declaration
public AudioBuffer(DataBuffer dataBuffer, AudioFormat format)
Parameters
Type | Name | Description |
---|---|---|
DataBuffer | dataBuffer | The data buffer. |
AudioFormat | format | The format. |
AudioBuffer(DataBuffer[], AudioFormat)
Initializes a new instance of the AudioBuffer class.
Declaration
public AudioBuffer(DataBuffer[] dataBuffers, AudioFormat format)
Parameters
Type | Name | Description |
---|---|---|
DataBuffer[] | dataBuffers | The data buffers. |
AudioFormat | format | The format. |
Properties
Gain
Gets or sets the gain.
Declaration
public double Gain { get; }
Property Value
Type | Description |
---|---|
System.Double |
GeneratedByPlc
Gets or sets a value indicating whether this buffer contains data generated by packet loss concealment (PLC).
Declaration
public bool GeneratedByPlc { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsDtmf
Gets a value indicating whether this buffer has DTMF data.
Declaration
public bool IsDtmf { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsL16
Gets a value indicating whether this buffer has L16 audio.
Declaration
public bool IsL16 { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsMuted
Gets a value indicating whether this instance has been muted.
Declaration
public override bool IsMuted { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Overrides
IsOpus
Gets a value indicating whether this buffer has Opus audio.
Declaration
public bool IsOpus { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsPcm
Gets a value indicating whether this buffer has raw PCM audio.
Declaration
public bool IsPcm { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsPcma
Gets a value indicating whether this buffer has PCMA audio.
Declaration
public bool IsPcma { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsPcmu
Gets a value indicating whether this buffer has PCMU audio.
Declaration
public bool IsPcmu { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
ApplyGain(Double)
Applies gain to this instance.
Declaration
public void ApplyGain(double gain)
Parameters
Type | Name | Description |
---|---|---|
System.Double | gain | The gain. |
CalculateLevel()
Calculates the level of this instance.
Declaration
public double CalculateLevel()
Returns
Type | Description |
---|---|
System.Double |
Clone()
Clones this instance.
Declaration
public override AudioBuffer Clone()
Returns
Type | Description |
---|---|
AudioBuffer |
Overrides
CreateInstance()
Creates a new instance.
Declaration
protected override AudioBuffer CreateInstance()
Returns
Type | Description |
---|---|
AudioBuffer |
Overrides
CreateSilence(Int32, AudioConfig)
Creates a silent audio buffer with the specified duration and configuration.
Declaration
public static AudioBuffer CreateSilence(int duration, AudioConfig config)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | duration | The duration in milliseconds. |
AudioConfig | config | The configuration. |
Returns
Type | Description |
---|---|
AudioBuffer |
CreateSilence(Int32, Int32, Int32)
Creates a silent audio buffer with the specified duration, clock rate, and channel count.
Declaration
public static AudioBuffer CreateSilence(int duration, int clockRate, int channelCount)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | duration | The duration in milliseconds. |
System.Int32 | clockRate | The clock rate. |
System.Int32 | channelCount | The channel count. |
Returns
Type | Description |
---|---|
AudioBuffer |
CreateSound(Int64, Int32, AudioConfig)
Creates an audio buffer with the specified duration and configuration, a frequency of 440Hz, and an amplitude of 16,384.
Declaration
public static AudioBuffer CreateSound(long timestamp, int duration, AudioConfig config)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | The starting time of this buffer relative to the clock rate. |
System.Int32 | duration | The duration in milliseconds. |
AudioConfig | config | The configuration. |
Returns
Type | Description |
---|---|
AudioBuffer |
CreateSound(Int64, Int32, AudioConfig, Single)
Creates a silent audio buffer with the specified duration, configuration, and frequency, and an amplitude of 16,384.
Declaration
public static AudioBuffer CreateSound(long timestamp, int duration, AudioConfig config, float frequency)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | The starting time of this buffer relative to the clock rate. |
System.Int32 | duration | The duration in milliseconds. |
AudioConfig | config | The configuration. |
System.Single | frequency | The frequency. |
Returns
Type | Description |
---|---|
AudioBuffer |
CreateSound(Int64, Int32, AudioConfig, Single, Int32)
Creates a silent audio buffer with the specified duration, configuration, frequency, and amplitude.
Declaration
public static AudioBuffer CreateSound(long timestamp, int duration, AudioConfig config, float frequency, int amplitude)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | The starting time of this buffer relative to the clock rate. |
System.Int32 | duration | The duration in milliseconds. |
AudioConfig | config | The configuration. |
System.Single | frequency | The frequency. |
System.Int32 | amplitude | The amplitude. |
Returns
Type | Description |
---|---|
AudioBuffer |
CreateSound(Int64, Int32, Int32, Int32)
Creates an audio buffer with the specified duration, clock rate, and channel count, a frequency of 440Hz, and an amplitude of 16,384.
Declaration
public static AudioBuffer CreateSound(long timestamp, int duration, int clockRate, int channelCount)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | The starting time of this buffer relative to the clock rate. |
System.Int32 | duration | The duration in milliseconds. |
System.Int32 | clockRate | The clock rate. |
System.Int32 | channelCount | The channel count. |
Returns
Type | Description |
---|---|
AudioBuffer |
CreateSound(Int64, Int32, Int32, Int32, Single)
Creates a silent audio buffer with the specified duration, clock rate, channel count, and frequency, and an amplitude of 16,384.
Declaration
public static AudioBuffer CreateSound(long timestamp, int duration, int clockRate, int channelCount, float frequency)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | The starting time of this buffer relative to the clock rate. |
System.Int32 | duration | The duration in milliseconds. |
System.Int32 | clockRate | The clock rate. |
System.Int32 | channelCount | The channel count. |
System.Single | frequency | The frequency. |
Returns
Type | Description |
---|---|
AudioBuffer |
CreateSound(Int64, Int32, Int32, Int32, Single, Int32)
Creates a silent audio buffer with the specified duration, clock rate, channel count, frequency, and amplitude.
Declaration
public static AudioBuffer CreateSound(long timestamp, int duration, int clockRate, int channelCount, float frequency, int amplitude)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | The starting time of this buffer relative to the clock rate. |
System.Int32 | duration | The duration in milliseconds. |
System.Int32 | clockRate | The clock rate. |
System.Int32 | channelCount | The channel count. |
System.Single | frequency | The frequency. |
System.Int32 | amplitude | The amplitude. |
Returns
Type | Description |
---|---|
AudioBuffer |
FromJson(String)
Deserializes an instance from JSON.
Declaration
public static AudioBuffer FromJson(string audioBufferJson)
Parameters
Type | Name | Description |
---|---|---|
System.String | audioBufferJson | The audio buffer JSON. |
Returns
Type | Description |
---|---|
AudioBuffer |
FromJsonArray(String)
Deserializes an array of instances from JSON.
Declaration
public static AudioBuffer[] FromJsonArray(string audioBuffersJson)
Parameters
Type | Name | Description |
---|---|---|
System.String | audioBuffersJson | The audio buffers JSON. |
Returns
Type | Description |
---|---|
AudioBuffer[] |
GetMinimumBufferLength(Int32, AudioConfig)
Gets the minimum data buffer length for a given duration and configuration.
Declaration
public static int GetMinimumBufferLength(int duration, AudioConfig config)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | duration | The duration. |
AudioConfig | config | The configuration. |
Returns
Type | Description |
---|---|
System.Int32 |
GetMinimumBufferLength(Int32, Int32, Int32)
Gets the minimum data buffer length for a given duration, clock rate, and channel count.
Declaration
public static int GetMinimumBufferLength(int duration, int clockRate, int channelCount)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | duration | The duration. |
System.Int32 | clockRate | The clock rate. |
System.Int32 | channelCount | The channel count. |
Returns
Type | Description |
---|---|
System.Int32 |
Mute()
Mutes this instance. This is a one-way operation that clears the underlying data buffer.
Declaration
public override bool Mute()
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
ToJson()
Serializes this instance to JSON.
Declaration
public string ToJson()
Returns
Type | Description |
---|---|
System.String |
ToJson(AudioBuffer)
Serializes an instance to JSON.
Declaration
public static string ToJson(AudioBuffer audioBuffer)
Parameters
Type | Name | Description |
---|---|---|
AudioBuffer | audioBuffer | The audio buffer. |
Returns
Type | Description |
---|---|
System.String |
ToJsonArray(AudioBuffer[])
Serializes an array of instances to JSON.
Declaration
public static string ToJsonArray(AudioBuffer[] audioBuffers)
Parameters
Type | Name | Description |
---|---|---|
AudioBuffer[] | audioBuffers | The audio buffers. |
Returns
Type | Description |
---|---|
System.String |