12

My commercial embedded C++ Linux project requires playing wav files and tones at individual volume levels concurrently. A few examples of the sounds:

• “Click” sounds each time user presses screen played at a user-specified volume
• Warning sounds played at max-volume
• Warning tones requested by other applications at app-specified volume level (0-100%)
• Future support for MP3 player and/or video playback (with sound) at user-specified volume. All other sounds should continue while song/video is playing.

We're using Qt as our UI framework which has QtMultimedia and Phonon support. However, I heard the former has spotty sound support on Linux and the latter is an older version and may be deprecated in an upcoming Qt release.

I've done some research and here are a few APIs I've come across:
KDE Phonon
SFML
PortAudio
SDL_Mixer
OpenAL Soft
FMOD (though I'd prefer to avoid license fees)
ALSA (perhaps a bit too low-level...)

Other considerations: Cross-platform isn't required but preferred. We'd like to limit dependencies as much as possible. There is no need for advanced features like 3D audio or special effects in the foreseeable future. My team doesn't have much audio experience so ease-of-use is important.

Are any of these overkill for my application? Which seems like the best fit?

Update: It turns out we were already dependent on SDL for other reasons so we decided on SDL_Mixer. For other Embedded applications, however, I'd take a long at the PortAudio/libsndfile combo as well due to their minimal dependencies.

1

5 Answers 5

6

libao is simple, cross-platform, Xiphy goodness. There's documentation too!

Usage is outlined here - simple usage goes like this:

2
  • 1
    Its license, however, is the GPL and hence it will probably not meet the OP's requirements.
    – quinmars
    Apr 2, 2012 at 20:52
  • Ah, you might well be right, even though it's not currently specified in the question, "commercial" probably means GPL is out.
    – gnud
    Apr 2, 2012 at 20:53
2

Go for PortAudio. For just plain audio without unneeded overhead such as complex streaming pipelines, or 3D, it is the best lib out there. In addition you have really nice cross-platform support. It is used by several professional audio programs and has really high quality.

2
  • It looks like PortAudio has just a few dependencies, which is nice. The majority of our sounds are wav files, however, and it doesn't support reading or writing formatted audio files.
    – rocky
    Apr 4, 2012 at 22:07
  • You could use libsndfile for loading wave files. Its interface is essentially mimicking the standard C file I/O ones with some additional format (s/g)etting functionality. The combination libsnfile+portaudio gives you a very flexible, portable and lighweight way to play wav-files and is probably a good compromise for an embedded system. Apr 5, 2012 at 7:08
1

i have used SDL_Mixer time and time again, lovely library, it should serve well for your needs, the license is flexible and its heavily documented. i have also experimented with SFML, while more modern and fairly documented, i find it a bit bulky and cumbersome to work with even tho both libraries are very similar. imo SDL_Mixer is the best.

however you might also want to check out this one i found a few weeks ago http://www.mpg123.de/, i haven't delved too much into it, but it is very lightweight and again the license is flexible.

2
  • I think we're going to give SDL_Mixer a go since one of my co-workers has some experience with it. I'll update this question once we get something working. Thanks!
    – rocky
    Apr 4, 2012 at 22:15
  • It turns out we were already dependent on SDL for other reason so we're going with SDL_Mixer. For others readings this, however, I'd take a long at PortAudio as well, especially for Embedded projects.
    – rocky
    Apr 19, 2012 at 14:51
1

There is a sound library called STK that would meet most of your requirements:

https://ccrma.stanford.edu/software/stk/faq.html

1

Don't forget about:

  • FFmpeg: is a complete, cross-platform solution to record, convert and stream audio and video.

  • GStreamer: is a library for constructing graphs of media-handling components. The applications it supports range from simple Ogg/Vorbis playback, audio/video streaming to complex audio (mixing) and video (non-linear editing) processing.

1
  • Thanks, I re-read the question and one thing that is clear is that they have space in disk for one of the solutions I've suggested. They are not that big and I've used both on a couple of occasions in my embedded projects. And it goes without saying that learning one of this technologies adds a great skill to your programming arsenal. Apr 3, 2012 at 1:13

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.