Technical Devlog: Implementing Audio into my Game Engine
ฝัง
- เผยแพร่เมื่อ 5 ก.ย. 2024
- Devlog video about "Homegrown", a casual farming game I'm creating using my own engine. In preparation for the UI overhaul I'm implementing the audio system into my game engine this week.
Support the channel on Patreon and get access to the game & code for Homegrown, the city-builder, and Equilinox:
/ thinmatrix
Play my previous game "Equilinox":
store.steampow...
You can follow the progress of the game on my social media:
Twitter: / thinmatrix
Instagram: / thinmatrix
Facebook: / thinmatrix
Trello: trello.com/b/W...
Email: thinmatrix@gmail.com
Background music by Jamal Green:
open.spotify.c...
Outro music by Dannek Studio:
/ dannekstudio
#devlog #Homegrown
This is a much more technical devlog than usual so if that's not your thing then this one might not be for you (and if it is your thing then yay, enjoy!)
We'll be back to more visual features next time with the UI makeover.
I love this kind of content, which is a bit more technical. Congratulation for the huge amount of progress. :)
I'm learning game development and i like both or them but this type of content i like most
I agree, this is the content I like the most actually! :)
I actually quite enjoy the more technical content. I find it not only interesting but also very inspiring. I am an aspiring game dev as well so these videos often fuel the muse haha
Both are great but as a non game developer i really enjoy watching technical dev logs cuz it allows me to see a different aspect of programming
Everyone crying over unity while this mad lad just chills with his own engine. Absolute legend.
lmao, actually so smart from thinmatrix to do this looking at it retrospectively. Best unintended business decision
You're saying this as if it's not actually a problem that unity's doing this.
1. Unity fixed pricing with a 2.5% revenue cap, becoming cheaper than unreal.
2. Making an OWN engine consumes time, you have to be VERY GOOD at math / vector programming to just have some level of a simple camera rendering a cube.
3. Even making an engine that returns an executable application is a real PAIN. now imagine trying to produce multi-platform game on an own engine 💀
Engines costs money because they save time and resouces. You can always go godot but it has its sharp edges too.
@@pedroduran8927 Why even touch godot when king released their own engine for all to use? Both Unity and Godot have a smiliar issue - they are led by a buffoon.
@@pedroduran8927ehhh this is built on lwjgl cross-platform isn’t a huge issue here
The procedural sound system you made solved a problem I wasn't even aware of! I suspect most game devs will run into that issue at some point. Glad to be following this series.
I'd assume as a by product of this, when it comes to implementing Sound to your Minecraft Recreation that this will majorly help!
Nice to see you also watching ThinMatrix, FinalForEach! :D
@@Zonix_Official I stand on the shoulders of giants! ThinMatrix's videos is how I learned to make good looking water graphics after all.
Man the procedural sound effect thing you did for variable interaction time is so cool. Great solution to that problem.
I think this is exactly how it works in Minecraft
Can we talk about how good this transition at 1:26 is ? good work man !
He does it a lot but everytime I see it I still marvel at it lol it just looks so clean
Love the sounds! Especially the procedural ones - that's so cool!
I appreciate the more technical videos! The procedural sound generation for the arbitrary length actions was super nice!
For building compound sounds, I would recommend using a builder pattern, as you're effectively building a track. You would create a compound sound with an add track method that takes a track, and returns 'this', allowing you to chain addTrack function calls, that way you don't have a block of variables defined in a row like at 12:35 with incrementing variable names like track0, 1 2 3. You've used the builder pattern with sound 2D builder I think it would work really well with compound sounds. If only to keep consistency of the code. It's still be a good idea. You're using the factory pattern, for the digging sound effect which is a good idea. When you combined with patterns, a new world opens up. Imagine a sound effect factory, that can create the sound effect you need, and using the builder pattern to configure the given sound effect as a compound sound.
Actually I prefer this sort of devlog videos to where only the game play features are shown. 👍👍👍
It'd be cool to change the pitch of the sound during the digging or water pouring process so the player would have an intuition on how long the action would take without even looking in the screen.
Nice idea!
@@ThinMatrix To add onto this, it'd be an awesome bit of polish to have, for instance when harvesting a section of crops, to have the "harvest" sound rise in pitch over subsequent harvests. So basically crop 1/5 will be the lowest pitch, 3/5 being in the middle, then 5/5 being the highest, scaling in pitch depending on the size of that particular group of crops.
It builds a sense of rising accomplishment when you have an audio source do that, very similar in to how Minecraft does their sfx for breaking blocks. Or y'know, just implement it on a smaller scale and just do it for each individual plant. I think it'd fit right in with your farming game here!
And not everything has to follow this system, you could also increase the frequency at which sounds are played to give a sense of speedup.
That way not every action sounds like a fire alarm.
I love how far you have come with this and like I love how good the videos are getting with all the transitions and all looks so good! Have you got a goal in mind for releasing this game? I also love the out-of-monitor transition so much haha also pretty neat you are using ur own tutorials to remember stuff!
Thanks! I'm currently aiming for end of next year, but that might be a bit optimistic.
@@ThinMatrix That is awesome to hear sadly I was abit to eager to try it out so its awesome you uploaded it on Patreon!
End of next year ?!! But your game and his loop already is so polished, adding new content like plant and tool and farm upgrade okay, but if you leave yourself until end of next year it mean we haven't seen half of the systems and mechanics build implemented yet, right ? 👀
It’s amazing what sound effects and music can do! Brings the game to life 😍 keep it up!
Elegant solution and it sounds like it works well. My main suggestion is less harsh sounds like metal and hard rock. And more soft crunchy sounds.
You have a brilliant mind, and you are creating the most beautiful little garden simulator to cultivate peace.
I love it how you carefully explain everything while also making a game using Java, most people just use Unity and C# to make basic stuff but you made your own engine! Would love to playtest someday, keep up the awesome work!
Uff Amazing video...technical videos also rocks and people like them. Thanks for taking some of our advices!!
I love these devlogs
I love the secateurs sound! So clean and calm.
Wow! The sound generator idea for the tools was really smart! 😱
Watching this while writing my own AudioController for an audio book app.
you can break the song in stems, intro, chorus, bridge and outro and then randomly play the chorus and bridge a few times in variations and cap them off with intro and outro. additional chorus and bridge chunks add to the dynamics
As a bit of fun, you could try recording real-world sounds of you performing these tasks! Also, adding a start sound may also be value for certain actions. Such as the sound of a spade hitting the dirt. Loving this series so much, thank you for sharing!
1:25 This transition was unreal!
Hey man, I really appreciate you and your videos. I used to dream of being a game developer when I was younger, and your videos were my obsession. That was probably around 2015-16 when i was 11-13 years old! Now I am in college for Cybersecurity and am so happy to start watching your content again! Thanks for sticking around man and I am real proud to see how far you have gotten. :)
Your OpenAL tutorials helped me to add sounds to my game, just for the effort and work it took you to create all those tutorials (and the OpenGL ones) I'm wishing you the best, you're an inspiration for all indie gamedevs! Thank you.
Oh yes - Great idea layering the sounds - Very satisfying to listen to
I'm currently working on making my own GUI library. Definitely taking some inspiration from this video 😬 Excited to see what you'll do with the UI!
Those procedural sounds are incredible! Bravo.
Audio is one of the most underrated parts of a game, so its cool to see a Devlog about it. Great audio will not be noticed, but bad audio is heard by everyone, it seems you got a great start!
That's impressive how well all of these parts work together. The procedural audio sounds really good, neat idea!
The procedural sounds are beast my dude.
Congratulations, this really adds a great layer and makes it so much more immersive. The way you've created the procedural sounds is genius and applicable for much more than an audio system.
I love the idea of the CompoundSound. Very neat :)
I just found your TH-cam channel. It is great! I love the technical videos too. hope the game development stays smoothly. Keep up the good work!
Procedural sound (including the click sound) is such a nice QOL thing, makes the game feel so polished.
Your solution to problems is always elegant and inspiring. I didn't expect to enjoy this style of video and I was sad when it ended. Well done!
1:25 dat transition though
i always find it incredibly impressive and admirable when someone creates their own game engine for a game
love how the game looks, keep it up!
Very interesting episode, I enjoyed the deep dive :)
Brilliant to see how you are tackling sound. My last game had a bunch of issues with sound and I've struggled to find good videos explaining whats going on. This helped
Bro had the audacity to use Audacity.
Great Video my man, really enjoying to see such a progress in more than a month!
I very much enjoy those more technical devlogs, do not be afraid to make more like that! :)
I'll watch your every single video at least until you finish a city building game, you have my word!
I love these technical devlogs 😀 but I also enjoy the other ones 😊
This is a really cool solution to the sound repetition and definitely adds juice to the game. I am thinking that as the player progresses so will the soundscape of the gameplay loop, which is neat.
Random clicks sound cool; equally cool might be a step the pitch (up to a limit) in ascending or descending order. ;)
The way you implemented the compound sound effects is really clever, well done. Might have to borrow that idea in the future!
The procedural sound effects really give a lot of life to the game. Really really good implementation :D
Ohh.. making your own engine.. thought this was just a game devlog.. now I might have to go back to your first
For me the hardest part is to decide what needs to be in a new class and separating different ideas to different files.
Same brother 😂
I am quite new to your channel and I just realized that you do not "only" develop a cozy farming game, but that you use a self-made engine, too! That's so cool, much respect! 🙂 Seems like a big benefit in the current situation, hehe.
I really like the idea of the compound sounds, they give a nice polish to the general sound design and make the tasks feel less repetitive.
As another comment already mentioned, it could be nice to be able to hear the progress of a task, e.g. by raising the pitch after each tile.
Very nice devlog! :)
I like the information presented and the game is looking good!
That shovel sounds great!
This devlog was so interesting and useful! It's amazing how much sound does to a game.
Dude this is literally perfect, I wanted a good way to implement audio into my game and while it's not gonna be as complex as yours I wanna get some inspiration for future titles. Keep it up!
Super impressive work! Keep going! :)
Love the procedurally generated sounds! Cool way to create it! Have u thought about raising the pitch when u dig a hole? Idk it just felt would make the pop more satisfying.
Dude, the procedural sound system is amazing! That was so awesome to see in action!
The procedural sound system was such a cool solution, loving the videos!
This is so inspirational! As a new viewer, I'm absolutely amazed!
Brilliant work as always. The sounds add so much weight to the game interactions. Good job!❤
You inspire me so much! Despite I'm more towards meat and stuff, I'm loving your game development!
Such an absolute chad! You are a really good programmer sir! Loved the sound thing. Loved it.
Surprisingly interesting dev log. Good stuff!
Dude your home is so peaceful and clean, always admiring that in these videos :D
the fact that the sun is literally kissing you while you're coding is incredible
Would love to see a video on how you manage this project. Loved your Trello board, so simple and functional.
Man i just want to say, I'm still addicted to equilinox, it's such a good game. I have so many high hopes for this latest project
I love these more technical videos !!
Gotta say, even those placeholder samples don't sound half bad! Looking forward to the next devlog as usual!
1:27 very smooth!
Hey, really like your videos and the games you produce :) I also really enjoy the details you add to your videos like playing the music in the background the way your are describing it in the code :)
One suggestion (that you may have already done but it's hard to tell) is if you click to perform an action such as digging/planting, if you don't let go of the click but move the tile to another valid tile, that the action still performs so the user doesn't have to click each individual tile. I think this would be something that people probably won't notice if it exists but definitely would notice if it was missing. Love the technical video though!
Thanks! And that's already how the tools work :)
Can I just say how much I love these more technical videos! I was curious also @ThinMatrix what Java version and lwjgl version are you building the game using?
Super cool devlog! Loved how you approached the procedural sfx. Keep up the great work!
Really enjoyed the insight!
love the content thinmatrix!!!
Hey dude! Love your content
Thanks! And yeah, I'll do that during the upcoming UI updates :)
Amazed to spot an eclipse user in the wild 😁. Game's really starting to shape up, keep up the good work!
The sound system and sounds are great, most of them in my opinion are production-ready (unless of course a different feel is intended for the game). The only suggestion is the UI click sound, it's a bit loud and intrusive, and some of the sounds are spatially shifted when using earphones
Super inspiring and the way you structure your work.. impressive!
Epic stuff bro! Keep up the amazing hard work!
really liked this video :) the end result sounds great!
Wow, please talk more about the engine. Would love to hear more about it.
Don’t know the exact style you’re going for, but I feel like the game could be more relaxing with a less realistic style of sfx. I’m thinking more in the realm of mini motorways where it’s calming little blips and bloops that make the game somewhat relaxing and satisfying. Anyways, the more technical devlog was awesome and I really enjoyed this episode and the way you showcased and explained parts of your thought process and code!
That is nuts!
I think that explanation of audio buffering explains how games with a lot of dialogue are able to have skip functionality. It'd probably be a lot jankier if it had to load massive audio all at once, quickly, every time you hit skip
you should add a retry to creating the openal context(s), sometimes it seemed to fail for me for no reason when the CPU was under high load, but worked when retried
Later on I would love it if you could add a shop were you can buy items for maybe a house that you could buy or upgrade
Those compound sounds are fantastic... love your approach.
I'd love to see you mention something about your testing in this project, I assume you're unit testing alot of this? ....
Great work as always! Sounds 100% make a game feel more alive, its why i like to do audio passes every now and then to get them sorted.
The proc gen audio you have is so cool! Definitely something I want to try out at some point my self!
Also curious, for the click sounds, you have 5 different variations, would randomising pitch not do the same? I can see it still sounding maybe too similar so maybe variations makes more sense
You should avoid using the class LinkedList, and instead use ArrayDeque, has the same functionality, actually even more!, uses less memory and is more performant, the implementation uses a compact array which works better with the CPU caches.
Good to know, thanks for the info!
Ah, good ol' data structures.
Which to use depends on the access patterns.
The advantage of the linked list is that insertion / removal is a fixed cost, even when you're inserting / deleting in the middle of the list. Because you're just changing some pointers (insertion is pointing the previous node at the new node and having the new node point to where the previous node used to be pointing, removal is just pointing the previous node to the node after the node to be removed, so the node is pulled out of the list).
The disadvantage with linked list is, yes, that the nodes are allocated / deallocated individually and can be scattered throughout memory, so that's not cache-friendly. And that you always have sequential access, as you've got to start from the start and follow each link to find an item (poorer random access).
The compact array has the advantage that it is cache-friendly, because you're packing all the items next to each other, and that you can use random access (because the item at index n is at offset "n * sizeof(item)" into the tightly packed array).
The big disadvantage of the compact array is insertion / removal - particularly in the middle - as you've got to, for insertion, expand the size of the array, copy all the data after the insertion point further back to make room for the new data, insert the new data. For removal, you've got to copy all the data after the block to be removed forward to plug the gap (then shrink the array allocation with reallocation). Or, if you don't have dynamic reallocation for the memory, you're just recreating the whole array each time, which means copying absolutely evertyhing.
So the problem with the compact array is that, well, it's compact. You can't have gaps, and so you have to move / copy data around. And if your data structure is large, then all that copying is going to be costly - and the big problem is also that the performance is tied to how big the data structure is, so small amounts of data copy quickly but a large data structure full of data takes longer because there's more copying.
But note that, with the linked list, if the data structure gets large and you need random access - I need the "last but one" item, say - then because it's sequential access, I've got to step through the whole list (but one) to get to it. With a compact array, I can just grab the data at offset "(n - 1) * sizeof(item)" and instantly jump to any index.
So which is best depends on access patterns. If there's lots of insertion / removal all the time, then the linked list wins, for not requiring any data copying. If you need random access, the compact array wins, as you can calculate and jump to any index, while you have to go through each item, one by one, with a linked list.
There are other data structures. The "pool" is an awesome hybrid solution, often used by games.
The actual data is stored in a compact array. You just allocate a normal compact array of n items for storage. But then you have another "index" data structure alongside it, which tracks which elements of our storage space are in use.
When I need to insert, I scan for the first empty slot and use it. When I remove an item, I just mark that slot as empty - allowing it to be reused by subsequent allocations.
It's a compact array, but I can now have gaps. When we insert new items, we plug the gaps. When we remove items, we create a new gap, which can be reused by a subsequent insert later on.
But the real beauty of this approach is that the accompanying index is a different data structure. So you could use a linked list - well, two linked lists, one is a linked list of the items, the second one is a linked list of empty slots (the "free list"). You allocate the first item from the "free list" and put it on the "used" list. Removal is moving an item from the "used" list to the "free" list.
So you can have the quick insertion / removal of a linked list, but the data itself is in a cache-friendly random access compact array. Best of both worlds, and - the big reason why games often use memory pools - is because it cuts down on calls to OS memory allocation / deallocation, as you've got a pool of memory and you just keep reusing it over and over. The only time you call the OS allocation is if the entire pool is full and you need to expand it to accommodate more. It's cache-friendly and has random access. But the accompanying index structure - keeping track of what's in the pool - can be another data structure that has its own advantages. You can use linked lists, or another compact array, or a hash table to index into your "pool" compact array storage.
Indeed, the "pool" approach basically decouples indexing from storage. You store in the compact array, but you index into it using some other data structure (or, even more powerfully, you could even have multiple indexes - you could have a hash table on "name" and also another hash table on, say, "size" or any other data. As the index is now separate, you can have multiple indices for optimising finding the data in different ways - at the cost, because there's always a cost, of having to maintain multiple indices on insertion / removal).
Yeah, the advantage / disadvantage of being a C / C++ programmer, we end up in the weeds of this stuff all the time. But the plus is because you've got to do this memory management stuff yourself a lot of the time, it makes you think about it all and choose the most optimal data structure for each instance (not just LinkedLists for everything, everywhere, all the time).
But, as I say, for games, the "memory pool" is the perennial favourite. It's built on a compact array, so it's cache-friendly and random access. You reuse slots, so you're only ever hitting the OS allocation when your pool is totally full. For insertion / removal, you're not copying actual data, you're re-arranging the index that just points to the data in the pool.
Decoupling the data from the index into the data means you could have multiple indices for different access patterns (one index on "id", one index on "name", one index on "least recently used" or whatevever) and can mix and match different indices with your underlying storage. So, for example, the index could be a stack or a list or a tree or whatever, which just provides an index into your compact array, where the real data is stored.
Yes, sometimes, ArrayDeque will beat LinkedList, as it's cache-friendly. But it really depends on your access patterns and size of the data (if each item in the data structure is bigger than a cache line anyway, it doesn't even matter, as you can't fit it in the cache and it's a cache miss every time).
The real thing to do is look at your access patterns and then choose accordingly. Though, sure, all other things being equal, ArrayDeque probably works for what you're doing and, therefore, will likely be the better choice. But not always.
The underlying wisdom is that these things are always case-by-case - as it depends on how you use the data structure (e.g. do you need fast insertion / removal as you're doing it all the time? Is your access always sequential or can it be random access?).
And, in the end, always profile it. If it's "good enough" then leave it be.
As programming god Donald Knuth would have it: "premature optimisation is the root of all evil". Really, only optimise when you need to, as the thing's chugging and laggy, as you develop it. Do an "optimisation sweep" after you're finished coding it all to lower that "minimum spec" for your game.
Don't optimise early. Not least because you could be wasting your time. For example, I get a sort function and then I drop down to assembly language to really optimise every last CPU instruction. Cool. It's a super-fast sort. But then I re-visit the design and algorithm. If I move this here, if I change this... cool, now there's no need to pre-sort the data on-the-fly. I don't need that super-fast sort algorithm anymore, as I've got something even faster (another Knuth quote: "the fastest code is the code that never runs").
Do optimisation at the end - only do optimisation during development when you've got no choice, as it's just too damned slow and laggy without it - and then always optimise "top down". Start at the highest level and move down to the lower levels. There's a "directionality" to optimisation, as noted, so you don't want to just be "undoing" all your previous hard work all the time.
Also, always start with the overall algorithm and data structures, because those are the biggest wins. Going from a linear search through an array to a hash table - from "O(n)" to "O(1)" - will massively improve your performance. So much so, that's probably all the optimisation you need to do for excellent performance on everything. If you find yourself amongst the weeds of individual instructions, then you're doing it wrong, unless it's the very last bit of optimisation you're doing right at the end (and, with deadlines, you'll probably never get there - but if you've chosen all the best algorithms and data structures from the off, you won't need to be in the weeds anyway).
@@klaxoncowThat's a lot to take in, but thanks for taking the time to share. Learnt something new!
@@pritamdavis Yes, apologies, as it is quite a bit of text to read. Unfortunately, it's just not a subject you can easily summarise - I mean, "data structures" is often a whole module (or two) unto itself on university courses. Like, it's a lot of text, but this is the summarised version, believe it or not. 😁
Maybe you could buy decorative things to your house and your farm with the money from the crops etc. Also, you could invest and improve the town and the stores with the money you make.
You know you're talented when you watch your own tutorials
Or just forgetful ;)
@@ThinMatrix you can be both!
1:47 "OpenAL library" => open audio library library.
I always wonder how do you have such a full Trello board and forward thinking plan, it'd be great if you explained ur planning process to us meer mortals. I've worked in software companies mainly in sprint and with rapidly changing software requirements but I've never worked through a project begining to end with planned steps and it's refreshing to see you doing it
Yes that would be very helpful
I'm in programming since I was 14. This will be 18 years now. It's not like I have spent those 18 years programming (however, in the hindsight, I wish I did). Nevertheless, I could be sitting there for a month and would never figure it out, that repetitive sound is annoying me, and some procedural generation is required. 😐 You da boss!
That "exceptions" even exist is the second biggest mistake in Java (after null). They enable lazy handling of unexpected events. Some newer languages avoid this. Note this is a criticism of the language, not its users.
Thanks for the videos, they're always insightful! And your work environment is truly inspiring as well!
Maybe it's cool to add wild animals that attack the farm. To combat them we can buy farm cats and guard dogs. And take care of the pets. Or attract pollinators and birds of prey. This creates a ecosystem like they did in biggest little farm documentary. I think this makes the game stand out from other farm games.
I was at a LUG meeting so I missed the upload 😢. I can watch it now though!