What sound library do you all recommend for a C++ custom engine?

Started by
12 comments, last by RedBull4 3 years, 7 months ago

I'm looking around for open source, fast, and free to use sound libraries to use in my little opengl c++ engine. All I want to do is play multiple sound effects and play background music.

So far, I've found:

  • fmod: I'm confused if this is free to use or if it's good for small projects like mine. I'm interested though.
  • OpenAL: I read this was acquired by a company and is no longer free to use or not ideal for small projects. Is this true?
  • SDL: I know what SDL is but I wouldn't like to include such a large framework into my project, I'm already using GLFW and happy with it.

Granted, any suggestions are greatly appreciated!

Advertisement

fmod: See https://www.fmod.com/licensing#indie​ So basically yes free for small projects, put their logo somewhere, and you don't get source code or direct support from them. It does have a lot of features built in. If you wanted to distribute the engine to third parties, my understanding is you can't distribute FMOD binaries, they need to get their own licence and download themselves individually. You might ask sales@fmod.com..

You can use just some parts of SDL, for example you wouldn't need the image loading or text rendering libs. SDL audio is fairly basic though, basically just playing basic sounds/music “as is”.

I believe Creative still owns OpenAL. It hasn't really gone anywhere. OpenAL-soft provides a free LGPL software implementation of the API specification. I am not sure what the status is of even trying to get hardware support working even on Creative cards, but practically most audio is software these days.

On Windows XAudio2 is a nice option that full-fills a similar role of mixing multiple audio sources, dealing with different frequencies, 3D channels, DSP effects, etc. I found it really straight forward, at some point I intend to revisit OpenAL.

For OpenAL and XAudio2 loading various file formats etc. is mostly up to the user, they just provide powerful audio processing. Personally I found wav files pretty easy, as is Ogg Vorbis and I suspect the other Ogg audio libs. A little bit of plumbing code to move audio samples from one to the other.

Then obviously you have the actual OS level interfaces. On Windows these days there is WASAPI and on Linux I believe PulseAudio. These are however much more basic, any mixing/effects you need to do first. OpenAL, FMOD, SDL, XAudio2, etc. send their final outputs to these.

Audiere is a C++ sound library that you could use to accomplish that. It's simple to use also.

Check out my project Astorum! https://www.facebook.com/Astrum-111692220617440

There is not much open source and free these days because Audio still is a myth that not much people are doing these days in games business. OpenGL for example is common established and widely used so you'll get much tutorials and resources while there isn't a standard solution for audio. In the end, doing audio stuff on your own just using OS APIs is also simpler as it "sounds". As mentioned WASAPI exists since Windows 7 and all you have to do is to calculate the audio mixing on your own and provide a continous stream of audio data.

In modern games these days either you have your own implementation of an audio engine like Unity does or you have third-party software already included, for example FMOD in Unreal. FMOD and Wwise seem to rule the market at the moment

Could have a look at https://github.com/dr-soft/miniaudio​
I can't really recommend this, since i've never actually used it, but seems decent (and simple) enough to give a try.
PS. It's a C lib not a C++ if that matters you

This looks interesting: https://sol.gfxile.net/soloud/

FMOD is very simple to use. I wish it had better samples as I recall having some problems that weren't answered well in documentation that I had to figure out. And the license does say its free under a certain company revenue.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Thank you all for the great replies! Granted, I got lots to read, mind you…this aint easy.

You could just use the native sound API-s (mmsystem on Windows, alsa on linux), using them is just as 10-20 lines of C code as using a glorified library of someone.

For decoding music, i can recommend to use this public domain ogg loader that has no library dependencies https://github.com/nothings/stb/blob/master/stb_vorbis.c

I also use the native audio API for each platform, but instead of mmsystem I use WASAPI on Windows.

This blog post might be helpful if you go this route: https://ourmachinery.com/post/writing-a-low-level-sound-system/

And there are also some episodes of Handmade Hero about audio mixing.

This topic is closed to new replies.

Advertisement