[이 페이지와 연결된 기능인 Waveform Audio레거시 기능입니다. WASAPI 및 오디오 그래프 에 의해 대체되었습니다. WASAPI 및 오디오 그래프 Windows 10 및 Windows 11에 최적화되었습니다. 가능한 경우 새 코드에서 Waveform Audio대신 WASAPI 및 Audio Graphs 사용하는 것이 좋습니다. 가능한 경우 레거시 API를 사용하는 기존 코드를 다시 작성하여 새 API를 사용하도록 제안합니다.]
두 개 이하의 채널과 8비트 또는 16비트 샘플이 있는 PCM 오디오 데이터의 경우 WAVEFORMATEX 구조를 사용하여 데이터 형식을 지정합니다.
다음 예제에서는 11.025kHz(kHz) 8비트 모노 및 44.1kHz 16비트 스테레오에 대해 WAVEFORMATEX 구조를 설정하는 방법을 보여 줍니다. WAVEFORMATEX 설정한 후 이 예제에서는 IsFormatSupported 함수를 호출하여 PCM 파형 출력 디바이스가 형식을 지원하는지 확인합니다. IsFormatSupported의 소스 코드는 비표준 형식 지원 확인 예제에 나와 있습니다.
UINT wReturn;
WAVEFORMATEX pcmWaveFormat;
// Set up WAVEFORMATEX for 11 kHz 8-bit mono.
pcmWaveFormat.wFormatTag = WAVE_FORMAT_PCM;
pcmWaveFormat.nChannels = 1;
pcmWaveFormat.nSamplesPerSec = 11025L;
pcmWaveFormat.nAvgBytesPerSec = 11025L;
pcmWaveFormat.nBlockAlign = 1;
pcmWaveFormat.wBitsPerSample = 8;
pcmWaveFormat.cbSize = 0;
// See if format is supported by any device in system.
wReturn = IsFormatSupported(&pcmWaveFormat, WAVE_MAPPER);
// Report results.
if (wReturn == 0)
MessageBox(hMainWnd, "11 kHz 8-bit mono is supported.",
"", MB_ICONINFORMATION);
else if (wReturn == WAVERR_BADFORMAT)
MessageBox(hMainWnd, "11 kHz 8-bit mono NOT supported.",
"", MB_ICONINFORMATION);
else
MessageBox(hMainWnd, "Error opening waveform device.",
"Error", MB_ICONEXCLAMATION);
// Set up WAVEFORMATEX for 44.1 kHz 16-bit stereo.
pcmWaveFormat.wFormatTag = WAVE_FORMAT_PCM;
pcmWaveFormat.nChannels = 2;
pcmWaveFormat.nSamplesPerSec = 44100L;
pcmWaveFormat.nAvgBytesPerSec = 176400L;
pcmWaveFormat.nBlockAlign = 4;
pcmWaveFormat.wBitsPerSample = 16;
pcmWaveFormat.cbSize = 0;
// See if format is supported by any device in the system.
wReturn = IsFormatSupported(&pcmWaveFormat, WAVE_MAPPER);
// Report results.
if (wReturn == 0)
MessageBox(hMainWnd, "44.1 kHz 16-bit stereo is supported.",
"", MB_ICONINFORMATION);
else if (wReturn == WAVERR_BADFORMAT)
MessageBox(hMainWnd, "44.1 kHz 16-bit stereo NOT supported.",
"", MB_ICONINFORMATION);
else
MessageBox(hMainWnd, "Error opening waveform device.",
"Error", MB_ICONEXCLAMATION);