Jump to content
  • Advertisement
Sign in to follow this  
Shadowflare

DirectAudio Problem

This topic is 4811 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
Advertisement
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;
WCHAR wFile[_MAX_PATH];
lpSEGMENT lpSeg = NULL;
DMUS_OBJECTDESC ObjDesc;
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
MULTI_TO_WIDE(FileName,wFile);


//setup DMUS object description
INIT_DXSTRUCT(ObjDesc);
ObjDesc.dwValidData = DMUS_OBJ_FILENAME | DMUS_OBJ_CLASS;
ObjDesc.guidClass = CLSID_DirectMusicSegment;
ObjDesc.pStream = NULL;
wcscpy(ObjDesc.wszFileName,wFile);

//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);
if(FAILED(hResult))
{
DA.LogError(hResult,"DA Loader Result",__FILE__,__LINE__);
return(NULL);
}

//load the segment
//if(FAILED(DA.lpLoader->LoadObjectFromFile(CLSID_DirectMusicSegment,IID_IDirectMusicSegment8,wFile,(LPVOID*)&lpSeg)))
// {return(NULL);}



//if an audiopath is supplied download
//the instrument(s) from the file.
if(AudioPath)
{
if(FAILED(lpSeg->Download(AudioPath)))
{return(NULL);}
}


return(lpSeg);
}



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  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!