A good sound library with C?

Started by
7 comments, last by rakifsul 11 years, 6 months ago
I need a good sound library that I can use with a commercial game and is cross-platform. I need it to be as simple as the following code.sound testsound;
testsound=MP3_LOAD("sound.mp3");
while(1) {
    // Input and stuff.
    if(SOUND_PLAYING(testsound)==0) PLAY_SOUND(testsound);
}
I cannot work with SDL Mixer because it limits me to only so many channels, accepts only WAV files for sound effects, and even though the sound for a buzz that I want to constantly loop has no place in it without audio, it sometimes skips when looping (but sometimes does not; it repeats properly for a few repetitions and then there is a delay and then it repeats well again and it repeats).

Should I use OpenAL audio? Can I use it in a commercial game without having to pay the creators or anything? Does it limit me to only a fixed number of channels so I cannot make a (non-music) sound effect repeat if I so please? Can I use MP3 or another non-WAV format for sounds? Is it cross-platform? Will looping be smooth?

Thank you for your time.
Advertisement

Should I use OpenAL audio?

It is cross plattform, but I have not the best experiences with it. Have you looked at FMOD.


Can I use MP3 or another non-WAV format for sounds?

The file format is often not part of a sound API (like a image file format jpeg,png etc. is not part of a render API like OpenGL/DirectX). As alternative to mp3 you should take a look at ogg-vorbis.


Will looping be smooth?

Most APIs will enable you to do smooth looping, but often not out of the box (you need to implement some kind of streaming and manage the sound buffers yourself).
Yeah, mp3 support is going to kill you, as to ship an MP3 library, they need to license the codec.

So, commercial products like FMOD obviously can get away with it, but for free packages ( that care about being legal ), it's a giant deal breaker. As ashaman said, look in to Ogg. If you need to convert, there is always audacity.
Thanks for the suggestions! I will definitely use the OGG format. You have both mentioned FMOD as if it is an audio library similar to SDL Mixer that I can just include by doing #include . Is it this? Is it free for commercial use?

Is it free for commercial use?


FMOD is not free for commercial use, but it's not massively expensive.

OpenAL would be a decent choice, but I feel it's a bit more low level than FMOD. I see OpenAL as the audio equivalent of OpenGL while FMOD would be the equivalent of something like OGRE or Torque.
Do you know if OpenAL is free for commercial use? Does it limit me to a certain number of channels that I must poll to see if a sound is playing or can I just do something like in my example code in the first post? Is it cross-platform? Does it support OGG?

Thank you all so much for your time.

I see OpenAL as the audio equivalent of OpenGL

There's one major difference: OpenGL is a widely supported lib, whereas OpenAL is an attempt of more or less creative to keep there line of sound cards alive. The result is bad driver support.

Sound APIs aren't that complex, start with XAudio2 (windows only), it is at least free and once you really need to support other plattforms, take a look at FMOD.
I am using Linux, so I cannot start with XAudio2, but I found a way to do what I wanted to do. Thanks for your help and advice, everyone!
Try also MMAV (see http://chucklesoft.blogspot.com).

This topic is closed to new replies.

Advertisement