- Edited
Hello Godot Community, I am new to Godot and I am stuck at this point where I can't change the volume of all my SampleLibrary, I tried all kind of things (including solutions found in the old forum) Please help.
Hello Godot Community, I am new to Godot and I am stuck at this point where I can't change the volume of all my SampleLibrary, I tried all kind of things (including solutions found in the old forum) Please help.
Hello Updater3000!Do you mean changing the volume in the editor UI, or changing the volume via script?Within a SampleLibrary you can edit the "dB" value of each sample to make a sound louder or quieter. Is this the point where you can't change the volume? Or do you mean the general volume of the node "SamplePlayer"?Which posts were the ones you already tried?
[font=trebuchet ms]Hello Doc Angelo and thanks for your reply.I tried those posts :http://forum.godotdevelopers.org/index.php?topic=10130.msg10136#msg10136http://forum.godotdevelopers.org/index.php?topic=5850.msg5850#msg5850I am looking to change the volume of sample via script, I actually made a settings menu which has a volume bar for music(streamPlayer) and SFX, fot SFX I need to the volume change for the whole sample so I need to change volume of all the node via script, and when you turn the db of a sample to -60 it does not kill all the sound.[/font]
If I understand you correctly, you have a [tt]StreamPlayer[/tt] for music, and a [tt]SamplePlayer[/tt] for sound effects. You have a menu, where the user can set the volume for both music and sounds. If you want to control every stream or sample of the whole game, you can control the [tt]AudioServer[/tt] directly. Setting all streams to normal volume and all sound effects to half volume is done like this:[code]AudioServer.set_stream_global_volume_scale(1)AudioServer.set_fx_global_volume_scale(0.5)[/code]If you want to have finer control over streams and sounds, you have to set any [tt]StreamPlayer[/tt] and [tt]SamplePlayer[/tt] individually. [tt]StreamPlayer[/tt] and [tt]SamplePlayer[/tt] seem to have slightly different functions, and functions with the same name work different. Setting the volume of a [tt]StreamPlayer[/tt] to half the volume is done like this:[code]get_node("StreamPlayer").set_volume(0.5)[/code][quote=Godot Documentation | StreamPlayer | void set_volume( float volume )]Set the playback volume for this player. This is a float between 0.0 (silent) and 1.0 (full volume). Values over 1.0 will amplify sound even more, but may introduce distortion. Negative values will just invert the output waveform, which produces no audible difference.[/quote]For [tt]SamplePlayer[/tt], the function is called a bit different. Setting it to half the volume will result in all samples in this particular [tt]SamplePlayer[/tt] played with half the volume.[code]get_node("SamplePlayer").set_default_volume(0.5)[/code][quote=Godot Documentation | SamplePlayer | void set_default_volume( float volume )]Set the default volume of the player using a linear scale. The "volume" argument should be a positive factor ranging from 0.0 (mute) up to 16.0 (i.e. 24 dB). A factor of 1.0 means that the voice will be played at normal system volume. Factors above 1.0 might be limited by the platform's audio output.[/quote]
[font=trebuchet ms]Hello Doc Angelo, that's exactly what I want thank you very much for your help, I will post all my results when I finish making all the ui, man I am really grateful.[/font]