nathanhoad / godot_sound_manager Goto Github PK
View Code? Open in Web Editor NEWA simple music and sound effect player for the Godot Engine
License: MIT License
A simple music and sound effect player for the Godot Engine
License: MIT License
Is your feature request related to a problem? Please describe.
The standard AudioStreamPlayer will play a different stream each time it plays when given an AudioStreamRandomizer. You can stop and start it multiple times in a row to get randomized streams. SoundManager does not not stop the current stream when treated similarly.
Describe the solution you'd like
I would like SoundManager to treat AudioStreamRandomizer as a special case, so that users can play the same AudioStreamRandomizer resource multiple times to get randomized results.
In particular, I think the combination of checking for currently playing resource and the crossfade timer make it hard to diagnose the problem for new users.
Describe alternatives you've considered
The user may wait longer than the crossfade timer between stop_music() and play_music(), and SoundManager will correctly pick up a randomized stream from AudioStreamRandomizer.
E.g. await get_tree().create_timer(0.2).timeout
Additional context
I'm new to the AudioStreamRandomizer resource and find it a bit limiting. I'm not sure if my difficulty here is my ignorance of SoundManager or the Randomizer. If you have best practices recommendations for a looping music player that randomly selects a new stream at the end of the previous stream, I'd love to learn about them!
Pretty please <3.
I love this tool and want to conveniently install it on all of my projects.
Is your feature request related to a problem? Please describe.
A way to play a looping sound that needs to be turned on or off. Examples include footsteps, rain, whooshing sounds, water ambience, jetpacks and rockets. For all of these, there is a looping sound that in some cases should be on, and in others should fade out.
Describe the solution you'd like
A function to ‘set_continuous_sound_active’, which takes in the sound, a bool and optionally a fade time. When set to true, that sound will fade in. When set to false, the sound will fade out. Multiple different continuous sounds can be played at the same time. In the process function I could have something like the following:
SoundManager.set_continuous_sound_active(footsteps, player.is_walking, 0.1)
Describe alternatives you've considered
Tried using the music system to handle these continuous sounds, however it seems only one music track can be running at once. If music were used, this would play on the wrong bus by default and would require a line to turn it on and another to turn it off (rather than a single line that takes in a bool).
I make a data.gd
file (that save and load the game settings) and set it to autoload:
const _DATA_PATH := "user://data.cfg"
var music_volume := 100:
get:
return music_volume
set(value):
music_volume = value
SoundManager.set_music_volume(float(value) / 100)
var sound_volume := 100:
get:
return sound_volume
set(value):
sound_volume = value
SoundManager.set_sound_volume(float(value) / 100)
var _data = ConfigFile.new()
func _ready():
var err := _data.load(_DATA_PATH)
if err != OK:
return
music_volume = _data.get_value("settings", "music_volume", music_volume)
sound_volume = _data.get_value("settings", "sound_volume", sound_volume)
When start the game, it returned this error:
Invalid get index 'bus' (on base: 'Nil').
I'm trying for the first time this addon and with Godot RC2 the function fade_volume
when it gets called by play_music
it does not work.
After looking at the code thanks to the error code and the Godot Docs, it seems that the method interpolate_property
is not avaiable anymore.
Hope that you could fix it!
Note Listen to the music in the video
I make a data.gd
file (that save and load the game settings) and set it to autoload (name Data
):
var music_volume := 100:
get:
return music_volume
set(value):
music_volume = value
SoundManager.set_music_volume(float(value) / 100)
var sound_volume := 100:
get:
return sound_volume
set(value):
sound_volume = value
SoundManager.set_sound_volume(float(value) / 100)
In options_sheet.gd
:
func _on_spin_box_music_value_changed(value: float) -> void:
Data.music_volume = int(value)
printt(Data.music_volume, Data.sound_volume)
func _on_spin_box_sound_value_changed(value: float) -> void:
Data.sound_volume = int(value)
printt(Data.music_volume, Data.sound_volume)
When playing multiple sounds simultaneously, only play once.
This should be an optional feature, perhaps implemented as a parameter for PlaySound().
Is there a way to stop/resume the music without relying on godot pause? I mean the SoundManager.music_process_mode
you mention. If not, I think it would be a good addition in order to have more control over the music.
Thanks in advance!
This plugin is useless if the game is pause with get_tree().pause = true
. Hope you could fix this soon :(
Is your feature request related to a problem? Please describe.
I want to playback random sound effects in a folder and start a timer after the sound effect ends. They are variable length so I can't just add that to the timer as a buffer. I want to be able to play sound effects at a set interval.
Describe the solution you'd like
There's a finished signal for AudioStreamPlayer, even being able to tap into that would work
Describe alternatives you've considered
Setting a longer timer, it's what I will do for now.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.