Sound/Channel handles and FMOD abstraction

Hi all,

I’ve been integrating FMOD Core into an existing C++ game engine to replace an outdated audio engine. So far it has been quite smooth and generally worked great!

Regarding abstraction – Currently I’ve just been hiding FMOD behind a SoundManager class and passing back an integer ID to the Channel. I’m doing something similar for sound banks and for channel groups.

I started wondering, since FMOD channel pointers are just a 32 bit handle anyway… are we expected to just pass around the raw types instead?

I don’t love indirection from a handle to a handle, but then again I don’t exactly know what I’m doing. I’m curious what real world implementations tend to look like since I have very little experience in this area!

Thanks (:

It sounds like you’re taking a more data oriented approach, in which case passing back handles, and using static functions belonging to your SoundManager class seems appropriate. Passing the raw FMOD types would be fine in that situation, unless there’s a specific reason to use the ID system you’ve described - maybe you want to individually identify FMOD objects but abstract the functions belonging to those objects, or rely on the ID system to be able to differentiate each object more easily.

A more object-oriented approach, which we’ve seen a lot of larger and more complex projects do, would be to try to decouple your own code from the FMOD API to invert their dependencies - for example, by using an abstraction, such as Channel object that manages the underlying Channel and handles its functionality, instead of what is essentially another handle system with the Channel IDs you’ve described, FMOD and your own code would remain loosely coupled.

Ultimately, how best to handle this will depend on the needs and complexity of your project, and what approach you’re trying to take to the audio functionality, which is something that only you can judge.