The XMA2 command-line encoder converts a set of PCM files to XMA2 format, or an XMA2 file to PCM format.
This tool can be used both for Xbox 360 and Xbox One. For Xbox 360 the output of the tool can be used without any changes. For Xbox One the seek table might need to be byte swapped; code to do this is shown in the Xbox One Format section.
XMA2Encode file [/TargetFile xmafile][/PCMOutputFile pcmfile][/DecodeToPCM pcmfile][/BlockSize][/Quality value][/FilterHighFrequencies][/LoopWholeFile][/UseLoopPoints][/Speaker pos][/MeasureTime][/Verbose][/Help] |
| Option | Description | ||
|---|---|---|---|
| file | Specifies the file name of the file to convert. You can specify multiple file/speaker position pairs: XMA2ENCODE pcmfile [/Speaker pos ...] [pcmfile [/Speaker pos ...] ...] [options] When you encode multiple files, the XMA2Encode tool requires that the input files either be all single channel, or all stereo with the last stream being mono or stereo depending on the number of channels being encoded.
| ||
| /TargetFile xmafile | Encodes to <xmafile> (only one target file is allowed). | ||
| /PCMOutputFile pcmfile | Decodes the generated XMA2 file back to <pcmfile>. When you use this option, the tool generates two output files, an XMA2 encoded audio file and a PCM file, which is the result of decoding the just created XMA2 file. The resulting PCM file will have the same audio quality as the new XMA2 file. It allows for previewing of the XMA2 file's quality on Windows. | ||
| /DecodeToPCM pcmfile | Decodes an existing XMA2 file to <pcmfile>. | ||
| /BlockSize | Specifies the XMA2 compression block size to use (2 KB to 8,190 KB). The default block size is 64 KB. | ||
| /Quality value | Specifies the XMA2 compression quality level to use (1 to 100). The default value for quality is 60. | ||
| /FilterHighFrequencies | Filters out high frequencies in the source file. | ||
| /LoopWholeFile | Loops the entire file, even if loop points are already present. LoopWholeFile and UseLoopPoints are mutually exclusive. If neither the LoopWholeFile nor the UseLoopPoints argument has been specified, the file will not loop even if loop points are present. | ||
| /UseLoopPoints | Uses existing loop points, if present; otherwise, don't loop. LoopWholeFile and UseLoopPoints are mutually exclusive. If neither the LoopWholeFile nor the UseLoopPoints argument has been specified, the file will not loop even if loop points are present. | ||
| /Speaker pos | Specifies the speaker assignment for a channel of the source file. This option must immediately follow the file name. <pos> can be [L | R | C | LFE | LS | RS | LB | RB], where: L = Front left R = Front right C = Front center LFE = Low frequency LS = Left surround RS = Right surround LB = Left back RB = Right back
| ||
| /MeasureTime | Shows the time spent encoding. | ||
| /Verbose | Enables verbose output. | ||
| /Help | Shows this usage information. |
All options can be abbreviated to their first letters.
The following table lists error codes XMA2 Command-Line Encoder may print out to indicate problems encoding.
| Error Code | Description |
|---|---|
| 0x88890001 | The specified loop points are invalid. |
| 0x88890002 | The specified format is invalid. |
| 0x88890003 | A parameter is out of range. |
| 0x88890004 | A read operation failed. |
| 0x88890005 | There was an invalid XMA frame. |
| 0x88890006 | There was an incomplete XMA frame. |
| 0x88890007 | The stuffing bit was zero. |
| 0x88890008 | A data fetch failed. |
Output of this tool needs to be ULONG byte-swapped for Xbox One. If the input is a WAVE file the output can be used without alteration.
To byte-swap the seek table use the following lines of code.
for(UINT32 i = 0;(i < xmaformat->BlockCount);i++)
{
rgpXMASeekTable[i] = _byteswap_ulong(rgpXMASeekTable[i]);
}
Consider adding the lines of code to your app to test the funcionality, then perhaps writing a separate tool to perform the swap so no pre-processing is required of your app.
It is possible to write your own coding tool using the methods defined in xmaencoder.h and implemented in xmaencoder.lib. The xmaencoder.h file is locatd by default in the C:\Program Files (x86)\Microsoft Durango XDK\PC\include folder, and the xmaencoder.lib file is located by default in the C:\Program Files (x86)\Microsoft Durango XDK\PC\lib\amd64 folder.
The single method available in the header and library is XAudio2XMAEncoder.
The XMA2InMemoryEncoder and XMAInMemoryEncoder methods defined in the header are legacy and should not be used.
XMA2 Encoder Reference
Describes the functions available in xmaencoder.lib.