Game Programming III – the fifth week, AudioManager using FMOD part one (1)

fmod-new-logo-transbg

Hello!

This week I’ve been mostly working on getting a working audio manager class for the third and final assignment for this course. The audio manager is meant to load and play sounds or music that will be used in a 3D game. I’ve created this class with the FMOD library.

http://www.fmod.org/

The reason for using FMOD is mainly because it was recomended by our teacher, but also because it is used by several large game titles in the industry, like Diablo 3, Crysis, World of Warcraft and many others. It is also integrated with game engines such as Unity3D or Unreal Engine.

http://unity3d.com/

https://www.unrealengine.com/what-is-unreal-engine-4

It is therefore a good idea to have some experience working with it. However its documentation leaves something to be desired, at least if you are new. I’ve certainly had problems finding what I need in the documentation anyway.

For example I could not figure out how to dynamically create sound channels, until I finally found a forum post where I discovered that you can only create a pointer for a channel without making a new object for it. That is created as soon as the channel is used to play a sound, which makes me wonder how I’m supposed to set the sound for a channel before playing anything on it without getting an access violation.

Another problem I had was with FMOD’s own error checking function. It’s great that they have one, but it seems you cannot always count on it. In my case, I wanted to add some code that checked if a channel was busy before trying to play a sound on it, after which I added an error check to see if the function had worked properly. I kept getting an error that told me I used an invalid handle for the method that checked if the channel was busy. This confused me as it is supposed to take a boolean pointer as argument, and I did give it one. Finally I commented out the error check and everything worked just as it should, menaing the error message was faulty. I might have missed something that caused it to behave this way, but I doubt it. There’s not a lot of code in this class and I’ve gone over it I don’t know how many times this week. As I said, commenting out the error check made everything work just fine.

The audio manager is mostly finished at this point, I still need to make a proper shutdown method to avoid memory leaks and clean up the code in general. I might also need to add some functionality to it if the assignment calls for it.

https://github.com/Carveca/FMOD-project

To be continued…