Chapter 12. Sound / miniaudio.h

Contrary to my expectations, this topic turned out to be not so complicated. And basically it came down to finding the right audio library/API.

I've checked a few, including OpenSL, OpenAL, irrKlang, SFML, FMOD, PortAudio, SDL2, etc. Many of them, despite their own claims, are not truly cross-platform (or I couldn't get them to run), some are not even "audio APIs" but multimedia device interfaces . And most of them are huge and heavy.

I continued searching and finally came across miniaudio.h by David Reid, which well deserves to be #1 in relevant Google searches (I lost too much time checking other useless or misleading options). A single h-file 2-level API. Nice, compact and convenient. Only the samples list confused me a bit. The correct sample to start with is "Engine Hello World", NOT a "Simple Playback".

On my side it's implemented in MySound class. Extra parameters in my calls allow to regulate volume and pitch of the sound. Source code will follow.


Leave a Reply

Your email address will not be published. Required fields are marked *