Game Development Community

Turn music completely off?

by amaranthia · in Torque Game Builder · 05/16/2008 (2:51 pm) · 5 replies

Okay, this is my last question about TGB 1.7. Is there a command that lets you turn music off completely? so that it won't be triggered anywhere in the game? I could put hooks everywhere, but it would be much nicer not to...

#1
05/16/2008 (3:06 pm)
You should make a wrapper function. Something like this:

function playSound(%mySound)
{
    if (!isObject(%mySound))
    {
        warn ("playSound - Unknown sound" SPC %mySound);
        return -1;
    }
 
    if (!$PREFS::ENABLESOUND)
        return -1;
 
    return alxPlay(%mySound);
}
#2
05/16/2008 (3:33 pm)
When you play a sound the description specifies a channel with the "type" field ( eg. $GuiAudioType ). Then you can set the volume of a whole channel by using sfxSetChannelVolume. The optionsDlg does this already if you look at options.cs ( updateChannelVolume ) you can see how they are doing it.

So if you designate a channel for "music" you should be able to use sfxSetChannelVolume to do what you want.
#3
05/16/2008 (3:40 pm)
That just turns off the volume, it doesn't enable/disable it from being played.
#4
05/16/2008 (5:00 pm)
True, but then again your approach wouldn't stop a music sound that was already playing. And I assumed that more than likely that was what she wanted to accomplish.
#5
05/21/2008 (9:57 am)
This looks great. Thanks!