Тёмный
No video :(

Spatial audio with Dynamic Acoustics in Godot | Tutorial 

Blekoh
Подписаться 4,7 тыс.
Просмотров 5 тыс.
50% 1

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

 

23 авг 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 67   
@Blekoh
@Blekoh 5 месяцев назад
!🐛BUG ALERT🐛! The video version contains a bug where if the audio player is a child of something that rotates then it will not update the RaycastPlayer correctly. To fix the bug remove the RaycastPlayer from the node and ready function and then use the following _on_update_lowpass_filter function: func _on_update_lowpass_filter(_player : Node3D): if _lowpass_filter != null: var query = PhysicsRayQueryParameters3D.create(self.global_position,self.global_position + (_player.global_position - self.global_position).normalized() * max_raycast_distance, $RaycastForward.get_collision_mask()) var space_state = get_world_3d().direct_space_state var result = space_state.intersect_ray(query) var lowpass_cutoff = 20000 #init to a value where nothing gets cutoff if !result.is_empty(): var ray_distance = self.global_position.distance_to(result["position"]) var distance_to_player = self.global_position.distance_to(_player.global_position) var wall_to_player_ratio = ray_distance / max(distance_to_player,0.001) if ray_distance < distance_to_player: lowpass_cutoff = wall_lowpass_cutoff_amount * wall_to_player_ratio _target_lowpass_cutoff = lowpass_cutoff Alternatively you can view/download the fixed code here: www.patreon.com/posts/98559205 (its free)
@crowlsyong
@crowlsyong Месяц назад
Dude thank you. Much appreciated.
@streider1347
@streider1347 25 дней назад
In the debugger I get “_save_to_cache: Condition ‘f.is_null()’ is true. Is this a problem for everyone or just me?
@foxdancemedia
@foxdancemedia 6 месяцев назад
woah thanks blekoh this is actually something that will super improve a game I'm working on 👍 people really don't realize how much of a difference good sound design makes
@Blekoh
@Blekoh 6 месяцев назад
Nice! Yeah I made it for my current project and I felt like it made a big difference so I thought I'd share it hah. Good luck with your game 👈👈🤖
@PabloWunderlichMusic
@PabloWunderlichMusic 6 месяцев назад
couldnt agree more!
@clashofclans9783
@clashofclans9783 3 месяца назад
​@@Blekoh What is your next project 🤔 ?!?
@Blekoh
@Blekoh 3 месяца назад
@@clashofclans9783 I've mostly been working on my new game Sacred Forest ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-yGXYHpKD2II.html
@clashofclans9783
@clashofclans9783 3 месяца назад
@@Blekoh good luck
@JustVoidzzz
@JustVoidzzz 6 месяцев назад
Great tutorial. The effect is very good. The main thing I did differently when following is using ray cast queries instead of individual ray cast nodes. This allows the node to be added just like any other regular node. The only other thing I had to change when doing this is when I emitted the ray cast, I would have to add the current global position to the direction I wanted to emit.
@Blekoh
@Blekoh 6 месяцев назад
Awesome! I like the ray cast query idea! I honestly totally forgot those existed since its been a while since I've been working with Godot 3d stuff haha 👈👈🤖
@BetaTester704
@BetaTester704 6 месяцев назад
Really high quality video
@Blekoh
@Blekoh 6 месяцев назад
Thanks! 👈👈🤖
@phillippi2
@phillippi2 5 месяцев назад
This is kind of inspiring for me. I am working on a 3d game in Godot, where the player plays as a dolphin. It focuses on how they use sound for nearly everything. I wanted to implement a system similar to the GSound demo posted here on RU-vid. I thought that I was going to have to write a custom audio server. But this gives me hope that I won't have to.
@PureAsbestos
@PureAsbestos 6 месяцев назад
This is something I have thought about a lot. Thanks for making a video on it!
@possiblyzslot838
@possiblyzslot838 Месяц назад
Not the most elegant solution probably, however I'm glad there are any tutorials on this at all and once new developers get more experienced they can create their own improved solutions
@HakanBacon
@HakanBacon Месяц назад
Dang this is such a lovely tutorial. Thank you!
@jamie_dev
@jamie_dev 2 месяца назад
thanks for this! I just discovered your channel and love your other videos. looking forward for more!
@vegameta
@vegameta 3 месяца назад
Как же мощно! Спасибо 🧶
@Mr-Highball
@Mr-Highball 6 месяцев назад
Great tutorial! Im glad i saw this on the internet today
@Blekoh
@Blekoh 6 месяцев назад
Thanks!
@Marandal
@Marandal 4 месяца назад
Super helpful video. More people should know about this!!!
@morgan0
@morgan0 5 месяцев назад
fyi the lerps here are actually creating a first order lowpass filter (or smoothing filter), or an exponential moving average. it's similar to the filter you're using on the audio, but at a much lower cutoff frequency, and smoothing whatever values instead of audio
@ghostcreeper3679
@ghostcreeper3679 5 месяцев назад
Damn this is SICK, i found this tuto so useful as a starting point but other than adding more rays (like each diagonal for xy xz and zy planes and evey diagonal inbetween) i have no clue on how ot improve it further. Doy ou know other effects other than the two you showed so that i might get my hands on them? or do you plan on expanding this example?
@Blekoh
@Blekoh 5 месяцев назад
Thanks! Well there are a few ways it could be improved on but for my game I felt like it is good enough as is🤖 Some systems treat different surfaces different like carpet would be different than tile floor, or wood, etc. Sometimes other spatial audio systems will also add a compressor (which is just another effect that balances the audio out so things don't get blown out). An EQ might also be good to avoid off frequencies idk. I think spatial audio can be a rabbit hole for people to go down where a simple system like this will get you 90% of the way and you could spend months trying to perfect the system to get the extra 10% haha
@ghostcreeper3679
@ghostcreeper3679 5 месяцев назад
Thanks @@Blekoh I'll look into it :))
@morgan0
@morgan0 5 месяцев назад
if you want to add more rays for better resolution of what's around it, you could use a stochastic method where you shoot out rays in a random direction (or random forwards and backwards, or rotating a bunch of rays, whatever) and having some representation of distance in a sphere around it that each ray modifies based on where it is pointing, with some smoothing temporally and spatially. then unless the sound source is moving fast enough that it can't update frequently enough (also stationary objects could update less often), it will trend towards accurate distances. after watching some more, if you just want averages, you could use an exponential moving average with random ray directions. for each ray, calculate what its contribution would be, and then blend 0.9 of the old value with 0.1 of the new value (or maybe even smaller). that's different from typical linear interpolation, but is using the lerp function to create a first order smoothing filter, or an exponential moving average.
@clashofclans9783
@clashofclans9783 3 месяца назад
Why can't I hear anything?:(
@davitdon2963
@davitdon2963 2 месяца назад
I'm trying to get how many decibels certain sounds make, So that I can wake up characters if the environment is too loud. How would I get the decibels while the audio is playing?
@Blekoh
@Blekoh 2 месяца назад
Well you need the bus_idx for whichever bus you’re trying to check, so if you have a bus named “Master” var bus_idx = AudioServer.get_bus_index(“Master”) Then to get the current decibel level you can do var db_level = AudioServer.get_bus_volume_db(bus_idx)
@rigodolfo
@rigodolfo 4 месяца назад
tank you
@WeirdBrainGoo
@WeirdBrainGoo Месяц назад
I have a question. How would you treat sound sources that aren't point-like? For example, along a beach there are waves crashing all across the shoreline. Of course you could place several AudioStreamPlayer3Ds along the shore, but then I think there will be positions where you can hear two sources at the same time. So as you walk along the beach the sound would be louder in some places even if you're the same distance away from the water. Or should there be a trail in the water and you just make the sound source move alongside the player when they're near the shore? EDIT - I decided to just place a bunch of AudioStreamPlayer3D nodes along the shore. It works well as long as you set the attenuation mode to inverse.
@Blekoh
@Blekoh Месяц назад
@@WeirdBrainGoo Nice, yeah I think placing them along the shore was a good choice for that, or just using a regular AudioStreamPlayer and fade it in when you enter the shore Area, and fade it out when you exit. Good luck with your project! 👈🏻👈🏻🤖
@WeirdBrainGoo
@WeirdBrainGoo Месяц назад
Okay, thank you! 😁
@empMerp
@empMerp 25 дней назад
@@WeirdBrainGoo A more technical approach could also have the sound source follow the player along whatever axis the beach is on, Although if you plan to have it like an island, I cant think of a way to follow a circular path.
@WeirdBrainGoo
@WeirdBrainGoo 25 дней назад
@@empMerp Yea, that's actually what I said in my original comment. 🙂 I remember seeing a 2D node that was a path of some sort that you could define and set other nodes to move along. It was used in the 2D tutorial in the Godot documentation. There might be a 3D equivalent. If the island is circular you could just do sound_source.position = center + r * dir, where r is the radius of the island, dir is the direction the player is from the center of the island and center is the center of the island. So dir = (sound_source.position - player.position).normalized() I actually did try this, but it has the problem that when you go slightly to the left from the middle of the island, the sound source will move all the way to the left shore. So you'll only hear the water on the left. And whichever way you move slightly away from the middle, the source will be all the way there. My island is pretty small so it's very noticeable. Placing several sources along the shore fixed that problem. With that solution either the attenuation should be set to inverse, or if you're using inverse square root you should place a lot of them close together.
@empMerp
@empMerp 25 дней назад
@@WeirdBrainGoo Oh sorry I never saw the "show more" option
@mojosulo
@mojosulo 6 месяцев назад
Amazing tutorial, thanks! Any chance you'll be uploading this code anywhere, or making it into a Godot plugin?
@Blekoh
@Blekoh 6 месяцев назад
Thanks! Well this is meant to be sort of a starting point for people to just get an idea for how to make this sort of system and customize it to their needs. I don't think its really plugin quality as-is but anybody is welcome to add features to it and make their own plugin (also I don't want to maintain it long term haha)
@mojosulo
@mojosulo 6 месяцев назад
@@Blekoh Totally makes sense. Thanks for the reply!
@oshihete0
@oshihete0 4 месяца назад
thx
@lmullins573
@lmullins573 18 дней назад
Dumb question from me but do I add this to the player scene or a global scene. It doesn’t seem to be affecting the sounds and I know it’s something I’m doing wrong.
@Blekoh
@Blekoh 18 дней назад
You would add it to whatever you want to make a sound. For example, an enemy might have a spatial audio player that plays monster sounds. Also, I did release the code to where you can just download and use it if you have trouble finding out what is crashing :) www.patreon.com/posts/spatialaudioplay-98559205
@lmullins573
@lmullins573 18 дней назад
@@Blekoh oooooooh that makes sense. I get it now. It’s literally replacing all my audio player 3D nodes. Thank you so much. This game I’m making relies on hearing and this is going to be so solid.
@Blekoh
@Blekoh 18 дней назад
@@lmullins573 nice, good luck! :)
@jeffg4686
@jeffg4686 3 месяца назад
Nice, do you happen to know if you can add effects to someone's voice in the room? Like multiplayer, but you want to allow the mic on the headset and add effects to external sounds in the room. For instance, let's say you're in a game and you enter some weird room where everything is echoing even the people next to you. You could sample the audio from the mic and every "pause" you can reverb the sounds before it. I mean, I guess, I already know it can be done, but more wondering if you've tried.
@Blekoh
@Blekoh 3 месяца назад
You can definitely apply effects to someone's voice. Godot has tons of built in audio effects that can be applied to an audio bus. You can use the AudioStreamMicrophone along with the AudioEffectCapture to get a players voice audio data and then you can send the captured audio data over the network to nearby players. Then on every other players pc you can take that audio data that was received from the network and feed it into an AudioStreamPlayer that plays audio on an audio bus with your desired echo effect (either with reverb effect or delay effect) You can add/remove effects to audio buses whenever you want, so you can just add it when you're in your special room. Here is Godot's official demo project for recording audio which would be a good starting point: github.com/godotengine/godot-demo-projects/tree/master/audio/mic_record
@jeffg4686
@jeffg4686 3 месяца назад
@@Blekoh - Nice, thanks for the details. I think my first adventure into XR might be a haunted house or haunted mansion (side loaded for client) and something like that definitely add a nice effect to everything. Since everyone's in the room - no network needed in my scenario. Just process the audio coming in with effects. But you can't replay the audio portion itself - only the effects portion so I guess you'd maybe skip ahead of the initial sound itself (which the player has already heard)
@escapZe
@escapZe 6 месяцев назад
Help, why does this happen):. Out of bounds get index '10' (on base: 'Array')
@Blekoh
@Blekoh 6 месяцев назад
Count how many 0's you added in the _distance_array at the top of the script, there should be ten 0's, it looks like you might have 11
@escapZe
@escapZe 6 месяцев назад
Thank you! @@Blekoh
@Blekoh
@Blekoh 6 месяцев назад
​@@escapZe I would put a break point in the script to check first of all that _on_update_lowpass_filter is actually being called and also add a break point to make sure that in the _lerp_parameters function, it is actually setting the cutoff_hz value If you stand behind a wall and add the breakpoint to the _lerp_parameters function you should be able to see that your _target_lowpass_cutoff value should be set to some value less than 1000
@Blekoh
@Blekoh 6 месяцев назад
​@@escapZe If you still get stuck I uploaded my copy here for reference: www.patreon.com/posts/spatialaudioplay-98559205
@escapZe
@escapZe 6 месяцев назад
Anything past (self.bus = _audio_bus_name) doesnt work in ready function.@@Blekoh
@sunnivaflusund2987
@sunnivaflusund2987 4 месяца назад
I cant find the "spatialAudioPlayer3D" is my Nodes, is it like an addon?
@Blekoh
@Blekoh 4 месяца назад
SpatialAudioPlayer3D is the node we make in the video 👈🏻👈🏻🤖
@sunnivaflusund2987
@sunnivaflusund2987 4 месяца назад
Oh sorry, i see now, i am a total newbie xD I just wanna say really appreciate your skills with coding, i am more an artist than a programmer and find it a bit hard to learn sometimes, but folk like you makes me believe that it is possible, so thanks
Далее
How to Add Interaction in Godot 4
16:48
Просмотров 12 тыс.
When I met the most famous Cristiano
01:03
Просмотров 27 млн
Simple Flower Syrup @SpicyMoustache
00:32
Просмотров 1,7 млн
They made a game about philosophy...
23:19
Просмотров 449 тыс.
I Turned a Fake Ad into a Real Game
9:28
Просмотров 8 тыс.
A new way to generate worlds (stitched WFC)
10:51
Просмотров 525 тыс.
AI Learns How To Play Doodle Jump
12:02
Просмотров 276 тыс.
This Godot 4 Scene Manager Does it ALL
28:50
Просмотров 24 тыс.
4 Godot 4 Devs Make 4 Games in 44 Hours
25:19
Просмотров 510 тыс.
Bringing GLaDOS to life with Robotics and AI
13:04
Просмотров 846 тыс.
A truly 2D game isn't what you think it is...
13:23
Просмотров 42 тыс.
Hiding texture repetition in Godot 4 | Tutorial
16:05