API:WaveOutSetVolume,在MAPI帮助里咋找不道?(100分)

  • 主题发起人 PuppyFat
  • 开始时间
P

PuppyFat

Unregistered / Unconfirmed
GUEST, unregistred user!
听说WaveOutSetVolume可以控制播放的音量,可是我在MAPI帮助里咋找不到?哪为大虾能告诉我如何使用WaveOutSetVolume?
 
MAPI -- Messageing Application Programming Interface
wave打头的一堆函数去Win32SDK里找吧
在MSDN里很容易就查到了
 
那个函数在winmm.dll中, delphi的win32.hlp不包括的.
 
在MSDN里有,要看说明可以到
windows.pas里面看。
mapi<>mutimedia api:)
 
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 devicedo
es 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:

Value Description
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.

 
//得到当前音量:
procedure GetVolume;
var allvolume,leftv,rightv:integer;
begin

waveoutgetvolume(0,@allvolume);
leftv:=allvolume and $0ffff;
rightv:=(allvolume and $0ffff0000) div $10000;
end;


//设置当前音量:
procedure SetVolume(left,right:integer);
var leftv,rightv:integer;
begin

leftv:=left;
rightv:=right;
mmsystem.waveOutSetVolume(0,leftv+rightv*65536);
end;

加分吧!!
 
问题是我用waveOutsetVolume时,
总说它没定义.
 
你必须在uses中加入mmsystem单元
 
use mmsystem;
 
多人接受答案了。
 
我试过,但是只能调节一个声道的声音,而且音量最大为当前系统的设置值。
监控时:rightv=0!Why?
 
那个Longint的变量包含着左右声道的音量.高16位是右声道的音量!低16位是左声道的音量!
var
t,v:Longint;
begin

// if a=0 then
Exit;
t:=TrackBar1.Position;
v:=(t shl 8)or(t shl 24);
waveOutSetVolume(0,v);
end;

 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
958
DelphiTeacher的专栏
D
顶部