///////////////////////////////////////////////////////////////////////////// // DSUtil.h: helper functions for .WAV format resources. /////////////////////////////////////////////////////////////////////////////// // // DSLoadSoundBuffer Loads an IDirectSoundBuffer from a Win32 resource in // the current application. // // Params: // pDS -- Pointer to an IDirectSound that will be used to create // the buffer. // // lpName -- Name of WAV resource to load the data from. Can be a // resource id specified using the MAKEINTRESOURCE macro. // // Returns an IDirectSoundBuffer containing the wave data or NULL on error. // // example: // in the application's resource script (.RC file) // Turtle WAV turtle.wav // // some code in the application: // IDirectSoundBuffer *pDSB = DSLoadSoundBuffer(pDS, "Turtle"); // // if (pDSB) // { // IDirectSoundBuffer_Play(pDSB, 0, 0, DSBPLAY_TOEND); // /* ... */ // /////////////////////////////////////////////////////////////////////////////// IDirectSoundBuffer *DSLoadSoundBuffer(IDirectSound *pDS, LPCTSTR lpName); /////////////////////////////////////////////////////////////////////////////// // // DSReloadSoundBuffer Reloads an IDirectSoundBuffer from a Win32 resource in // the current application. normally used to handle // a DSERR_BUFFERLOST error. // Params: // pDSB -- Pointer to an IDirectSoundBuffer to be reloaded. // // lpName -- Name of WAV resource to load the data from. Can be a // resource id specified using the MAKEINTRESOURCE macro. // // Returns a BOOL indicating whether the buffer was successfully reloaded. // // example: // in the application's resource script (.RC file) // Turtle WAV turtle.wav // // some code in the application: // TryAgain: // HRESULT hres = IDirectSoundBuffer_Play(pDSB, 0, 0, DSBPLAY_TOEND); // // if (FAILED(hres)) // { // if ((hres == DSERR_BUFFERLOST) && // DSReloadSoundBuffer(pDSB, "Turtle")) // { // goto TryAgain; // } // /* deal with other errors... */ // } // /////////////////////////////////////////////////////////////////////////////// BOOL DSReloadSoundBuffer(IDirectSoundBuffer *pDSB, LPCTSTR lpName); /////////////////////////////////////////////////////////////////////////////// // // DSGetWaveResource Finds a WAV resource in a Win32 module. // // Params: // hModule -- Win32 module handle of module containing WAV resource. // Pass NULL to indicate current application. // // lpName -- Name of WAV resource to load the data from. Can be a // resource id specified using the MAKEINTRESOURCE macro. // // ppWaveHeader-- Optional pointer to WAVEFORMATEX * to receive a pointer to // the WAVEFORMATEX header in the specified WAV resource. // Pass NULL if not required. // // ppbWaveData -- Optional pointer to BYTE * to receive a pointer to the // waveform data in the specified WAV resource. Pass NULL if // not required. // // pdwWaveSize -- Optional pointer to DWORD to receive the size of the // waveform data in the specified WAV resource. Pass NULL if // not required. // // Returns a BOOL indicating whether a valid WAV resource was found. // /////////////////////////////////////////////////////////////////////////////// BOOL DSGetWaveResource(HMODULE hModule, LPCTSTR lpName, WAVEFORMATEX **ppWaveHeader, BYTE **ppbWaveData, DWORD *pdwWaveSize); /////////////////////////////////////////////////////////////////////////////// // // helper routines // /////////////////////////////////////////////////////////////////////////////// BOOL DSFillSoundBuffer(IDirectSoundBuffer *pDSB, BYTE *pbWaveData, DWORD dwWaveSize); BOOL DSParseWaveResource(void *pvRes, WAVEFORMATEX **ppWaveHeader, BYTE **ppbWaveData, DWORD *pdwWaveSize);