Change audio volume (Audio slider)

Hey, I want to implement simple audio sliders that control the volume of various sound classes (Master, Music, SFX). I set up sound classes and their hierarchy, but now I need to access the volume multiplier somehow, which does not seem to be possible.

I’ve searched for quite a while but couldn’t find an answer. It seems that either no one had this issue before, or I’m just mussing something obvious here. I hope you can help me with this.

Wondering the same thing. Any news?

Actually yes, from Blueprint you just can’t. It seems like in some areas, Blueprint has some serious catching up to do… In C++, however, changing the volume of sound classes is trivial:
SoundClassObject->Properties.Volume = 0.5f;
So we created some custom nodes to expose those sound class adjustments to blueprint. If anyone wants it I can post the specific code, but with this great article it is quite simple to implement.

Hi. Not sure if this is what you meant, but this is what I did for a project I’m currently working on.
(I just made a new empty project to test it for explanation purposes)

First I made a Widget Blueprint and just put a slider in it. Then I created a “binding” on the Value of the slider.

Then in the binding (I named it "Get Music Volume) just make a new float variable (called mine Music Volume) and connect it to the return value. Put the default value on the variable to 1.

Then go back to the slider and make a “OnValueChanged Event” from it. Set the Music Volume variable based on the Value from the slider event. So that the Music Volume variable will be changed based on the sliders position.

And lastly set it all up in the level blueprint (or wherever best suited depending on your own project). At the start of the event I created the slider widget and made a reference to it that is again used for the “Cast To Slider” which gets the Music Volume variable from the Slider Widget.

Put the sound you want to play out in the level and reference it in the Level Blueprint. make a “Set Volume Multiplier” and drag the Target node to the music reference and it will create the “Audio Component” thing between them. Connect the Set Volume Multiplier with the Music Volume variable, and it should work. (just have a camera in the level and get the mouse to show up so you can drag the slider)

When you start the level now, the music will start and you can turn the volume up or down with the slider.

I used this to change the Music Volume in my project, just connect every in-game Music or Sound effects up to a slider like this and maybe have it in a pause menu or start menu.

Hope this helps :slight_smile:

1 Like

Really there need to be way to change sound class volume from blueprints. This is important feature for every game that have sounds and music (so…every game) we are waiting for this feature for long time, a lot of people added this in C++ in sec. It would be nice to have it officially in binaries.

Couldn’t find any blueprint-only solution, so I’ve maked it in code. There is C++ example.

https://i.gyazo.com/c8522d191ccbcea26ca1735ac38ee113.png

https://i.gyazo.com/b7300f2d214e88079ddea5fb002735c3.png

Why I can not auto play music according to the last pic in my level blueprint?

The pictures are no longer available unfortunately :frowning:

You can make it without using C++. Just create an empty SoundBase class and your sound classes. Then use this in your game instance “Init” event.

352786-1.png

and set the volumes later

352787-2.png

2 Likes

how do you use set volume cause it will not show up just only get volume and thats only after dragging out the widget node

Wondering why the delay node is needed here. I tried without delay node, and the “set base sound mix” won’t work in game instance. Then I setit in my Persistent level on begin play instead, it works fine without delay node. Is it because the Game instance is initialized before the sound system? And I’m also worried that the delay node will cause other problems.