user-0 提问: 声卡放音

回复:
user: user-1
content: MSDN98_1.ISO http://pan.baidu.com/s/1dDF41ix,  MSDN98_2.ISO http://pan.baidu.com/s/1bnGo0Vl 先下载安装MSDN98 再参考： MSDN98\SAMPLES\VC98\SDK\GRAPHICS\AUDIO\REVERSE\REVERSE.C MSDN98\SAMPLES\VC98\SDK\GRAPHICS\VIDEO\AVIEDIT\AUDIO.C MSDN98\SAMPLES\VC98\SDK\GRAPHICS\VIDEO\AVIVIEW\AUDPLAY.C MSDN98\SAMPLES\MSDN\TECHART\2899\SRC\WAVEODEV.CPP MSDN98\SAMPLES\MSDN\TECHART\3014\SRC\WAVEODEV.CPP MSDN98\SAMPLES\MSDN\TECHART\3015\SRC\WAVEODEV.CPP MSDN98\SAMPLES\MSDN\TECHART\3215\SRC\WAVEODEV.CPP MSDN98\SAMPLES\MSDN\TECHART\3228\SRC\WAVEODEV.CPP MSDN98\SAMPLES\MSDN\TECHART\4245\SRC\WAVEODEV.CPP MSDN98\SAMPLES\MSDN\TECHART\4246\SRC\WAVEODEV.CPP MSDN98\SAMPLES\MSDN\TECHART\4247\SRC\WAVEODEV.CPP

user: user-1
content: 使用BASS库？ 或者参考MSDN里面的： Example of Writing Waveform Data The following example illustrates the steps required to allocate and set up a WAVEHDR structure and write a block of data to a waveform output device.   // Global variables.   HANDLE hData  = NULL;  // handle of waveform data memory  HPSTR  lpData = NULL;  // pointer to waveform data memory    void WriteWaveData(void)  {      HWAVEOUT    hWaveOut;      HGLOBAL     hWaveHdr;      LPWAVEHDR   lpWaveHdr;      HMMIO       hmmio;      UINT        wResult;      HANDLE      hFormat;      WAVEFORMAT  *pFormat;      DWORD       dwDataSize;       // Open a waveform device for output using window callback.       if (waveOutOpen((LPHWAVEOUT)&hWaveOut, WAVE_MAPPER,                      (LPWAVEFORMAT)pFormat,                      (LONG)hwndApp, 0L, CALLBACK_WINDOW))      {          MessageBox(hwndApp,                     "Failed to open waveform output device.",                     NULL, MB_OK | MB_ICONEXCLAMATION);          LocalUnlock(hFormat);          LocalFree(hFormat);          mmioClose(hmmio, 0);          return;      }        // Allocate and lock memory for the waveform data.        hData = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, dwDataSize );      if (!hData)      {          MessageBox(hwndApp, "Out of memory.",                     NULL, MB_OK | MB_ICONEXCLAMATION);          mmioClose(hmmio, 0);          return;      }      if ((lpData = GlobalLock(hData)) == NULL)      {          MessageBox(hwndApp, "Failed to lock memory for data chunk.",                     NULL, MB_OK | MB_ICONEXCLAMATION);          GlobalFree(hData);          mmioClose(hmmio, 0);          return;      }        // Read the waveform data subchunk.        if(mmioRead(hmmio, (HPSTR) lpData, dwDataSize) != (LRESULT)dwDataSize)      {          MessageBox(hwndApp, "Failed to read data chunk.",                     NULL, MB_OK | MB_ICONEXCLAMATION);          GlobalUnlock(hData);          GlobalFree(hData);          mmioClose(hmmio, 0);          return;      }        // Allocate and lock memory for the header.       hWaveHdr = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE,          (DWORD) sizeof(WAVEHDR));      if (hWaveHdr == NULL)      {          GlobalUnlock(hData);          GlobalFree(hData);          MessageBox(hwndApp, "Not enough memory for header.",              NULL, MB_OK | MB_ICONEXCLAMATION);          return;      }        lpWaveHdr = (LPWAVEHDR) GlobalLock(hWaveHdr);      if (lpWaveHdr == NULL)      {          GlobalUnlock(hData);          GlobalFree(hData);          MessageBox(hwndApp,              "Failed to lock memory for header.",              NULL, MB_OK | MB_ICONEXCLAMATION);          return;      }        // After allocation, set up and prepare header.        lpWaveHdr->lpData = lpData;      lpWaveHdr->dwBufferLength = dwDataSize;      lpWaveHdr->dwFlags = 0L;      lpWaveHdr->dwLoops = 0L;      waveOutPrepareHeader(hWaveOut, lpWaveHdr, sizeof(WAVEHDR));        // Now the data block can be sent to the output device. The      // waveOutWrite function returns immediately and waveform      // data is sent to the output device in the background.        wResult = waveOutWrite(hWaveOut, lpWaveHdr, sizeof(WAVEHDR));      if (wResult != 0)      {          waveOutUnprepareHeader(hWaveOut, lpWaveHdr,                                 sizeof(WAVEHDR));          GlobalUnlock( hData);          GlobalFree(hData);          MessageBox(hwndApp, "Failed to write block to device",                     NULL, MB_OK | MB_ICONEXCLAMATION);          return;      }  }