Skip to main content
GameDev.net gamedev.net
🔒 Locked

DirectAudio Problem

Started by Shadowflare Oct 10, 2005 at 6:46 PM 3 replies 550+ views
Original Post
Shadowflare
Shadowflare
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!
lack o comments
lack o comments
Are you checking those return values? ;) Make sure you're segment and performance objects are valid.
Shadowflare
Shadowflare
Aye, they are valid. I just removed my error checking code to simplify things. Everything runs OK until the Download() call.
lack o comments
lack o comments
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.
lack o comments
lack o comments
Ah, just thought of something. Are you creating your performance object with a default audio-path?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.