• ### Popular Now

• 14
• 12
• 9
• 10
• 13

#### Archived

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

# DirectX 8 Audio question

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

## Recommended Posts

Hi, I''m trying to load a .wav file using directx 8. Now I guess the new way to do it with directx 8 is to load a .wav file as a IDirectMusicSegment8 and play it the same way as a midi. But the problem I have is that since my .wav files are stored in my own file structure, I can''t just give directx 8 my filename. See, I can load a .wav file correctly if I do it the normal way, like this: gLoader->LoadObjectFromFile(CLSID_DirectMusicSegment, IID_IDirectMusicSegment8, wstrFileName, (LPVOID*)&segment); But like I said before, I have to load it into memory first, and that way doesn''t work for some reason: DMUS_OBJECTDESC object; memset(&object, 0, sizeof(DMUS_OBJECTDESC)); object.dwSize = sizeof(DMUS_OBJECTDESC); object.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_NAME | DMUS_OBJ_MEMORY; object.guidClass = CLSID_DirectMusicSegment; MultiByteToWideChar(CP_ACP, 0, filename, -1, object.wszName, DMUS_MAX_NAME); // I fill object.llMemLength and object.pbMemData here gLoader->GetObject(&object, IID_IDirectMusicSegment8, (LPVOID*)&segment); When I do it that way, the program crashes at GetObject. I know that llMemLength and pbMemData have been filled correctly, because I used the same method I used for .mid files and that worked. Either this is a bug in directx8 or the LoadObjectFromFile function does something extra that I don''t know about. Anyone have any ideas? Thanks for reading -------Blah

##### Share on other sites
from msdn tutorials:
  CHAR strPath[MAX_PATH]; GetWindowsDirectory( strPath, MAX_PATH ); strcat( strPath, "\\media" ); // Convert to Unicode. WCHAR wstrSearchPath[MAX_PATH]; MultiByteToWideChar( CP_ACP, 0, strPath, -1, wstrSearchPath, MAX_PATH ); // Set the search directory. g_pLoader->SetSearchDirectory( GUID_DirectMusicAllTypes, // Types of files sought. wstrSearchPath, // Where to look. FALSE // Don''t clear object data. ); if (FAILED(g_pLoader->LoadObjectFromFile( CLSID_DirectMusicSegment, // Class identifier. IID_IDirectMusicSegment8, // ID of desired interface. file, // filename must be in format L"Filename.wav" (LPVOID*) &g_pSegment // Pointer that receives interface. ))) { MessageBox( NULL, "Media not found, sample will now quit.", "DirectAudio", MB_OK ); return 0; }

HHSDrum@yahoo.com

##### Share on other sites
I know, I can make the program work with the
''LoadObjectFromFile'' function. But my .wavs are in a
custom data structure, like quake''s .pak structure. So
I have to load the file myself and then load it into
directx from memory. But I can''t get that method to work.

------Blah