Sign in to follow this  
DarioMicera

[DirectX][XACT] No global settings have been loaded

Recommended Posts

Hi, it's me again.

I've managed to successfully use the XACT API to play sounds/music for my game. I was not happy with the volume of the background music, so i tryed to use the SetVolume Method. This is my code

[code]

CoInitializeEx(NULL,COINIT_MULTITHREADED);
if(FAILED(XACT3CreateEngine(0,&audio)))
return -1;

VOID* pGlobalSettingsData = NULL;
DWORD dwGlobalSettingsFileSize = 0;
DWORD dwBytesRead;
HANDLE fil=CreateFile("soundtrack.xgs",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
dwGlobalSettingsFileSize=GetFileSize(fil,NULL);
if( dwGlobalSettingsFileSize != INVALID_FILE_SIZE )
{
pGlobalSettingsData = CoTaskMemAlloc(dwGlobalSettingsFileSize);
if( pGlobalSettingsData )
{
ReadFile(fil, pGlobalSettingsData, dwGlobalSettingsFileSize, &dwBytesRead, NULL) )

}
}
CloseHandle(fil);
if( pGlobalSettingsData )
CoTaskMemFree(pGlobalSettingsData);
pGlobalSettingsData = NULL;
dwGlobalSettingsFileSize = 0;

XACT_RUNTIME_PARAMETERS EngineParameters={0};

EngineParameters.pGlobalSettingsBuffer = pGlobalSettingsData;
EngineParameters.globalSettingsBufferSize = dwGlobalSettingsFileSize;
EngineParameters.globalSettingsFlags = XACT_FLAG_GLOBAL_SETTINGS_MANAGEDATA;

audio->Initialize(&EngineParameters);


HANDLE hFile=CreateFile("WaveBank.xwb",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
if(hFile==INVALID_HANDLE_VALUE)
return -2;
DWORD FileSize=GetFileSize(hFile,NULL);
if(FileSize==-1)
return -3;

HANDLE MapFile= CreateFileMapping(hFile,NULL,PAGE_READONLY,0,FileSize,NULL);
if(!MapFile)
return -4;
waveBankMapping=MapViewOfFile(MapFile,FILE_MAP_READ,0,0,0);
if(!waveBankMapping)
return -5;

audio->CreateInMemoryWaveBank(waveBankMapping,FileSize,0,0,&waveBank);
CloseHandle(MapFile);
CloseHandle(hFile);

HANDLE File=CreateFile("SoundBank.xsb",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
DWORD hFileSize=GetFileSize(File,NULL);
soundBankMemory=new BYTE[hFileSize];
DWORD bytesRead;

if(ReadFile(File,soundBankMemory,hFileSize,&bytesRead,NULL)!=0)
audio->CreateSoundBank(soundBankMemory,hFileSize,0,0,&soundBank);
CloseHandle(File);

XACTINDEX cueIndex=soundBank->GetCueIndex("Soundtrack");
XACTINDEX cueIndex1=soundBank->GetCueIndex("Laser");
XACTCATEGORY category=audio->GetCategory("Soundtrack");
audio->SetVolume(category,0.0f);[/code]


This is the code regarding the XACT initialization and setup that is currently situated in my main (the play methods are in the game loop). The sound keeps playing normally, but it's uneffected by the SetVolume.

My problem seems to be the error like this "[XACT][SetVolume] no global settings have been loaded" that is displayed in my debug. By checking if the call of the SetVolume was actually successful, i've noticed that it was not.

Also from the error, i've supposed it was a problem with initialization and the xgs file that contains the settings, but none of the methods fails.

Any thoughts?

Searched on the web but found no specific answer.

Thanks in advance.

Regards [img]http://public.gamedev.net/public/style_emoticons/default/smile.gif[/img]

Share this post


Link to post
Share on other sites
[font=arial, verdana, tahoma, sans-serif][size=2]k got an update:

Tried to use XACTENGINE_E_NOGLOBALSETTINGS error to verify if my global settings were loaded.

The result: they are not!

So the problem now is:

How do i load XACT global settings (since i seem to have not done it in the right way) ?

Your help it's still welcome :P

Thanks in advance[/size][/font]

Share this post


Link to post
Share on other sites
It's been a while since I've messed with XACT, but IIRC you're going to need to set up a category or variable in the XACT GUI to handle that. Googling for "XACT3 dynamic sound" provided some promising-looking results. I don't have access to my pc at the moment, so I can't check how I handled it.

Share this post


Link to post
Share on other sites
[quote name='yckx' timestamp='1312853974' post='4846478']
It's been a while since I've messed with XACT, but IIRC you're going to need to set up a category or variable in the XACT GUI to handle that. Googling for "XACT3 dynamic sound" provided some promising-looking results. I don't have access to my pc at the moment, so I can't check how I handled it.
[/quote]

Thanks for the answer :D


I've tried to create and manage the volume with a category/global variable but i still get the same result (the above error). Will try to follow your direction and seek for a solution. Will edit if i will find what i need

Thanks :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this