Determining Nonstandard Format Support

To see whether a device supports a particular format (standard or nonstandard), you can call the waveOutOpen function with the WAVE_FORMAT_QUERY flag. The following example uses this technique to determine whether a waveform-audio device supports a specified format.

// Determines whether the specified waveform-audio output device 
// supports a specified waveform-audio format. Returns 
// MMSYSERR_NOERROR if the format is supported, WAVEERR_BADFORMAT if 
// the format is not supported, and one of the other MMSYSERR_ error 
// codes if there are other errors encountered in opening the 
// specified waveform-audio device. 
MMRESULT IsFormatSupported(LPWAVEFORMATEX pwfx, UINT uDeviceID) 
    return (waveOutOpen( 
        NULL,                 // ptr can be NULL for query 
        uDeviceID,            // the device identifier 
        pwfx,                 // defines requested format 
        NULL,                 // no callback 
        NULL,                 // no instance data 
        WAVE_FORMAT_QUERY));  // query only, do not open device 

This technique for determining nonstandard format support also applies to waveform-audio input devices. The only difference is that the waveInOpen function is used in place of waveOutOpen to query for format support.

To determine whether a particular waveform-audio data format is supported by any of the waveform-audio devices in a system, use the technique illustrated in the previous example, but specify the WAVE_MAPPER constant for the uDeviceID parameter.