# Blender in game volume control?

Is there a way to use python to control the master volume in game. I want that all sounds are controlled by one object so I can do any settings in game.

Globally change volume with this Python snippet. Also affects sound actuators.

import aud

device = aud.device()
device.volume = 0.5  # Change this value to whatever


http://www.blender.org/api/blender_python_api_2_76_2/aud.html

Keep in mind that a new device isn't created until you re-start blender, so any changes made in-game will persist until you actually close blender.

• This is the solution. – Daniel Oct 3 '16 at 13:42

Check out Tutorials For Blender 3D for a solid reference on basically everything you'll ever need for scripting. Link here for the Sound Actuator Python reference.

Ended up sitting down finally, and got you this: Volume Control

I'll let you see the script and sort out how it works on your own. Not to be an ass, but because it'll make more sense and stick better if you do.

Reference for sound actuator python. http://bgepython.tutorialsforblender3d.com/SoundActuator

• Is there a different way. I don't want to set this up on every single object that uses sound. You see, I am making a big game and everyone knows that more logic bricks are more lag. so... – Hendriks3D Nov 1 '15 at 9:18
• Ah. I was thinking in terms of music. But it's still easy. Unfortunately I'm again not at my computer so let me explain this as best I can. – Daniel Nov 1 '15 at 9:20
• Give me a bit, I'll be editing my answer. – Daniel Nov 1 '15 at 9:21
• Done. Untested. Let me know how it works. You can see any possible errors by going to Help and showing system terminal. – Daniel Nov 1 '15 at 9:32
• Updated one more time. Gave you a .blend to play with and see how it works. – Daniel Nov 1 '15 at 18:55