Making Procedural Music in Unity

  Рет қаралды 28,214

Ryan Hedgecock

Ryan Hedgecock

Жыл бұрын

Hey There! 👋
Making procedural audio is hard. But hopefully this can help shed some light on the interesting processes behind generating audio at runtime!
github: github.com/rhedgeco/Synthic
blog: blog.hedgecock.dev

Пікірлер: 69
@SuperTerryBeat
@SuperTerryBeat Жыл бұрын
I love how humbled I get when I think i'm a decent unity coder, and then I see this sort of wizardy
@MrKickphlipp
@MrKickphlipp 17 күн бұрын
This is incredibly good! I am pretty new to Unity and was investigating synthesis here for a music game. Lovely - you saved me so much time with very educating video :) Thank you!
@ChipboardDev
@ChipboardDev Жыл бұрын
Great tutorial! I hope to see more from this channel, this is one of the most in-depth tutorials I've seen that use such complicated performance optimizations!
@alejocv7
@alejocv7 Жыл бұрын
First video and such great quality!! 👏🏼
@blkb33
@blkb33 Жыл бұрын
Would be great to see you do further developments on this, really appreciate you sharing the knowledge
@sidneyhestres1147
@sidneyhestres1147 Жыл бұрын
First video of yours I've seen. You're getting my sub and a like cause you inadvertently taught me the existence of Expression-Bodied Properties and that feels like forbidden knowledge that I've wanted forever.
@jung-zen
@jung-zen Жыл бұрын
Really great video, would love to see more on this topic.
@Dehakuzo
@Dehakuzo Жыл бұрын
You dug way deeper than I expected to produce this, This was a blast to watch. I was delighted to see you writing native code for something that sounded so simple in the beginning, love seeing massive optimizations.
@rhedgeco
@rhedgeco Жыл бұрын
Thanks for the kind words! I'm a sucker for optimization
@Infinite3D
@Infinite3D Жыл бұрын
Clean editing, interesting topic, and well-made video. Subscribed.
@rhedgeco
@rhedgeco Жыл бұрын
Thank you 😁
@koenfrontatie
@koenfrontatie 4 ай бұрын
Hey thanks for this great video! Eager to watch more
@isobelshasha2095
@isobelshasha2095 Жыл бұрын
wow this is so exciting, as a game dev who has recently gotten into some modular synth stuff maybe i'll try & do some synth coding with this! thanks so much for making this & sharing
@zebbaukhagen9738
@zebbaukhagen9738 Жыл бұрын
That was very interesting, please make some more videos of this subject! Subscribed.
@chocholatebunny
@chocholatebunny 8 ай бұрын
This is such an elegant tutorial, subbed and want more
@TheOfficialPolo
@TheOfficialPolo Жыл бұрын
Really interesting topic; I had in plan to include Procedural Music in my own project, but the amount of work for the system itself would be too much. Instant respect for thinking of optimization and quality of your work instead of just blasting towards the outcome, it really pays back at the end, when your code makes your work easier ;) Patiently waiting for future videos/devlogs especially if in the same format
@rhedgeco
@rhedgeco Жыл бұрын
Thank you for your kind words! If there's one job a software engineer has, it's making our own lives easier right? 😅
@TheOfficialPolo
@TheOfficialPolo Жыл бұрын
@@rhedgeco Yeap, noone will help us, but surely will blame us for it 😆
@MT-on4hn
@MT-on4hn Жыл бұрын
THIS IS ONE OF THE GREATEST KZfaq VIDEOS OF ALL TIME CAN'T WAIT FOR YOU TO BE BACK WITH MORE
@mixandjam
@mixandjam Жыл бұрын
Nice video Ryan!!
@javiermartinezdevelasco8515
@javiermartinezdevelasco8515 Жыл бұрын
Would love to see where this is headed!!! Thanks for the video and the code!
@ramyzhang
@ramyzhang Жыл бұрын
awesome. really enjoyed this, and your explanations were easy to follow!
@burnoutauge6089
@burnoutauge6089 Жыл бұрын
great video! Did not expect you to have 138 subcribers. Keep it up!
@jamesbland5082
@jamesbland5082 17 күн бұрын
This is incredible!!
@hamderber4691
@hamderber4691 Жыл бұрын
Good quality, good information, guess I gotta add you to my Unity watch list
@rhedgeco
@rhedgeco Жыл бұрын
It would be an honor ❤️
@jkRatbird
@jkRatbird 11 ай бұрын
suuper insteresting! Please continue this series!
@rhedgeco
@rhedgeco 11 ай бұрын
Thanks! I'm back to it so maybe I'll make another one soon!
@jkRatbird
@jkRatbird 11 ай бұрын
hell yeea!
@chriswooohoo4518
@chriswooohoo4518 Ай бұрын
"Something that makes a good software engineer is knowing you're a bad software engineer" - I've never heard anything more true than this. Am software engineer working for 6+years now. Subbed.
@xxgoodideaxx
@xxgoodideaxx Жыл бұрын
Such a good video.
@jangebert6088
@jangebert6088 8 ай бұрын
Great video! I followed along very well an sparked lots of ideas! :D For those who do not want/can use the burst compiler, you can precalculate the sinewave for example and store it in an array and read from there. I have to check how this interacts with filters and such, but I got similar or better performance as with burst compiler and its super easy to implement :)
@rhedgeco
@rhedgeco 8 ай бұрын
Thanks for the comment! That is definitely a good way to go. In fact, I have a synth filter that caches the input from a runtime synth that does pretty much exactly this! If the data you are using for sounds can be prerendered, it's always a good idea to do so. Great tip! Glad you are enjoying my content 😁
@stevethepirate
@stevethepirate 3 ай бұрын
wow man this is really advanced. how do you think you would approach creating a standalone drum program that exports the tracks after the drum parts have been mapped out in an interactive way similar to a drum plugin? i doubt a unity app could plug into a daw so i think unity would need to export wave files as separate tracks of the drum kit.
@rhedgeco
@rhedgeco Ай бұрын
Yeah unfortunately unity does not have a lot of good ways of embedding itself into another app which would stop you from building your own VST plugin with it. But you could create a VST that relies on another process and uses whatever your choice of IPC to talk to your unity program.
@VenRune
@VenRune 7 ай бұрын
Very enlightening video, thanks. I did some work and found that if I use the OnAudioFilterRead to implement some procedural sound effects, such as playing the MiddleC sound when the keyboard is pressed. But I found that due to the different scheduling logic of OnUpdate and OnAudioFilterRead, there is an obvious delay from key press to sound playback. Is this implement not suitable for interactive sound effects?
@rhedgeco
@rhedgeco 6 ай бұрын
Interesting that you found the delay noticeable. In my experience even if it takes a while frame to register the key press and set the audio it's only a 16ms delay. How long is the delay for you?
@stephenkiser8243
@stephenkiser8243 Жыл бұрын
Love the video, but I'm super curious how you implemented the millisecond timer in the inspector?? Was this just some nice video editing for a visual helper, or did you actually get it to show in the inspector? I've been working in Unity for years but never seen any debug tool like that and I'm fascinated.
@rhedgeco
@rhedgeco Жыл бұрын
That's actually built in! When you use the OnAudioFilter read method, it displays the millisecond bar under that script. I agree it's very cool!
@ewwitsantonio
@ewwitsantonio Жыл бұрын
Super interesting! So glad I found your channel! I'm curious if you considered the "native audio plugin" route? I'm not asking because I think you should be considering it - just because I want to learn how to create my own synths for use in Unity and struggling to make a decision about how I can go about it. I'd love to hear your input. :) Here's another youtube video on the topic: watch?v=6SBjFPDrdu8 ( Jorge Garcia - Building game audio plugins for the Unity engine )
@rhedgeco
@rhedgeco Жыл бұрын
Yeah totally! I've actually done a fair bit of native plugin development, especially in rust. The only issue is that it's fairly difficult to reload native plugins at runtime. There are some ways, but its not super friendly. I found that getting used to the burst compiler was the easiest for fast and built in integration. Also the types that i make get to be shared between codebases instead of having to make duplicates.
@firezenk
@firezenk 8 ай бұрын
How did you show the latency in the script component? Nice video BTW!
@rhedgeco
@rhedgeco 8 ай бұрын
It just happened by default in the unity version I was using at the time when the script had a OnAudioFilterRead method. Seems like it doesn't now which is a bug. There are a few workarounds if you look it up on Google lol
@hjagu1323
@hjagu1323 Жыл бұрын
Wouldn’t it be faster to calculate the samples in a compute shader? Very great first video!
@rhedgeco
@rhedgeco Жыл бұрын
Great question! It would not for a few reasons. First being that compute shaders can usually only be dispatched from the main unity thread so it an sync with the GPU. All the audio processing happens on an audio thread. Which is also why I didn't use jobs. And the other reason being that data copying across the CPU GPU boundary actually takes a really long time. (In the order of a few milliseconds or more depending on the situation) At the end of the day, GPU is better for higher volumes of data processing anyways, and we are only calculating 2048 samples. An incredibly small number when it comes to GPU parallelism.
@BeardBarians
@BeardBarians 10 ай бұрын
why does unity use 48000 and not 44100 sample rate?
@rhedgeco
@rhedgeco 10 ай бұрын
It's set to 48000 by default purely because it's slightly higher resolution. But you can change it to 44100.
@Xeros08
@Xeros08 5 ай бұрын
How did you get that channels bar (The green dynamic bar that shows on play)? Just curious
@rhedgeco
@rhedgeco 5 ай бұрын
It happened by default in previous unity versions. They took it out for some reason. There are some hacks I've seen to bring it back though
@KentBrakewell
@KentBrakewell 2 ай бұрын
I was excited to try this - I cloned your repo origin/main as of 2023-11-10 but I'm getting compiler errors in the Synthic.Handlers classes upon opening the project in the Unity editor. "error CS0234: The type or namespace name 'Native' does not exist in the namespace 'Synthic' (are you missing an assembly reference?)". It feels like the Rust code needs to be compiled to reference "Lib", but I'm totally guessing and have never compiled Rust code. Any tips you can provide will be very appreciated!
@rhedgeco
@rhedgeco 2 ай бұрын
I probably need to put a note of this somewhere. But the original synthic did not use rust. So if you want to try out the version used in this video. Check out the old-synthic branch. Let me know if that helps!
@KentBrakewell
@KentBrakewell 2 ай бұрын
@@rhedgeco thank you, I will give that a shot! Are there performance differences between the two?
@rhedgeco
@rhedgeco 2 ай бұрын
@@KentBrakewell Nothing that should be noticable. Plus the rust version is more incomplete anyways. Should probably make the rust version an off branch instead of main
@mikeflower3308
@mikeflower3308 7 ай бұрын
using puredata is also another solution
@barisaxo
@barisaxo 11 ай бұрын
So uh, making optimized procedural sine waves in Unity is cool too.
@rhedgeco
@rhedgeco 10 ай бұрын
Lol yeah 😅 Im making more, there's just so much boilerplate and I forget that it takes some mental leaps to get to more complex sounds even though once you have programmatic waves you're pretty much there. Stay tuned for the next one!
@barisaxo
@barisaxo 10 ай бұрын
​ @rhedgeco Hope it's soon! I know these things are a ton of work, but I'd really like the see the process and result.
@rhedgeco
@rhedgeco 10 ай бұрын
@@barisaxo anything you are interested in in particular? I'm still flushing some things out so now's you're chance lol
@GAGONMYCOREY
@GAGONMYCOREY Жыл бұрын
You need a higher volume
@rhedgeco
@rhedgeco Жыл бұрын
Thanks for the feedback. I'll push those levels a little more next time!
@WeirdBrainGoo
@WeirdBrainGoo Жыл бұрын
I feel like the title is a bit misleading considering that you don't actually make music in the video. Maybe something like "Setting up the burst compiler to make procedural music in Unity" could be more accurate.
@rhedgeco
@rhedgeco 10 ай бұрын
Yeah that's a good point. Tbh I planned on doing more in the video, but it was getting to be a lot so I left it where it was. I've got new stuff coming soon so stay tuned!
@RikMaxSpeed
@RikMaxSpeed Жыл бұрын
Feels like Unity should really use C++, like the Unreal engine.
@rhedgeco
@rhedgeco 11 ай бұрын
Yeah it's all about what they are going for. C++ is harder to write and easier to crash the program while C# offers a faster development cycle and better errors at the cost of some performance. So while I agree, I see why they went with C#.
@camper-uz3wb
@camper-uz3wb Жыл бұрын
First
@rhedgeco
@rhedgeco Жыл бұрын
If there's one thing I learned in kindergarten, its that if one is first, one might also be the worst. 🤓 Good luck fren
@sovio4280
@sovio4280 7 ай бұрын
How can i contact you? Insta or something?
@rhedgeco
@rhedgeco 7 ай бұрын
My email is linked in a few places like on my GitHub. I just don't actively advertise it on my KZfaq so I don't get too much spam
How to turn PROCEDURAL MATH into MUSIC (actually this time)
6:39
Ryan Hedgecock
Рет қаралды 4 М.
How I Procedurally Generate Music (EXPLAINED)
14:18
Dennis Martensson
Рет қаралды 58 М.
Пробую самое сладкое вещество во Вселенной
00:41
3 wheeler new bike fitting
00:19
Ruhul Shorts
Рет қаралды 45 МЛН
ТАМАЕВ vs ВЕНГАЛБИ. ФИНАЛЬНАЯ ГОНКА! BMW M5 против CLS
47:36
ИРИНА КАЙРАТОВНА - АЙДАХАР (БЕКА) [MV]
02:51
ГОСТ ENTERTAINMENT
Рет қаралды 2,4 МЛН
Code-It-Yourself! Sound Synthesizer #1 - Basic Noises
28:50
javidx9
Рет қаралды 262 М.
Unity async / await: Coroutine's Hot Sister [C# & Unity]
16:18
How to make an Audio System in Unity | Unity + FMOD Tutorial
49:37
Shaped by Rain Studios
Рет қаралды 46 М.
Building Runtime UI with UI Toolkit In Unity
21:35
Game Dev Guide
Рет қаралды 28 М.
Can I Create Video Games Using SQL? (No Game Engine)
20:58
icitry
Рет қаралды 124 М.
The Wave Function Collapse algorithm
21:45
CodingQuest
Рет қаралды 275 М.
Procedurally Generated 3D Dungeons
9:42
Vazgriz
Рет қаралды 276 М.
How To Make Sound Effects For Games
18:54
Jonas Tyroller
Рет қаралды 352 М.
The Secret To Good Rhythm Games
15:50
Mental Checkpoint
Рет қаралды 143 М.
How to Make Adaptive Video Game Music
13:51
Tarro57
Рет қаралды 9 М.
Телефон в воде 🤯
0:28
FATA MORGANA
Рет қаралды 968 М.
APPLE совершила РЕВОЛЮЦИЮ!
0:39
ÉЖИ АКСЁНОВ
Рет қаралды 2,5 МЛН
Урна с айфонами!
0:30
По ту сторону Гугла
Рет қаралды 6 МЛН