使用waveOutWrite播放wave |
尚未結案
|
asd98537
一般會員 發表:27 回覆:25 積分:10 註冊:2002-10-23 發送簡訊給我 |
底下這段程式碼為什麼在console 下播放不出聲音,但是在BCB下卻可以?請問問題出在哪裡?謝謝
char* WaveData; WAVEFORMATEX WaveFmt; HWAVEOUT WaveHandle; int DataSize; WAVEHDR WaveHeader; MMCKINFO ChunkInfo; MMCKINFO FormatChunkInfo; MMCKINFO DataChunkInfo; // Zero out the ChunkInfo structure. memset(&ChunkInfo, 0, sizeof(MMCKINFO)); // Open the file. HMMIO handle = mmioOpen( "C:\\MYLIBR~1\\CSPBUF\\ex\\mic.wav", 0, MMIO_READ); // Find the RIFF chunk. DWORD Res = mmioDescend(handle, &ChunkInfo, 0, MMIO_FINDRIFF); // Descend into the format chunk. FormatChunkInfo.ckid = mmioStringToFOURCC("fmt", 0); Res = mmioDescend(handle, &FormatChunkInfo, &ChunkInfo, MMIO_FINDCHUNK); // Read the wave format. memset(&WaveFmt, 0, sizeof(WAVEFORMATEX)); // mmioRead and mmioWrite return the number of // bytes read or written so don't call the // CheckMMIOError fucntion for those. mmioRead(handle, (char*)&WaveFmt, FormatChunkInfo.cksize); // Ascend out of the format chunk. Res = mmioAscend(handle, &FormatChunkInfo, 0); // Descend into the data chunk. DataChunkInfo.ckid = mmioStringToFOURCC("data", 0); Res = mmioDescend(handle, &DataChunkInfo, &ChunkInfo, MMIO_FINDCHUNK); // Read the data into a buffer. DataSize = DataChunkInfo.cksize; // if (WaveData) // delete[] WaveData; WaveData = new char[DataSize]; mmioRead(handle, WaveData, DataSize); Res = waveOutOpen(&WaveHandle, WAVE_MAPPER, &WaveFmt, 0, 0, WAVE_FORMAT_QUERY); Res = waveOutOpen(&WaveHandle, WAVE_MAPPER, &WaveFmt,NULL,NULL, CALLBACK_NULL); // Set up the wave header. memset(&WaveHeader, 0, sizeof(WaveHeader)); WaveHeader.lpData = WaveData; WaveHeader.dwBufferLength = DataSize; // If the LoopEdit contains a value greater // than 1 then set the loop count and flags. // Prepare the wave header. Res = waveOutPrepareHeader(WaveHandle, &WaveHeader, sizeof(WAVEHDR)); // Start playback. Res = waveOutWrite(WaveHandle, &WaveHeader, sizeof(WAVEHDR)); |
asd98537
一般會員 發表:27 回覆:25 積分:10 註冊:2002-10-23 發送簡訊給我 |
|
anpino
版主 發表:31 回覆:477 積分:231 註冊:2003-01-02 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |