Game Development Community

Music Volume

by JohnT · in Torque X 2D · 06/25/2008 (8:36 am) · 1 replies

Anyone know how to adjust the volume of music playing during gameplay? I looked through the source and did not find anything. I even tried calling the XNA Audio engine directly like this:

AudioEngine myAudio = Game.Instance.Engine.SFXDevice;
AudioCategory myCategory = myAudio.GetCategory("Music");
myCategory.SetVolume(0.5f);
myAudio.Update();
Still no luck!

#1
06/26/2008 (7:43 am)
That looks like it should work ... I have something similar in my code.

_musicAudio = MyGame.Instance.Engine.SFXDevice.GetCategory("Music");
_musicAudio.SetVolume(value);

(with "AudioCategory _musicAudio;" and "value" a float between 0 an 1)

This only affects sounds in the music category. Double check in XACT that the sound you are trying to control is actually in the Music category.

Otherwise that's puzzling ...