XACT variables

Started by
-1 comments, last by treeway 15 years, 12 months ago
Hi Im trying to set variables in XACT from within my program, i.e. I want the speed of my engine sound to be affected by the ammount of accelleration coming from input. I've created an XACT engine which can play sounds but cannot access the global variables set:

//////////////////////////////////////////////////////////////////////////////////////
/// Initialises the class instance.
/// @return TRUE on success, FALSE on fail.
//////////////////////////////////////////////////////////////////////////////////////
BOOL CGE_XACT::initialise()
{

	CoInitializeEx(NULL, COINIT_MULTITHREADED);

	HRESULT hr;

	if(FAILED(hr = XACTCreateEngine(0,&pEngine)))
	{
		::MessageBox(0,"Failed to Create XACTEngine","CGE_XACT::initialise()",0);
		return FALSE;
	}

	XACT_RENDERER_DETAILS rendererDetails;
	if(FAILED(hr=pEngine->GetRendererDetails(0,&rendererDetails)))
	{
		::MessageBox(0,"Failed to get Sound Card render details","CGE_XACT::initialise()",0);
		return FALSE;
	}

	XACT_RUNTIME_PARAMETERS params;
	memset(&params,0,sizeof(XACT_RUNTIME_PARAMETERS));
	params.lookAheadTime = XACT_ENGINE_LOOKAHEAD_DEFAULT;
	params.pRendererID = rendererDetails.rendererID;

	if(FAILED(hr=pEngine->Initialize(&params)))
	{
		::MessageBox(0,"Failed to Initialize XACT Engine","CGE_XACT::initialise()",0);
		return FALSE;
	}
	
	return TRUE;
}


this works fine for playing sounds but when I try to set a variable, I get the following debug warning:

[XACT] [XACT::CEngine::GetGlobalVariableIndex] [time 10:40:19.790] Error: There are no global settings loaded

every time I try to access the "SpeedOfSound" global variable with

XACTVARIABLEINDEX i = XActSound.pEngine->GetGlobalVariableIndex("SpeedOfSound");

I know that the global variables haven't been loaded becasue the XACT_RUNTIME_PARAMETERS params; struct which is passed into the XACT engines initialize function does not contain any data about the global variables. The XACT_RUNTIME_PARAMETERS struct is described here where the three members: void *pGlobalSettingsBuffer; DWORD globalSettingsBufferSize; DWORD globalSettingsFlags; DWORD globalSettingsAllocAttributes; are described very loosley. I have noticed that the XACT Global Settings are stored in an .xgs file along with the sound bank, so I read this file into a string and tryed passing that into the pGlobalSettingsBuffer member using the following:

//////////////////////////////////////////////////////////////////////////////////////
/// Initialises the class instance.
/// @return TRUE on success, FALSE on fail.
//////////////////////////////////////////////////////////////////////////////////////
BOOL CGE_XACT::initialise()
{

	CoInitializeEx(NULL, COINIT_MULTITHREADED);

	HRESULT hr;

	if(FAILED(hr = XACTCreateEngine(0,&pEngine)))
	{
		::MessageBox(0,"Failed to Create XACTEngine","CGE_XACT::initialise()",0);
		return FALSE;
	}

	XACT_RENDERER_DETAILS rendererDetails;
	if(FAILED(hr=pEngine->GetRendererDetails(0,&rendererDetails)))
	{
		::MessageBox(0,"Failed to get Sound Card render details","CGE_XACT::initialise()",0);
		return FALSE;
	}

	fstream oFile;
	oFile.open("C:\\Users\\David J Beirne\\Desktop\\Cyclone9\\Cyclone\\Racer\\Media\\Sounds\\Win\\mySoundLibrary.xgs",ifstream::in);

	// Check that we opened the file okay
	if(!oFile.is_open())
	{
		::MessageBox(0,"Error - Cannot open file.","CGE_XACT::initialise()",0);
	}

	if(!oFile.good())
	{
		::MessageBox(0,"Error - File is corrupt!","CGE_XACT::initialise()",0);
	}

	string pData;
	while(!oFile.eof())
	{
		oFile >> pData;
	}
	oFile.close();


	XACT_RUNTIME_PARAMETERS params;
	memset(&params,0,sizeof(XACT_RUNTIME_PARAMETERS));
	params.lookAheadTime = XACT_ENGINE_LOOKAHEAD_DEFAULT;
	params.pRendererID = rendererDetails.rendererID;
	params.globalSettingsBufferSize = pData.size();
	params.pGlobalSettingsBuffer = (void*)pData.c_str();

	if(FAILED(hr=pEngine->Initialize(&params)))
	{
		::MessageBox(0,"Failed to Initialize XACT Engine","CGE_XACT::initialise()",0);
		return FALSE;
	}
	
	return TRUE;
}


but the pEngine->Initialize(&params) call returns an E_FAIL. Sorry this post was so long. has anyone managed to access the variables in an XACT file? and if so what is passed into the initialise parameters of the XACT engine?

This topic is closed to new replies.

Advertisement