请问怎么用waveOutSetVolume设置音量

amartapple 2002-11-30 06:48:06
这是文档的内容
The waveOutSetVolume function sets the volume level of the specified waveform-audio output device.

MMRESULT waveOutSetVolume(

HWAVEOUT hwo,
DWORD dwVolume
);


Parameters

hwo

Handle of an open waveform-audio output device. This parameter can also be a device identifier.

dwVolume

New volume setting. The low-order word contains the left-channel volume setting, and the high-order word contains the right-channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence.
If a device does not support both left and right volume control, the low-order word of dwVolume specifies the volume level, and the high-order word is ignored.



Return Values

Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following:

MMSYSERR_INVALHANDLE Specified device handle is invalid.
MMSYSERR_NODRIVER No device driver is present.
MMSYSERR_NOMEM Unable to allocate or lock memory.
MMSYSERR_NOTSUPPORTED Function is not supported.


Remarks

If a device identifier is used, then the result of the waveOutSetVolume call applies to all instances of the device. If a device handle is used, then the result applies only to the instance of the device referenced by the device handle.
Not all devices support volume changes. To determine whether the device supports volume control, use the WAVECAPS_VOLUME flag to test the dwSupport member of the WAVEOUTCAPS structure (filled by the waveOutGetDevCaps function). To determine whether the device supports volume control on both the left and right channels, use the WAVECAPS_LRVOLUME flag.

Most devices do not support the full 16 bits of volume-level control and will not use the high-order bits of the requested volume setting. For example, for a device that supports 4 bits of volume control, requested volume level values of 0x4000, 0x4FFF, and 0x43BE all produce the same physical volume setting: 0x4000. The waveOutGetVolume function returns the full 16-bit setting set with waveOutSetVolume.
Volume settings are interpreted logarithmically. This means the perceived increase in volume is the same when increasing the volume level from 0x5000 to 0x6000 as it is from 0x4000 to 0x5000.

他的第一个值HWAVEOUT hwo怎么获得
还有别的方法么

...全文
1410 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
szbug 2002-12-11
  • 打赏
  • 举报
回复
不是,这个函数控制的音量是指Wave播放的音量,你在音量控制台里可以看到一般常用的有总音量,Wave音量,CD音量,MIDI音量。。。这个是控制Wave的。
amartapple 2002-12-11
  • 打赏
  • 举报
回复
还是不行呀
这个函数是不是只对特定的文件类型有效,我的文件是dat,avi,mp3
tsk 2002-12-07
  • 打赏
  • 举报
回复
UP
warton 2002-12-03
  • 打赏
  • 举报
回复
来晚了!!
szbug 2002-12-03
  • 打赏
  • 举报
回复
这是我在一个程序里面写的,应该没有问题的:
if(VolFlag == +1 && VoldxfPB->Position < 1000)
{
TimerUpdate->OnTimer = NULL;
VoldxfPB->Step = +5;
VoldxfPB->StepIt();
if ( VoldxfPB->Position > 1000 )
VoldxfPB->Position = 1000;
bSetVolReturn = SetWaveVolumePercent(VoldxfPB->Position/10.0, true);
bSetVolReturn = SetWaveVolumePercent(VoldxfPB->Position/10.0, false);
TimerUpdate->OnTimer = TimerUpdateTimer;
}
if(VolFlag == -1 && VoldxfPB->Position > 0)
{
TimerUpdate->OnTimer = NULL;
VoldxfPB->Step = -5;
VoldxfPB->StepIt();
if ( VoldxfPB->Position < 0 )
VoldxfPB->Position = 0;
bSetVolReturn = SetWaveVolumePercent(VoldxfPB->Position/10.0, true);
bSetVolReturn = SetWaveVolumePercent(VoldxfPB->Position/10.0, false);
TimerUpdate->OnTimer = TimerUpdateTimer;
}
PSP 2002-12-03
  • 打赏
  • 举报
回复
这是我的代码,可用,写得不对的地方,望各位高手指正:
//初始TrackBar刻度既当前音量
void __fastcall TMainForm::FormShow(TObject *Sender)
{

//获取系统音量大小
DWORD volume;
TrackBar1->Position = waveOutGetVolume(0, &volume);
TrackBar1->Position = 0xFFFF - LOWORD(volume);

}
//使用TrackBar改变音量
void __fastcall TMainForm::TrackBar1Change(TObject *Sender)
{
int value = 0xFFFF - TrackBar1->Position;
waveOutSetVolume(0, MAKELONG(value, value));
}
invalid 2002-11-30
  • 打赏
  • 举报
回复
参考:
URL= http://expert.csdn.net/Expert/topic/1215/1215050.xml?temp=.8503534

13,873

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧