Volume issue
by Abhinav Chokhavatia · in Torque Game Builder · 06/17/2008 (2:26 am) · 6 replies
Hey guys!
I was trying to create a volume control GUI for my game and I wanted to change the volume of the backgroud music on the fly. Is there a function which I can call to change the volume of the music? Below is my code.
I was trying to create a volume control GUI for my game and I wanted to change the volume of the backgroud music on the fly. Is there a function which I can call to change the volume of the music? Below is my code.
$bgmusic = alxPlay (bgmusic); %newVolume = 0.8; (I dont know what to put here for changing the volume)
About the author
#2
06/17/2008 (9:20 am)
You can also check out the options gui and related scripts in the common folder. There is an options gui with the ability to set music/sfx volume in stock TGB.
#3
You want to use updateChannelVolume(). For example, here's the script that I placed in the "altcommand" of my guiSliderCtrl control:
Where $AudioType::music is the audio channel of the sound (set in the audio description datablock) and ui_music_slider is the name of the gui control.
06/17/2008 (11:22 am)
Abhinav,You want to use updateChannelVolume(). For example, here's the script that I placed in the "altcommand" of my guiSliderCtrl control:
updateChannelVolume($AudioType::music, ui_music_slider.value)
Where $AudioType::music is the audio channel of the sound (set in the audio description datablock) and ui_music_slider is the name of the gui control.
#4
but the change is only reflected is I use AlxStop and then play the sound again. How can this works inmediately?
Thanks
06/21/2008 (3:19 pm)
I can update the value of my AudioDescription using this line:updateChannelVolume(myAudioDatablock.volume = 0.3);
but the change is only reflected is I use AlxStop and then play the sound again. How can this works inmediately?
Thanks
#5
06/21/2008 (3:58 pm)
If you want to change the sound on a particular sound only, and not the entire channel, you can use this:// %handle is the return value from alxPlay(mySound); // %volume is the volume you want it set to (lies between 0.0 and 1.0) alxSourcef(%handle, "AL_GAIN", %volume);
Torque Owner Brian Wilson
I'll post some code when I get home from work...