Struct AudioFormat
Defines the format of PCM data consumed or produced by Opus.
Namespace: DSharpPlus.VoiceNext
Assembly: cs.temp.dll.dll
Syntax
public struct AudioFormat
Constructors
AudioFormat(Int32, Int32, VoiceApplication)
Creates a new audio format for use with Opus encoder.
Declaration
public AudioFormat(int sampleRate = 48000, int channelCount = 2, VoiceApplication voiceApplication = VoiceApplication.Music)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | sampleRate | Audio sampling rate in Hz. |
System.Int32 | channelCount | Number of audio channels in the data. |
VoiceApplication | voiceApplication | Encoder preset to use. |
Properties
AllowedChannelCounts
Gets the collection of channel counts the Opus encoder can use.
Declaration
public static IReadOnlyCollection<int> AllowedChannelCounts { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<System.Int32> |
AllowedSampleDurations
Gets the collection of sample durations (in ms) the Opus encoder can use.
Declaration
public static IReadOnlyCollection<int> AllowedSampleDurations { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<System.Int32> |
AllowedSampleRates
Gets the collection of sampling rates (in Hz) the Opus encoder can use.
Declaration
public static IReadOnlyCollection<int> AllowedSampleRates { get; }
Property Value
Type | Description |
---|---|
IReadOnlyCollection<System.Int32> |
ChannelCount
Gets the audio channel count.
Declaration
public int ChannelCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Default
Gets the default audio format. This is a formt configured for 48kHz sampling rate, 2 channels, with music quality preset.
Declaration
public static AudioFormat Default { get; }
Property Value
Type | Description |
---|---|
AudioFormat |
SampleRate
Gets the audio sampling rate in Hz.
Declaration
public int SampleRate { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
VoiceApplication
Gets the voice application, which dictates the quality preset.
Declaration
public VoiceApplication VoiceApplication { get; }
Property Value
Type | Description |
---|---|
VoiceApplication |
Methods
CalculateSampleSize(Int32)
Calculates a sample size in bytes.
Declaration
public int CalculateSampleSize(int sampleDuration)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | sampleDuration | Millsecond duration of a sample. |
Returns
Type | Description |
---|---|
System.Int32 | Calculated sample size in bytes. |
GetMaximumBufferSize()
Gets the maximum buffer size for decoding. This method should be called when decoding Opus data to PCM, to ensure sufficient buffer size.
Declaration
public int GetMaximumBufferSize()
Returns
Type | Description |
---|---|
System.Int32 | Buffer size required to decode data. |