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);
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);