How to make AUDIO VISUALIZER in Unreal Engine 4

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello there i'm sir fancy and in this tutorial i will show you how to make audio visualizer for your game it doesn't have to be for the game if you are making video clip or anything like that you can use that as well behind me you can already see stuff that i'm going to show you today so let's not waste your time and get to it alright then let's get to work i have created just empty project there is a third person template which you can see right here blah blah blah and i'm using version 4.26 from from unreal engine but any new version should work the important thing is that you need to have a plugin enabled so let's look into plugins and if we look into audio you should find here audio synaesthesia audio synaesthesia make sure it is enabled and let's pretend that we don't see this better version it for me it worked pretty fine i could package the game and everything seems to be fine so make sure you have it enabled and if you have to restart the project another thing is that i have here prepared some sound for me it's just a vivaldi right here so you got the idea what it is and make sure that if you are importing something it's in vma or something that will support unreal engine all right that's it for preparation so let's get started first of all right click and we will create here in sounds analysis we have to click on synaesthesia on rd this thing and we will work with constant you can of course work with loudness and i haven't found a really good way to work with onset but you may found the use for that uh primary are going to use constant loudness may be interesting if you want to visualize only very loud sounds so let's click on constants select it and call it sound underscore and rt let's open that and a setting leave your default constant qrt setting or if you want you can create your own but for sound you have to select your new sound in my case it's a vivaldi so let's put it here and now let's create blueprint that will set up a whole visualization thing so let's create blueprint actor blueprint class abacter and let's call it just sound and master underscore bp and let's open that let's put it in component audio leave it right here all right now let's go into event graph and take your audio and what you want to do is to set sound right here and once that sound you can find it and set it here but for now we will promote it to variable and just call it sound all right connect it after event begin play and as our sound let's set here song that you are going to use in my case it's a vivaldi right here and we don't need any of that all right now we will have to create another variable because we need to know how long that song is so let's take our variable sound and give me its length so which is i believe called duration yeah we will have to call it duration get duration promote it to variable and connect it right after this all right now let's make it a bit more interesting we'll have to add here a new event i believe it's a bit uh no bind event on audio playback it's called i believe let's disable context menu and we want bind event on audio playback percent click on that wonderful and as target let's set our audio to do right here and you of course have to take comment from that so let's take it from here and click here at the custom event and it will be playback change now that should get us rid of that error so now what you want to do is to create a new variable so let's enter variable and call it plate time and make sure that it's float all right anyone to set that after the playback will change so to set to what number you will want to set it is simply a duration times playback percent so let's set it float times float and connect it and now we also need to find reference for that new asset we have created that sound energy so let's create a new variable and here in variable type let's put here constant queue on rt open that and click as object reference and let's call it constant underscore ref after you compile you can set default value which will be sound energy which is exactly this one we have created here wonderful so now let's get our constant reference let's get it and set it to get normalized channel constant q at the time you may want to disable contact sensitive if you can't find it but you should find it without a problem right here and in our seconds let's set our plate time which is this one that we are sitting here and from here we will take for loop so let's see they put here for each loop connect it right here and now we have to do something with that so let's start by putting here some object so add component let's let's do sphere it should be fine and what we will do on our for loop is set its scales set volts k3d will be fine and what you want to do is to is to set it to float times float and connect our array right here and let's set it by 10 i wonder how big that will be but we will see we will see but before that we also have to play the song so let's put here our audio and play the song so play just play start time zero blah blah blah all right let's try to put it in here and test it so click on play and switch it to simulate to and see what it does and look at that it seems to react pretty fine to our sound [Music] alright let's see it in regular game that seems to work pretty good [Music] all right now let's make it a bit more interesting i'll add here a new material something emissive because we are making sound visualizer of course it has to be emissive so let's call it emissive underscore master and let's do just something really simple so right click put here constant constant free vector promote it to parameter convert it to parameter call it color and you know what i'm gonna put it as a color because it's much more fancy yeah i said it anyway put it another constant and again promote it to from convert it to parameter and set it as intensity and what you want to do is to put your default value as base color and then set here multiply and put it as our emissive color right here and apply it all right now let's right click on it and create your material instance and let's call it emissive underscore test underscore math and what you want to do is click on color and intensity and set it to let's do something pinkish that will be cool and intensity let's do 50. ah that looks cool look at that all right and we will set it to our sound master so sphere and material let's set it to emissive test material alright click on play and now it's looking much more like some wonderful visualizer but now let me actually show you how you can create here different types of visualizer because you probably don't want to use only one object so what i will do is to delete our sphere from here and it will create error probably here let's delete that thing and what i will do actually is create here new blueprint that will be actor and let's call it audio element underscore bp and what you want to do here is put here whatever object you want let's say that i will use cube that's probably best one and just put it right here let's put here one and two to do that seems cool and now let's just duplicate it few times so let's create here something like a circle and it will be probably easier if i just take your cylinder scale it up and put it on that so you can create something like a actual circle all right that should be cool worst circle i have ever done but it will work the shape right now doesn't really matter just for a demonstration but let's let's set it up somehow so let's go back into sound master and always make sure that even if you can't see it in the game that blueprint has to be in the game so it always needs to be in the level and what i will do is to go into construct script and on construction let's get all actors of class and that will be of course our audio element bp and let's just promote it to variable i will call that audio elements and now if we get back into audiograph after our for each loop we will take our audio elements get a copy get a copy here and take our array right here and now from here you can set scale and do same thing as we did before so set the world scale for our cube and now let's change it a little bit because i want to change only my z-axis so let's connect z here and set my y and x to 0.2 right and connect it right in loop body and let's see what that will give us and look at that it's looking pretty good it's giving us some error so let's see what it is about and it's probably just trying to find find trying to find reference for our cube even if it can find it so we will simply add here is valid so let's put it here that should fix our problem our object will be of course from here and if it is valid it will continue if it's not not gonna happen that should get rid of that error let's see oh error seems to be gone all right let's make it a bit bigger so let's do 0.5 times 0.5 and here you go if you put here for example three or four times as many of them you will see quite a good quite a good audio visualizer and you can create here whatever shape you want of course let's make it bit more of a cube all right i somehow managed to mate even worse cube than i made our circle but that doesn't matter because as you can see it works and it keeps that shape that i wanted originally all right let's put here let's put it also our material because everything looks better if it's shiny let's be real here um and you can of course set it to changing colors etcetera etcetera let me show you one more thing right now you can see that it's quite structured and it's always one side is up our on the other side is up and it's basically following its defensive but if you want to have it a bit more random basically from all around you what you can do after our construct oh no i mean better in wrong element you have to go into sound master bb what you can do in our construction script is after you will collect it let's shuffle it so let's put a shuffle and have it like that let's see now now you can see it's much more shuffled as you could guess i like a deck of cards all right and let's do one more thing i want to show you how to create that line where it's always showing only one of them up up and down it doesn't change that much but it's moving so let's set it up by by deleting all of these yep let's delete all of them and we won't have to do that with our construction script let's just disable it let's just move this thing here and get it away so what you want to do here on our loop buddy of always when it happens so let's spawn actor from class and that actor will be of course audio element and as our spawn transform let's use for that our default scene root right here get world location connect it right in here rotation you can leave as it is but what we will do is of course to change our scale so for our scale let's right click on it split structure pin x and y let's leave to one and our z let's set two again multiply float times float and let's try it times five and put it on our z but now it will be of course just spawning them on one place if i put i already have it here so let's leave it here it will be probably just spawning them yep exactly which is bit buggy we don't want that what you want to do is to go into audio element and adhere some movement so let's put here event kick and let's add local offset and now you also now you kind of have to guess where you want to move it so let's set that it will be x and about five and let me try to put it in the game to see how fast it is moving so let's delete sound master for now because that would make it messy put that thing here and click on play and it's moving pretty pretty well but i would probably use in this case y and let's move it by 10 units and it's pretty good all right let's see what happens now when i put here our sound master if it will be moving fast enough and probably you know what let's not have our scale on one let's put it on zero three for x and value and now and you can see it's spawning them way too fast and it has like thousand actors already well that's bad that's very bad so first of all let's take our audio element again and on our event begin play let's put here short delay and after two seconds i want to destroy itself oh you know what let's let's do five seconds so destroy actor that should help us at least a little bit but we are still spawning way too many of them so what we will simply do in our sound master let's take loop button and put here short delay 0.2 seconds is way too much let's try 0.1 and i'm afraid that it is still too much so let's click on play and look at that that's looking pretty decent but let's change it a little bit let's try 0.5 and i would probably scale down x and y and maybe let it delete a bit sooner let's try three seconds all right now let's click on play and look at that that's looking pretty well and you can see it's getting it get it's getting deleted now i can't even speak from that but i would say that we are getting pretty much what we want and you can see that we don't have more than 90 actors at the same time so let's try to put it in the game click on play and look at that it all of course depends on what kind of music you are using music or sound you are using but hey i would say that we got pretty good audio visualizer for ourselves if you want to have bigger difference between different elements let's just take sound master multiply it by 10 and let's also put this guy down something like that click on play and look at that [Music] and the thing is also the sound eye music i should be able to jump through that that's a that's a game idea for you can jump through sound alright that's about it i hope that you learned something if you did feel free to leave a like down or if you're interested in other stuff that i'm doing i have instagram somewhere here so you can follow that i do mostly vr games i make new vr game every week so you can check that out and huge thank you to everyone on the patreon and also on the patreon you can find complete project files for this just as i finished it right now i'm gonna zip it and not touch it anymore never anyway that's about it see ya sir fancy out
Info
Channel: Sir_Fansi Gamedev
Views: 3,714
Rating: 4.9325843 out of 5
Keywords: audio visualizer, unreal engine audio visualizer, unreal engine audio reactive, unreal engine audio plugin, unreal audio visualization, audio reactive unreal engine, ue4 audio visualizer, ue4 audio reactive, unreal engine sound visualizer, unreal engine sound effects, ue4 sound visualization, ue4 sound effects, unreal engine music visualizer, unreal engine music video, unreal engine 4 music video, unreal engine 4 music visualizer, ue4 music visualizer, ue4 music video
Id: 3JYyNucyMBk
Channel Id: undefined
Length: 16min 49sec (1009 seconds)
Published: Wed Jul 14 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.