读取WAV文件到内存中播放不出声,请高手指教。谢谢! ( 积分: 100 )

  • 主题发起人 主题发起人 crhallan
  • 开始时间 开始时间
C

crhallan

Unregistered / Unconfirmed
GUEST, unregistred user!
我读取一个WAV文件到内存里,用WaveOutWrite就是放不出来,请高手指教。代码如下:

Fname := 'c:/11.wav';
f := TFileStream.Create(Fname,fmopenread);
f.ReadBuffer(Buf,BufferSize);

WAVEFORMATEX.wFormatTag := WAVE_FORMAT_PCM;
WAVEFORMATEX.nChannels := 1;
WAVEFORMATEX.nSamplesPerSec := 8000;
WAVEFORMATEX.nAvgBytesPerSec := 8000;
WAVEFORMATEX.wBitsPerSample := 0;
WAVEFORMATEX.cbSize := 0;

WaveOutOpen(@WaveOut,WAVE_MAPPER,@WAVEFORMATEX, 0, 0, CALLBACK_NULL );
WaveHead.lpData := @buf;
WaveHead.dwBufferLength := BufferSize;
WaveHead.dwBytesRecorded := 0;
WaveHead.dwFlags := WHDR_begin
LOOP OR WHDR_ENDLOOP;
WaveHead.dwLoops := 0;
WaveHead.dwUser := 0;
WaveHead.lpNext := nil;
WaveHead.reserved := 0;
WaveOutPrepareHeader(WaveOut,@WaveHead,sizeof(WaveHead));
waveOutWrite(WaveOut,@WaveHead,sizeof(WaveHead));
WaveOutUnPrepareHeader(WaveOut,@WaveHead,sizeof(WaveHead));
WaveOutClose(WaveOut);
 
回调函数都没有,放什么。
 
我添加了回调函数
Procedure WaveOutProc(hwo:HWAVEOUT;
uMsg,dwInstance,dwParam1,dwParam2:DWORD);StdCall;
并且把WAVEOUTOPEN改为 WaveOutOpen(@WaveOut,WAVE_MAPPER,@WAVEFORMATEX, Cardinal(@WaveOutProc), 0, CALLBACK_FUNCTION);

貌似还发不出声音啊,高手帮忙指教,不胜感激!!!
 
后退
顶部