怎样用Windows API 函数通过MODEN播放'*.wav'声音文件???(100分)

R

redweek

Unregistered / Unconfirmed
GUEST, unregistred user!
当拨号完成后,用户拿起话筒时,通过moden播放‘*。wav’文件,使接听者可以听到声音。<br>1。怎样获得waveform out 设备的Iddevice?<br>2.怎样把‘*.wav’变成‘pcm’格式?<br>3。怎样播放?<br><br>我下面的程序有问题,谁能帮我解答?<br>&nbsp; &nbsp; &nbsp; &nbsp;e-mail:redweek@21cn.com<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; redweek@163.net<br><br><br>-------------------------------<br>unit waveout;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,mmsystem,<br>&nbsp; StdCtrls;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; &nbsp; lpdata:thandle;<br>&nbsp; &nbsp; mywaveout:hwaveout;<br><br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>&nbsp;var<br>&nbsp; &nbsp;iomm:hMMIO;<br>&nbsp; &nbsp;mmckinfoparent:MMCKINFO;<br>&nbsp; &nbsp;mmckinfosubchunk:MMCKINFO;<br>&nbsp; &nbsp;dwfmtsize:integer;<br>&nbsp; &nbsp;pformat:twaveformatex;<br>&nbsp; &nbsp;caps:waveoutcaps;<br>&nbsp; &nbsp;deviceid:cardinal;<br>&nbsp; &nbsp;dwdatasize:integer;<br>&nbsp; &nbsp;hwavehdr:hglobal;<br>&nbsp; &nbsp;mylpwavehdr:pwavehdr;<br>&nbsp; &nbsp;wresult:double;<br>&nbsp; &nbsp;tt:longint;<br>begin<br><br>&nbsp; //open the given file for reading using buffered i/o /<br>&nbsp; &nbsp;iomm:=mmioopen('son1.wav',nil,MMIO_READ or MMIO_ALLOCBUF);<br><br>&nbsp; &nbsp;{locate a 'RIFF' chunk with a 'wave' form type,tomake sure it's a WAVE file}<br>&nbsp; // mmckinfoparent.fccType := mmioFOURCC('w','a','v','e');<br>&nbsp; &nbsp;mmiodescend(iomm,@mmckinfoparent,nil,MMIO_FINDRIFF);<br><br>&nbsp; &nbsp;{find the format chunk(form type 'fmt'),it's should be a subchunk of the 'RIFF' parent chunk}<br>&nbsp;// &nbsp;mmckinfosubchunk.ckid :=mmiofourcc('f','m','t','');<br>&nbsp; &nbsp;mmiodescend(iomm,@mmckinfosubchunk,@mmckinfoparent,MMIO_FINDCHUNK);<br><br>&nbsp; { get the size of the formt chunk,allocate and lock memory for }<br>&nbsp; dwfmtsize:=mmckinfosubchunk.cksize;<br><br>&nbsp; {read the format chunk}<br>&nbsp; tt:= mmioread(iomm,@pformat,dwfmtsize) ;<br>&nbsp; deviceid:=waveOutGetNumDevs;<br>&nbsp; if tt=-1 then<br>&nbsp; {make sure a waveform output device support this format}<br>&nbsp; waveoutgetdevcaps(deviceid,@caps,sizeof(caps)) ;<br>&nbsp;if &nbsp;waveoutopen(@mywaveout,deviceid,@pformat,0,0,WAVE_FORMAT_QUERY)=0 then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; showmessage('can not open');<br>&nbsp; &nbsp; end;<br><br>&nbsp; {ascend out of the format subchunk}<br>&nbsp; mmioascend(iomm,@mmckinfosubchunk,0);<br><br>&nbsp; {find the data subchunk}<br>&nbsp;// mmckinfosubchunk.ckid :=mmiofourcc('d','a','t','a');<br>&nbsp; mmiodescend(iomm,@mmckinfosubchunk,@mmckinfoparent,MMIO_FINDCHUNK);<br><br>&nbsp;{get the size of the data subchunk}<br>&nbsp; dwdatasize:=mmckinfosubchunk.cksize;<br>&nbsp; waveoutopen(@mywaveout,deviceid,@pformat,0,hinstance,CALLBACK_FUNCTION);<br><br>&nbsp;{allocate and lock memory for the header}<br>&nbsp; lpdata:=globalalloc(GMEM_MOVEABLE or GMEM_SHARE,sizeof(dwdatasize));<br><br>&nbsp; mmioread(iomm,@lpdata,dwdatasize);<br><br>&nbsp; hwavehdr:=Globalalloc(GMEM_MOVEable or GMEM_SHARE,sizeof(wavehdr) );<br>&nbsp; mylpwavehdr:=Globallock(hwavehdr) ;<br><br>&nbsp; mylpwavehdr^.lpData :=@lpdata;<br>&nbsp; mylpwavehdr^.dwBufferLength :=dwdatasize;<br>&nbsp; mylpwavehdr^.dwFlags :=0;<br>&nbsp; mylpwavehdr^.dwLoops :=0;<br>&nbsp; mylpwavehdr^.dwuser:=0;<br>&nbsp; waveoutprepareheader(mywaveout,mylpwavehdr,sizeof(wavehdr));<br><br>&nbsp; wresult:=waveoutwrite(mywaveout,mylpwavehdr,sizeof(wavehdr));<br>&nbsp; if wresult=0 then<br>&nbsp; &nbsp; &nbsp;showmessage('faild!');<br><br>end;<br><br>end.
 
@!@<br>http://www.gislab.ecnu.edu.cn/delphibbs/DispQ.asp?LID=60617
 
以前讨论过,不过好象没有结果。
 
kucio<br>&nbsp; &nbsp; &nbsp;你好,该问题是有结果的,不过要请高手帮忙!!!<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;redweek &nbsp; 00-05-08 !
 
附加功能 &nbsp; 将问题提前 &nbsp; &nbsp;
 
redweek:如果还想接着讨论请定期提前自己的帖子,如果不想继续讨论请结束帖子。<br>
 
老猫是好人
 
看hubdog的文章<br>http://www.csdn.net/develop/read_article.asp?id=1764<br>http://www.csdn.net/develop/read_article.asp?id=1895
 
redweek:如果还想接着讨论请定期提前自己的帖子,如果不想继续讨论请结束帖子。<br><br>
 
要支持语音的猫然后用命令就可以实现了
 
用语音卡可以很轻松实现,但语音卡比较贵。
 
问题很棘手吗!
 
这帖子快一年了?
 
不过确实有意义。值得讨论,虽然我不研究这个方向,但是还想知道答案。[:)]
 
提前一下。[:)]
 
来自http://wenjinshan.yeah.net或wenjinshan.mycool.net的<br>《Delphi串口及语音传真编程》已出版
 
多人接受答案了。
 
顶部