도전2022

볼륨 조절 본문

참고자료

볼륨 조절

hotdigi 2012. 4. 23. 15:15

http://support.microsoft.com/kb/139098/ko

기술 자료: 139098 - 마지막 검토: 1999년 3월 6일 토요일 - 수정: 1.0

웨이브 오디오 볼륨 조절 API를 사용하는 방법


기계 번역된 문서와 영문 원본 문서 나란히 보기

기계 번역 고지 사항 보기

이 문서가 적용되는 제품 보기.

이 페이지에서


모두 확대 | 모두 축소

요약

함수 waveOutGetVolume() 및 waveOutSetVolume() 설정하고 웨이브 출력 장치 볼륨 검색할 수 있습니다. 성공 또는 검색할 DWORD에 낮은 순서 단어의 왼쪽된 채널의 볼륨 및 높은 순서 단어의 오른쪽 채널이 볼륨이 포함되어 있습니다. 이 문서에서는 이러한 함수 사용하는 일반 샘플 추가할 수 있는 단일 함수를 통해 나와 있습니다.

위로 가기

추가 정보

Win32 SDK에 포함된 믹서 API를 제공하는 보다 광범위한 컨트롤, 빠른 있지만 waveOutGetVolume() 및 waveOutSetVolume() 함수를 사용하여 간단한 오디오 볼륨 조절 얻을 수 있습니다. 


일반 샘플이 이 문서에서는 지정된 ShowVolume() 함수의 코드를 추가하여 출력 볼륨 컨트롤 상태에 대한 정보를 메시지 상자에 이를 발생할 수 있습니다. 샘플을 실행하는 동안 WSS 오디오 Conrol 볼륨 컨트롤 또는 웨이브 출력 볼륨 표시하는 주어진된 사운드 카드의 믹서 컨트롤을 경험하는 슬라이더 위치 변경 ShowVolume() 함수에서 왼쪽과 오른쪽 채널 볼륨에 대한 값을 변경할 때. 


샘플이 실행되면 첫 번째 메시지 상자에는 웨이브 출력 장치 수를 보고합니다. 두 번째 및 세 번째 메시지 상자는 8192의 왼쪽된 채널의 볼륨 및 최대 65535) 밖으로 16384보다 오른쪽 채널 볼륨이 보고합니다. 볼륨 조절 웨이브 열의 가로 슬라이더 균형을 슬라이더가 되고 오른쪽 볼륨 이제 큰 때문에 오른쪽으로 설정됩니다. 또한 볼륨 슬라이더를 웨이브 열 세로 슬라이더 두 채널 큰 볼륨 설정의 추적 1/4 위치로 설정됩니다. 


네 번째 및 다섯 번째 메시지 상자를 32768에서 16384 왼쪽 및 오른쪽 볼륨 각각 보고합니다. 이제 균형을 슬라이더를 왼쪽 것이며 웨이브 볼륨이 약 1/2, 더 큰 값을 다시 추적.

위로 가기

일반 샘플 추가할 수 ShowVolume() 코드

// Link with mmsystem.lib for 16-bit applications and

// link with winmm.lib for 32-bit applications.


#include <mmsystem.h>

#include <stdlib.h>


void ShowVolume(void);   //Prototype the function early in the app


void ShowVolume(void)

{

    // This is the function that can be added to the Generic Sample to

    // illustrate the use of waveOutGetVolume() and waveOutSetVolume().


    char buffer[40];

    char printbuf[80];

    UINT uRetVal, uNumDevs;

    DWORD volume;

    long lLeftVol, lRightVol;


    WAVEOUTCAPS waveCaps;


    // Make sure there is at least one

    // wave output device to work with.

    if (uNumDevs = waveOutGetNumDevs())

    {

   itoa((int)uNumDevs, buffer, 10);

   wsprintf(printbuf, "Number of devices is %s\n", (LPSTR)buffer);

   MessageBox(GetFocus(), printbuf, "NumDevs", MB_OK);

    }


    // This sample uses a hard-coded 0 as the device ID, but retail

    // applications should loop on devices 0 through N-1, where N is the

    // number of devices returned by waveOutGetNumDevs().

    if (!waveOutGetDevCaps(0,(LPWAVEOUTCAPS)&waveCaps,

       sizeof(WAVEOUTCAPS)))


    {

   // Verify the device supports volume changes

   if(waveCaps.dwSupport & WAVECAPS_VOLUME)

   {

       // The low word is the left volume, the high word is the right.

       // Set left channel: 2000h is one-eighth volume (8192 base ten).

       // Set right channel: 4000h is quarter volume (16384 base ten).

       uRetVal = waveOutSetVolume(0, (DWORD)0x40002000UL);


       // Now get and display the volumes.

       uRetVal = waveOutGetVolume(0, (LPDWORD)&volume);


       lLeftVol = (long)LOWORD(volume);

       lRightVol = (long)HIWORD(volume);


       ltoa(lLeftVol, buffer, 10);

       wsprintf(printbuf, "Left Volume is %s\n", (LPSTR)buffer);

       MessageBox(GetFocus(), printbuf, "Left Volume", MB_OK);


       ltoa(lRightVol, buffer, 10);

       wsprintf(printbuf, "Right Volume is %s\n", (LPSTR)buffer);

       MessageBox(GetFocus(), printbuf, "Right Volume", MB_OK);


       // The low word is the left volume, the high word is the right.

       // Set left channel: 8000h is half volume (32768 base ten).

       // Set right channel: 4000h is quarter volume (16384 base ten).

       uRetVal = waveOutSetVolume(0, (DWORD)0x40008000UL);


       // Now get and display the volumes.

       uRetVal = waveOutGetVolume(0, (LPDWORD)&volume);


       lLeftVol = (long)LOWORD(volume);

       lRightVol = (long)HIWORD(volume);


       ltoa(lLeftVol, buffer, 10);

       wsprintf(printbuf, "Left Volume is %s\n", (LPSTR)buffer);

       MessageBox(GetFocus(), printbuf, "Left Volume", MB_OK);


       ltoa(lRightVol, buffer, 10);

       wsprintf(printbuf, "Right Volume is %s\n", (LPSTR)buffer);

       MessageBox(GetFocus(), printbuf, "Right Volume", MB_OK);


   }

    }

}

'참고자료' 카테고리의 다른 글

Microsoft Expression Encoder 4 with Service Pack 1 (SP1)  (0) 2012.04.30
ios 가상 이미지 관련 툴  (0) 2012.04.30
Windows Desktop Development Downloads  (0) 2012.04.21
3M Multi touch app  (0) 2012.04.10
CS02-500 Digital Microscope  (0) 2012.04.10