Class AudioContent
- Assembly
- MonoGame.Framework.Content.Pipeline.dll
Encapsulates and provides operations, such as format conversions, on the source audio. This type is produced by the audio importers and used by audio processors to produce compiled audio assets.
public class AudioContent : ContentItem, IDisposable
- Inheritance
-
AudioContent
- Implements
- Inherited Members
Remarks
Note that AudioContent can load and process audio files that are not supported by the importers.
Constructors
AudioContent(string, AudioFileType)
Initializes a new instance of AudioContent.
public AudioContent(string audioFileName, AudioFileType audioFileType)
Parameters
audioFileName
stringName of the audio source file to be processed.
audioFileType
AudioFileTypeType of the processed audio: WAV, MP3 or WMA.
Remarks
Constructs the object from the specified source file, in the format specified.
Properties
Data
The current raw audio data without header information.
public ReadOnlyCollection<byte> Data { get; }
Property Value
Remarks
This changes from the source data to the output data after conversion. For MP3 and WMA files this throws an exception to match XNA behavior.
Duration
The duration of the audio data.
public TimeSpan Duration { get; }
Property Value
FileName
The name of the original source audio file.
[ContentSerializer(AllowNull = false)]
public string FileName { get; }
Property Value
FileType
The type of the original source audio file.
public AudioFileType FileType { get; }
Property Value
Format
The current format of the audio data.
public AudioFormat Format { get; }
Property Value
Remarks
This changes from the source format to the output format after conversion.
LoopLength
The current loop length in samples.
public int LoopLength { get; }
Property Value
Remarks
This changes from the source loop length to the output loop length after conversion.
LoopStart
The current loop start location in samples.
public int LoopStart { get; }
Property Value
Remarks
This changes from the source loop start to the output loop start after conversion.
Methods
ConvertFormat(ConversionFormat, ConversionQuality, string)
Transcodes the source audio to the target format and quality.
[Obsolete("You should prefer to use AudioProfile.")]
public void ConvertFormat(ConversionFormat formatType, ConversionQuality quality, string saveToFile)
Parameters
formatType
ConversionFormatFormat to convert this audio to.
quality
ConversionQualityQuality of the processed output audio. For streaming formats, it can be one of the following: Low (96 kbps), Medium (128 kbps), Best (192 kbps). For WAV formats, it can be one of the following: Low (11kHz ADPCM), Medium (22kHz ADPCM), Best (44kHz PCM)
saveToFile
stringThe name of the file that the converted audio should be saved into. This is used for SongContent, where the audio is stored external to the XNB file. If this is null, then the converted audio is stored in the Data property.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
SetData(byte[], AudioFormat, TimeSpan, int, int)
public void SetData(byte[] data, AudioFormat format, TimeSpan duration, int loopStart, int loopLength)
Parameters
data
byte[]format
AudioFormatduration
TimeSpanloopStart
intloopLength
int