Jump to content
  • Advertisement

making sound support in my engine

Recommended Posts

Hi all,

I have written a mobile game engine in OpenGL ES that run on Android (thru NDK), iOS (Objective C) and Desktop (GLFW),

Writing an engine in straight OpenGL is easy since it is standard across, the rendering that is.

Now I am planning to integrate the sound functionality to it, I did initial researched and there is a library called OpenSL ES for android.

But i want to write an engine just like OpenGL that i can standardize for the 3 platforms, what are my options?
I mean i can just design an abstract and wrap OpenSL ES a generic class but what are my options for the 3 platforms?

Android - OpenSL ES

Objective C - ?

Desktop (GLFW?) - ?

Thank you in advance!


Share this post

Link to post
Share on other sites

A generally compatible enough choice is OpenAL, an equivalent of OpenGL. The vendor or community's implementation (OpenAL Soft) could cover all your engine's target platforms. Few cons: macOS would deprecate OpenAL support from version 10.15; The community is less active than OpenGL's; No further successor standard so far.

Personally I recommend you take a look at FMOD or Wwise, they are both widely adopted by the industry nowadays, and have more advantages around the maintenances, user/dev community, and software maturities. Wwise encapsulated the low-level audio business tighter than FMOD, in contrast, it's easier to get your hand dirty through FMOD. They both use Event-Driven design for high-level communication between the host application and themselves, and they both have the (almost) unified implementation across different platforms. But since they are targeting the actual products so the API is more verbose and messy, the learning curve would be a little steep.

Share this post

Link to post
Share on other sites

You may already be aware of this, but OpenGL is deprecated on Apple platforms. Realistically I suspect it might continue to be supported for the foreseeable future, but the fact that it's deprecated might be worth keeping in mind.

Regarding the audio issue, I'm basically working on the same problem right now, so I'll comment based on my experience so far.

As zhangdoa mentioned, there are professional/commercial third-party solutions available if that's an option for you. There may also be free/open-source cross-platform solutions, but I don't have any suggestions in that category off the top of my head. There's OpenAL, as mentioned previously, but (also mentioned previously) it's deprecated on iOS. I'm not sure what its status on Android is, but it doesn't seem to be the recommended solution in that environment.

You mentioned desktop, but didn't specify platforms. If you're targeting e.g. macOS, Windows, and Linux, obviously that adds some complexity to the problem. I'm currently just targeting iOS and Android, so I'll stick to commenting on that.

I don't know if OpenSL is available on iOS (I Googled but didn't find a clear answer offhand). iOS offers various technologies though, such as AVAudioEngine, that are fairly straightforward to use.

Things seem to be a little more complicated on Android. Options include:

- SoundPool for short preloaded sounds. Its feature set is fairly small, which can make it a little difficult to work with, and there have been some reports of environment-specific bugs (although that seems common for Android in general).

- MediaPlayer for longer sounds (e.g. music). There may be problems with seamless looping when using the 'looping' feature, which can be a showstopper for e.g. games. There may be some workarounds, but I don't know how reliable they are.

- ExoPlayer is an open-source third-party alternative to MediaPlayer. Empirically it appears to support seamless looping, although that may be environment-dependent.

- AudioTrack, which is lower-level and requires more effort to use.

- On the native side, there's OpenSL, the newer AAudio, and the third-party library Oboe, which wraps both of these. These are all more complicated, I think, at least compared to e.g. SoundPool and MediaPlayer.

The seamless looping issue seems to be a vexing problem. If it wasn't for that I'd just recommend SoundPool and MediaPlayer. You didn't mention what sort of audio features you need though, and if you're looking for e.g. complex 3-d audio with effects and so on, then those tools may not be sufficient.

If you need more input, it seems like some relevant questions would be what desktop platforms you want to support, and what sorts of audio features you need.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!