Sign in to follow this  

DirectAudio Problem

This topic is 4482 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

My code works fine up until I try to download the audio band to the performance object. Here is the essential code in my LoadSound function:
HRESULT LoadSound(LPCTSTR szFilename)
     WCHAR wszFilename[256];
     MultiByteToWideChar(CP_ACP, 0, szFilename, -1, wszFilename, 256);

     m_pDMLoader->LoadObjectFromFile(CLSID_DirectMusicSegment, IID_IDirectMusicSegment8, wszFilename, (void **)m_pDMSegment[m_iLoadedSegments]);

     m_pDMSegment[m_iLoadedSegments]->Download(m_pDMPerformance); // ERROR

     return S_OK;


m_pDMSegment is an array of audio segments, and m_iLoadedSegment is 0, since I can't get any files to load :P When I try to call Download() I get an unhandled exception. Anyone have any ideas? Thanks!

Share this post

Link to post
Share on other sites
Aye, they are valid. I just removed my error checking code to simplify things. Everything runs OK until the Download() call.

Share this post

Link to post
Share on other sites
Hmmm. As soon as I finish re-formating my other PC's hard-drive and get the old DirectX SDK's installed. I'll take a look into it. In the mean time, here is the code I used.

lpSEGMENT LoadSegment(LPCTSTR FileName,IUnknown *AudioPath)
STRING strFileName;
HRESULT hResult;

//copy to temp STRING object
strFileName = FileName;

//DM uses wide strings, so
//the parameter passed must be
//converted with this handy
//little macro

//setup DMUS object description
ObjDesc.guidClass = CLSID_DirectMusicSegment;
ObjDesc.pStream = NULL;

//check for presence of full-path by searching for a colon in the file name
if(strFileName.Find(':') != -1) {ObjDesc.dwValidData |= DMUS_OBJ_FULLPATH;}

//obtain the object from a file
hResult = DA.lpLoader->GetObject(&ObjDesc,IID_IDirectMusicSegment8,(void**)&lpSeg);
DA.LogError(hResult,"DA Loader Result",__FILE__,__LINE__);

//load the segment
// {return(NULL);}

//if an audiopath is supplied download
//the instrument(s) from the file.


I updated it at some point to manually load the object. Can't for the life of me remember why though. Just so you know: There is some code in there that checks for a colon in the file name to determine whether or not the loader is checking a full-path name or a relative-path name. I used a custom-made STRING class to do this.

Share this post

Link to post
Share on other sites
Sign in to follow this