waveOutWrite 實現重複播放
- SetWaveFormat
tWaveFmt.wFormatTag = WAVE_FORMAT_PCM; tWaveFmt.nChannels = 1; tWaveFmt.nSamplesPerSec = SAMPLERATE; tWaveFmt.nAvgBytesPerSec = sizeof(short) * SAMPLERATE; tWaveFmt.nBlockAlign = sizeof(short) ; tWaveFmt.wBitsPerSample = 2 <<3; tWaveFmt.cbSize = 0;
- Prepare wave header
tWaveHdrP.lpData = (LPSTR) (pcWavBuff); tWaveHdrP.dwBufferLength = dSize; tWaveHdrP.dwFlags = WHDR_BEGINLOOP | WHDR_ENDLOOP; //重複播放必要的flag tWaveHdrP.dwLoops = 100L; // 重複播放幾次
- Open wave out device and play
goto err_out; if (waveOutPrepareHeader(hWaveOutP, &WaveHdrP, sizeof(WAVEHDR))) goto err_out; if (waveOutWrite(hWaveOutP, &WaveHdrP, sizeof(WAVEHDR))) goto err_out;