Skip to main content
GameDev.net gamedev.net
🔒 Locked

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

Started by EBZ Aug 20, 2020 at 9:09 PM 12 replies 35.3k views
Original Post
EBZ
EBZ

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!

SyncViews
SyncViews

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.

Shaarigan
Shaarigan

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

aclk
aclk

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

dpadam450
dpadam450

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 
EBZ
EBZ

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

Geri
Geri

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

kop0113
kop0113

I recommend OpenAL Soft. It is small and portable to different operating systems.

The free software implementation can be found here: https://openal-soft.org/​

It is LGPL licensed which means it is free to use forever and so long as you don't statically link against it (i.e using a .dll is fine) then you don't need to release your code under the GPL if you don't want to.

It is fairly easy to use for a positional audio library. There used to be a good tutorial on this site but I can't find it. I can point you towards one of my old projects with it in: https://github.com/osen/software-3d-renderer/blob/master/src/qplatform/Audio.cpp​

Final thing I recommend is, rather than moving the “virtual ears” around, just pass object positions through the same view matrix you use to render them to the screen. I find this much cleaner and more flexible to get audio sources in the correct location. I am rambling, you will probably see what I mean when you get to it.

http://tinyurl.com/shewonyay - Thanks so much for those who voted on my GF's Competition Cosplay Entry for Cosplayzine. She won! I owe you all beers :)

Mutiny - Open-source C++ Unity re-implementation.
hplus0603
hplus0603

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

Absolutely! mmsystem (wavOutOpen() and friends) was designed for 16-bit windows, where Sound Blaster DMA buffers were the other alternative. It's not a low-latency API, unfortunately. WASAPI can easily get to 30 ms end-to-end latency, though, which is usually enough for most games. If you need better than that, you really need bespoke APIs like ASIO, anyway, or a wrapper like PortAudio (which is still about low-level device access, not “play these sounds” high-level stuff.)

enum Bool { True, False, FileNotFound };
RedBull4
RedBull4

SDL2 : D

None

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.