Тёмный

Organize Sound In Godot 4 

Cadoink
Подписаться 571
Просмотров 14 тыс.
50% 1

A tutorial about different way to organize sound effects in Godot 4 (concepts all apply to Godot 3.X as well!). In this video, I will talk about three techniques I use to organize my sound: SoundQueues, SoundPools, and the SoundManager.
These structures can be used to organize sounds, prevent sounds from being cut off, and playing random similar sound effects (good for things like footsteps).
All examples are using C#, but you can create the same structures using GDScript or any other language.
Let me know in the comments how you structure your sound in your game dev projects!
🎨 Assets used in the video:
Kenney - www.kenney.nl/assets
www.kenney.nl/assets/rpg-audio
www.kenney.nl/assets/micro-ro...
🎵 Music:
Silent Wood by Purrple Cat | purrplecat.com/
Music promoted by www.chosic.com/free-music/all/
Creative Commons CC BY-SA 3.0
creativecommons.org/licenses/...

Опубликовано:

 

5 мар 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 42   
@joshhoffman7811
@joshhoffman7811 4 месяца назад
Your introduction to these concepts is fantastic. This is exactly what I was looking for, thank you for putting this video together! :)
@cadoink
@cadoink 4 месяца назад
Thank you so much! I'm glad you enjoyed it! :)
@baumwolle2548
@baumwolle2548 Год назад
Nice one! Since good Godot projects depend on strong software architecture its awesome you shared your work
@cadoink
@cadoink Год назад
Thank you! I'm always looking for better ways to organize my code. :) I've gotten a lot of reuse with these structures over various game jams, so I hope they'll be useful for others.
@eeek143
@eeek143 Год назад
I love seeing people talk more about audio aspect of things, excellent video
@petersonnormil6799
@petersonnormil6799 Год назад
awesome video for godot! it honestly taught me some things that I've never even tried in Unity. thanks so much!
@tastedaspear7948
@tastedaspear7948 4 месяца назад
gr8 video mr.KING-GAMEDEV!
@andres_mpr
@andres_mpr Год назад
This was amazing... I like mi code well structured and this is awesome, thanks
@felbecker
@felbecker Год назад
Thank you for putting time into this tutorial! Going further, one could think about implementing a priority system. The game should be able to prioritize sounds if there are too many. For instance, the fire sound from the player should have very high priority, whereas the same sound but from an enemy could be silenced if there are too many of them. I think this will require a small rewriting of you current SoundQueue approach.
@cadoink
@cadoink Год назад
That is a very interesting idea! I wonder if something like that could be achieved with a priority queue. I haven't run into this requirement before, but it would be fun to try and figure out.
@sporktank
@sporktank Год назад
Great video! Very nice way of solving these audio issues. Thanks for all the tips! 😄
@cadoink
@cadoink Год назад
Hope its useful! Its been great for the game jam projects. I typically stuff everything in the Sound Manager so I can quickly validate that everything is on the right audio buses for my sound settings. Perhaps an abuse of the singleton pattern, but acceptable for jams.😅
@sporktank
@sporktank Год назад
@@cadoink Everything is acceptable in a jam. 😂
@projectavalongame
@projectavalongame Год назад
nice vid, I had actually been thinking about this recently for my own game but hadn't searched anything about it. Seems very random for this to come up in my youtube home page 24 minutes after upload lmao
@cadoink
@cadoink Год назад
Serendipity! Hope its helpful! Let me know if it works out, or if you come up with some other cool ways of organizing sound. :)
@crabirl
@crabirl 3 месяца назад
You mentioned having a signal dictionary between the classes around 9:10 -- I would love to know more about that. Thank you!
@cadoink
@cadoink 3 месяца назад
I kind of flubbed my word there. I was trying to say a single dictionary. 😅 What I meant was that instead of having a Dictionary for SoundQueues and a Dictionary for SoundPools, they could each implement a C# interface that defines a Play method. Then you could store both the queues and pools in one dictionary.
@DrZ_5000
@DrZ_5000 8 дней назад
Great Tutorial, thx a lot! liked&subbed :) You have a nice way of explaining the software design behind your ideas. Good to see you using C#, I just started godot and prefer static typed languages. I will try this out in in my project for sure. Would it be possible, that you push that specific code in a minimal Godot project to github? Maybe that way people (including me) can collaborate and share their ideas about this topic there. We could also copy&paste the code more easily ;) cheers mate
@moose6459
@moose6459 7 месяцев назад
I ended up converting it all into a singleton with a PlaySound(Node3D owner, AudioData data) and PlayRandomSound(Node3D owner, IEnumerable). My AudioData is just a resource containing the stream and all the stream variables. Then I check in the singleton if the dictionary of sounds already contains an active AudioStream playing the sound, in which case I replay the sound, otherwise I create a new AudioStream child. This way all my active audio in the game is in one central location and any script can request to play a sound.
@0HHC
@0HHC Год назад
Thank you! But can't you just increase max_polyphony in godot 4 for a queue?
@cadoink
@cadoink Год назад
I don't know! I've only recently started messing around with Godot 4. While I used Godot 4 for this video, I had typically been using these in Godot 3.5. Its possible that Godot 4 already solves queueing natively. I'll have to investigate! Thanks for the heads up!
@fkeyzuwu
@fkeyzuwu Год назад
@@cadoink yeah im pretty sure they have polyphony for this in godot 4. still a nice video tho! also, instead of having the audiostreamplayer as a child shenanigans and having to check for errors, you could just add an @export variable for the audio file you want to play and when you add new audiostreamplayers you just set their audio file to the one you put inside the variable. that saves a bunch of code that seems kinda messy and unneeded imo.
@cadoink
@cadoink Год назад
@@fkeyzuwu Hadn't thought to use an export to get the audio stream and just create the audio stream players in the ready method. That's a great idea! Thanks for the suggestion!
@cadoink
@cadoink Год назад
@@fkeyzuwu One upside to my approach is that you can tweak the AudioStreamPlayer for particular sound effects if you need to adjust the db, the bus you want to use, or some other setting (especially spatial audio). This could also be achieved with exports passing these values through though.
@regen-Q
@regen-Q Месяц назад
from what i understand, increasing the max polyphony attribute of an AudioStreamPlayer node achieves the same result as your SoundQueue system. is there a particular reason why you chose this system over simply increasing the max polyphony?
@matiturock
@matiturock Год назад
Hello excellent video. One suggestion is to please make the editor code letters bigger. Thank you.
@cadoink
@cadoink Год назад
Thank you for the suggestion. I'll increase the font size in future videos. :)
@moose6459
@moose6459 7 месяцев назад
The SoundQueue isn't necessary. AudioStreamPlayer has a MaxPolyphony which does the same thing, allowing a sound to be played again while already playing if set higher than 1.
@cadoink
@cadoink 6 месяцев назад
I either came up with this before MaxPolyphony was implemented (maybe an older version of 3.X), or before I learned about this. Thanks for the tip!
@E62147
@E62147 3 месяца назад
But then SoundPool isnt't necessary either, If I can use AudioStreamRandomizer? Im getting lost what is the best aproch to implement sound system.
@cadoink
@cadoink 3 месяца назад
@@E62147 So this looks to be a new feature of Godot 4. Its not a node, but a selection for the Stream on AudioStreamPlayer. This stream setting has a Streams property where you can add multiple streams. Pretty cool! My recommendation would be to use this in your Godot 4 projects and see if it meets your needs. You can also implement my solution if there is some specific behavior you want that the new Godot 4 option doesn't provide.
@sziklamester1244
@sziklamester1244 6 месяцев назад
Actually I created a simple menu for my game but actually the game is a single image and now not that matters. I managed from another video tutorial to play a music by using a music controller and autoload which is nice because I wanted the music works on the main menu and the options menu but actually not want to use it on the game scene. I only have currently one music to play but later when I start to build up my game I want to play different sounds and musics but now I would want to mute the music when I start my game scene. Actually what you shown in the video is good but I did not followed because not want to mess it up more than what may I did currently. Already used 3 peoples tutorial and mixed into one but not managed to fix this yet. I am using Godot 4.2 right now and currently none of the 7 tutorial I watched for helped me that much because they have had already a game or was just a mess.
@DibyoshreeSarkar
@DibyoshreeSarkar 7 месяцев назад
Okay so I have a bunch of sounds that I want to play, based on a dialogue script, What I did was set a new stream to the same audio player at runtime, so that when the script says "play a pop sound" the code looks in the asset library for a pop sound and sets the stream of the audio player to that sound. This works fine for a small project, but I was wondering if this is too inefficient for a larger project ?
@cadoink
@cadoink 7 месяцев назад
I'm not entirely sure, but I think the resource stream is the expensive part. Once its loaded, creating and destroy AudioStreamPlayers should be efficient.
@FPTGOG
@FPTGOG 6 месяцев назад
It says that "playback can only happen when a node is inside the scene tree", i can't use Sound Queue at all
@cadoink
@cadoink 6 месяцев назад
You will need your SoundQueue somewhere in the scene tree. This could either be a part of a singleton that is autoloaded, for example a sound manager to manage all your sounds, or you can use these SoundQueue directly in the scenes that needs the sound, like a Player scene could have a SoundQueue for its footsteps sounds.
@juanjosepenabecerra7746
@juanjosepenabecerra7746 7 месяцев назад
How to prevent from playing the sound pool every frame? wait until the current sound ends?
@cadoink
@cadoink 7 месяцев назад
You should play the audio when the event happens. So when the player presses jump, or is hit by a projectile, etc. If you play the audio on the frame something happens, it shouldn't restart on other frames. Sometimes an event may occur very frequently. In those causes you may want to limit how many times a sound can be played. The size of your queue of sounds and how long they play can limit how frequently the sound will occur, so for some events it may skip playing the sound so that its not overwhelming.
@tastedaspear7948
@tastedaspear7948 4 месяца назад
btw, is it possible for me the to get my hands on that fireball png?
@cadoink
@cadoink 4 месяца назад
Its from the Kenny Micro Roguelike spritesheet: www.kenney.nl/assets/micro-roguelike
Далее
10+2 AWESOME ADDONS for GODOT 4
8:36
Просмотров 126 тыс.
How To Make Sound Effects For Games
18:54
Просмотров 355 тыс.
ПОЮ ЛЕТНИЕ ПЕСНИ🌞
3:16:55
Просмотров 1,7 млн
How to program in Godot - GDScript Tutorial
58:10
Просмотров 433 тыс.
Optimizing my Game so it Runs on a Potato
19:02
Просмотров 463 тыс.
Volume Settings Tutorial For Godot 4
14:26
Просмотров 2,1 тыс.
How to add UI sounds in Godot 4 the smart way
33:59
Просмотров 8 тыс.
How to use Classes in Godot! - Intermediate Tutorial
8:46
Complete Godot Rhythm Game Tutorial
23:02
Просмотров 61 тыс.
This Godot 4 Scene Manager Does it ALL
28:50
Просмотров 20 тыс.
Godot 4 - Tiled Dungeon Environment From Scratch
26:24
Просмотров 388 тыс.