Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


problem loading wav resource in DSound

This topic is 6266 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

There''s problem when I tried to load wave resource in DSound. I wrote the code according to the directx documentation: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dx8_c/hh/dx8_c/audio_using_9jxr.asp Here''s what I''ve written: ////////////////////////////////////////////////////////////// CWaveFile waveFile; if (FAILED(waveFile.Open("mywave", NULL, WAVEFILE_READ))) // where "mywave" is the name of wave resource file { waveFile.Close(); } LPDIRECTSOUNDBUFFER lpdsbStatic; DSBUFFERDESC dsbdesc; memset(&dsbdesc, 0, sizeof(DSBUFFERDESC)); dsbdesc.dwSize = sizeof(DSBUFFERDESC); dsbdesc.dwFlags = 0; dsbdesc.dwBufferBytes = waveFile.GetSize(); dsbdesc.lpwfxFormat = waveFile.m_pwfx; if FAILED(lpds->CreateSoundBuffer(&dsbdesc, &lpdsbStatic, NULL)) { // Error handling. } LPVOID lpvAudio1; DWORD dwBytes1; if FAILED(lpdsbStatic->Lock( 0, // Offset of lock start. 0, // Size of lock; ignored in this case. &lpvAudio1, // Address of lock start. &dwBytes1, // Number of bytes locked. NULL, // Wraparound start; not used. NULL, // Wraparound size; not used. DSBLOCK_ENTIREBUFFER)) { // Error handling. } DWORD dwBytesRead; waveFile.Read((BYTE*)lpvAudio1, dwBytes1, &dwBytesRead); lpdsbStatic->Unlock(lpvAudio1, dwBytes1, NULL, 0); waveFile.Close(); /////////////////////////////////////////////////////////////// The problem is that the resource "mywave" failed to open and cannot create the buffer.("mywave" was imported as type "WAVE" in the resource.rc) However, when I replace "mywave" with a file name, say "wave1.wav", the routine works properly. Can anyone tell me what''s going wrong? Thanks!!

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
You can use CMusicManager (find in DMUtil.cpp)

CMusicManager* g_pMusicManager = NULL;

g_pMusicManager = new CMusicManager();
if( FAILED( g_pMusicManager->Initialize( hWnd ) ) )
return E_FAIL;

g_pMusicManager->CreateSegmentFromResource(&g_pSound,_T("MYSOUND"), _T("WAV") );


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!