4

I write an Desktop/iOS Game with OpenGL and want to play audio files (mp3 or wav). I've worked already with CoreAudio and AudioQueues, but now I need something that works also with Windows (and maybe Linux).

I've seen so far:

  • OpenAL
  • OpenSL

I only need really basic features - like "playSound(file)" and "isPlaying(file)" - no 3D Sound, effects and so on... OpenAL & OpenSL are both from khronos - so I dont really get the difference (yes, they are 2 different librarys thought).

What would be the simplest cross-plattform soultion? Can I write with one of them code, that runs on iPhone and Desktop PCs similiar?

Constantin
  • 8,721
  • 13
  • 75
  • 126
  • 1
    I'm not entirely sure if it's as cross-platform and all as you need but have you looked at fmod? I've had great experiences with this library back in the past when it was still free :-P don't know about pricing now though.. – mtijn Aug 07 '11 at 21:21
  • 3
    "Juce" is much more then an audio library, but it is has audio capabilities and is cross-platform http://www.rawmaterialsoftware.com/juce.php – Itamar Katz Aug 08 '11 at 12:21
  • 6
    OpenAL is not from khronos, only OpenSL is; **that's** the difference. OpenAL was invented by Loki Software and is now owned by Creative Labs, who switched from LGPL to proprietary. Both have an interface that reminds to OpenGL, however only OpenAL is currently more widely supported, OpenSL is in fact OpenSL ES and only for embedded devices, the lib for desktop PCs is OpenMAX AL, which has an identical interface as OpenSL ES, but also offers a lot more functionality beyond audio playback and recording. – Mecki Feb 09 '12 at 21:05

2 Answers2

3

If your target platforms are Windows/Mac/iOS then OpenAL is a fine choice as it's supported on all those platforms. The place where you will need to write cross platform code is how you open and decode your files.

Byron
  • 1,091
  • 11
  • 27
  • I'm looking into a cross platform audio API as well. OpenAL is my first choice. It appears to have been ported to Android as well. Does their license permit closed source commercial ventures? – Halsafar May 30 '12 at 05:23
  • @Halsafar the license of OpenAl is LGPL then yes you can – Flavien Volken Dec 09 '13 at 15:12
  • If you target Windows/Mac/Linux/iOS/BlackBerry10/Android and do not require low-latency audio, OpenAL is the right choice. – Sergey K. Jul 13 '15 at 15:30
0

You might be looking for SDL_audio, which loads an audio file and plays it. Its' API is available in C, and it is cross-platform.

tripulse
  • 1,059
  • 11
  • 18