Reading Multichannel Audio

The Windows Media Audio 9 Professional codec can encode multichannel audio (more than two channels). When reading a file with multichannel audio, you must configure the output properly or the audio will be delivered at a lower quality and in stereo. To set an output for multichannel audio delivery, you must set two output settings: g_wszEnableDiscreteOutput and g_wszSpeakerConfig.

Setting g_wszEnableDiscreteOutput to TRUE sets the codec to deliver high-definition audio output. High-definition audio is encoded by the Windows Media Audio 9 codec with 24-bit samples in stereo or multiple channels. If this setting is FALSE, only 16-bit stereo output will be delivered.

The number of speakers on the playing computer is set with g_wszSpeakerConfig. This setting is a DWORD value set to one of the DirectSound speaker constants listed in the following table. To resolve these constant names for your compiler, you must include dsound.h.

Constant Value Description
DSSPEAKER_DIRECTOUT 0x00000000 The audio is passed through directly, without being configured for speakers.
DSSPEAKER_HEADPHONE 0x00000001 The client computer is equipped with headphones.
DSSPEAKER_MONO 0x00000002 The client computer is equipped with a monaural speaker.
DSSPEAKER_QUAD 0x00000003 The client computer is equipped with quadraphonic speakers.
DSSPEAKER_STEREO 0x00000004 The client computer is equipped with stereo speakers.
DSSPEAKER_SURROUND 0x00000005 The client computer is equipped with four-channel surround-sound speakers.
DSSPEAKER_5POINT1 0x00000006 The client computer is equipped with five speakers and a subwoofer.
DSSPEAKER_7POINT1 0x00000007 The client computer is equipped with seven speakers and a subwoofer.

 

To set these settings, use IWMReaderAdvanced2::SetOutputSetting.

Finally, for the channels to be output discretely, with no fold-down to stereo, you must set the correct media type on the output by following these steps:

  1. Call IWMReader::GetOutputFormatCount to get the number of supported formats for the relevant audio output. Output format indexes are zero-based.
  2. For each supported format, call IWMReader::GetOutputFormat to retrieve the IWMOutputMediaProps interface on the output media properties object.
  3. Call IWMMediaProps::GetMediaType to retrieve the media type.
  4. If the retrieved media type is the desired multichannel type, then set it by calling IWMReader::SetOutputProps.

After you have set discrete output and the speaker configuration, the output formats enumerated by the reader should include multichannel formats that use the WAVEFORMATEXTENSIBLE structure. If you enumerate the output formats before setting the properties, only formats with 1 or 2 channels and a maximum of 16 bits per channel will be included. As with other audio formats, you should use only the formats enumerated by the reader; do not configure your own.

Note

You can output multichannel audio only if your application is running on Microsoft Windows XP or a later version of Microsoft Windows.

 

Inputs, Streams and Outputs

Reading ASF Files

Output Settings

Working with High-Resolution PCM Audio