Null reference while playing with XATC and background music
by Stefan Sierder · in Torque X 2D · 08/21/2010 (9:23 am) · 3 replies
Hello community,
Situation:
I am trying to get a nice 8bit music track to run when the game starts.
Problem:
I get a "null reference" for my "Sound Bank" and "Wave Bank" objects.
What have i done:
* converted an 8bit 44000Mhz MP3 to .wav
* loaded the file in the XATC Wave Bank
* droped the WAV from Wave Bank to Sound Bank so i have a "Cue Name"
* saved and builded the XATC project
* copied the 3 created files over to my data/music/ folder inside my project
Then i activated TX2d sound in torqueSettings.xml:
And this is my code to call the soundfile:
While debugging i noticed, that "Sound Bank" and "Wave Bank" inside "SoundGroup" are always null.
Can anybody point me to the right direction where to fix that?
My XATC project:

Situation:
I am trying to get a nice 8bit music track to run when the game starts.
Problem:
I get a "null reference" for my "Sound Bank" and "Wave Bank" objects.
What have i done:
* converted an 8bit 44000Mhz MP3 to .wav
* loaded the file in the XATC Wave Bank
* droped the WAV from Wave Bank to Sound Bank so i have a "Cue Name"
* saved and builded the XATC project
* copied the 3 created files over to my data/music/ folder inside my project
Then i activated TX2d sound in torqueSettings.xml:
<EnableAudio>true</EnableAudio> <AudioGlobalSettingsFile>data/music/testsound2.xgs</AudioGlobalSettingsFile>
And this is my code to call the soundfile:
protected override void BeginRun()
{
base.BeginRun();
SoundGroup = SoundManager.Instance.RegisterSoundGroup("Sounds", @"data/music/Wave Bank.xwb", @"data/music/Sound Bank.xsb");
MusicCue = SoundManager.Instance.PlaySound(@"data/music/Sound Bank.xsb", "tbdm");While debugging i noticed, that "Sound Bank" and "Wave Bank" inside "SoundGroup" are always null.
Can anybody point me to the right direction where to fix that?
My XATC project:

About the author
#2
thanks for your reply.
I think it is not an issue with my code as far as i can see... maybe
the wav file is not valid, although accepted by XATC.
I will dive again into this, but i see a huge demand for a more stable
and simple way to do this in TX.
08/24/2010 (11:14 am)
Hi!thanks for your reply.
I think it is not an issue with my code as far as i can see... maybe
the wav file is not valid, although accepted by XATC.
I will dive again into this, but i see a huge demand for a more stable
and simple way to do this in TX.
#3
After reading your post, I believe these steps will fix the problem.
1) When you open up XACT you should first do File->New Project and save this in your data/music folder.
2) Copy your .wav file(s) into this folder.
3) Load the .wav from the data/music folder
4) Do the steps you did to get the wav file into the cue
5) Build and Save.
6) Don't copy or move anything, everything is where it should be.
Send me an email if you still are having problems with this after trying this.
08/28/2010 (3:46 am)
Hi Stefan, XACT is actually the best way to do sound that I know of and very simple once you get it down. Believe me, I know how you feel :-) After reading your post, I believe these steps will fix the problem.
1) When you open up XACT you should first do File->New Project and save this in your data/music folder.
2) Copy your .wav file(s) into this folder.
3) Load the .wav from the data/music folder
4) Do the steps you did to get the wav file into the cue
5) Build and Save.
6) Don't copy or move anything, everything is where it should be.
Send me an email if you still are having problems with this after trying this.
Torque 3D Owner Henry Shilling
Smokin Skull
I do it like this:
these are globals:
this is in BeginRun:
// setup the sound, do not forget to set EnableAudio in torqueSettings.xml // also look at the AudioGlobalSettingsFile and set it accordingly // there are other ways to do this but I find this easy, and I am all about the easy. SoundGroup = SoundManager.Instance.RegisterSoundGroup("Sounds", @"data/sfx/Wave Bank.xwb", @"data/sfx/Sound Bank.xsb"); // I split my music and sound effects SFX into to categories AudioCategory _sfx = Game.Instance.Engine.SFXDevice.GetCategory("SFX"); _sfx.SetVolume(SFXVol); // This is Space Fighter Loop from http://incompetech.com AudioCategory _music = Game.Instance.Engine.SFXDevice.GetCategory("Music"); _music.SetVolume(MusicVol); // Play the music I like the music to start with the splash screens // if you do not put this line somewhere else whe you like it. // like in the main menu SoundGroup.PlaySound("musicLoop");Also assign your music to the music category and xact will automatically take care of custom soundtracks for you. You will not have to do anything.
There is a working example in the GameKit: www.torquepowered.com/community/resources/view/19137