Ogg playback for Mac apps - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Tools & Technology (/forum-10.html)
+--- Thread: Ogg playback for Mac apps (/thread-8929.html)
Ogg playback for Mac apps - ugriffin - May 6, 2011 12:12 PM
Although personally I'm fine with using mp3's, other Mac devs are hell-bent on using ogg's for their projects. GM apps only support mp3's, therefore, you can only use mp3's, wavs, and the 'common' sound files.
Since I'm happy with mp3, other people developed an Extension that lets you play back ogg's... however, you need to install system frameworks for openAL and Vorbis decoders... not very user friendly, and definitely not App Store friendly. They seem to be having trouble either including the frameworks inside the app bundle or inside the dylib itself. I believe Apple also isn't very happy with you using frameworks on App Store apps.
Therefore, I decided to do a little research on the subject myself. As some of you may know, I'm completely new to OS X programming and I'm quite the noob at C programming... what would be the easiest, cheapest, fastest way of writing a BSD C dylib wrapper for OGG playback on OS X? Preferably in a way where you don't have to use frameworks? The dylib also needs to be 32bit, which I think (I'm not sure) rules out openAL in Snow Leopard.
RE: Ogg playback for Mac apps - ThemsAllTook - May 6, 2011 01:03 PM
OpenAL is a system framework included with Mac OS X since 10.4 (as I recall, might've been 10.3 even), so there's no need to include your own. With a little bit of effort, you can compile libogg, libvorbis, and libvorbisfile yourself and statically link to them.
On 10.6, I just checked my system OpenAL and it's built for both i386 and x86_64, so linking to it from 32-bit code shouldn't be a problem.
RE: Ogg playback for Mac apps - OneSadCookie - May 6, 2011 01:58 PM
http://onesadcookie.com/svn/Third-Party will build you many architectures of static libs for ogg & vorbis. It hasn't been updated in a while, so things like versions and URLs might need tweaking.
RE: Ogg playback for Mac apps - gnurf - May 8, 2011 12:46 AM
You might be fine with using MP3s, but you'll still need a license to actually get away with it
RE: Ogg playback for Mac apps - Oddity007 - May 8, 2011 08:42 AM
I've taken a liking to stb_vorbis lately, it's small (one header), it's straightforward, and it's pretty easily connected to OpenAL.
RE: Ogg playback for Mac apps - HMaudio - May 9, 2011 06:03 PM
Just wanted to help explain why ogg is loved so much, from an audio designer's point of view. Ogg gets a bit better compression and quality compared to mp3, but the real beauty is being able to loop seamlessly. Unless you have some fancy code or tools, mp3s add a bit of silence (data, really) before/after the actual song, thus on repeat you'll hear a bit of silence, ruining the perfect loop.
Best of luck in your ogging!
RE: Ogg playback for Mac apps - carmine - May 10, 2011 12:16 PM
(May 8, 2011 08:42 AM)Oddity007 Wrote: I've taken a liking to stb_vorbis lately, it's small (one header), it's straightforward, and it's pretty easily connected to OpenAL.
I got this working-ish.... I'm doing a decode from memory and it seems to stop after a minute of playing. Is there some setting somewhere that is making it not decoded the entire thing to memory?
(I'm using xcode4 and c++)
RE: Ogg playback for Mac apps - Oddity007 - May 10, 2011 02:18 PM
I wouldn't advise decoding completely into memory as uncompressed sound files can be huge (on the order of GB, sometimes) Instead, I'd look into streaming. It's likely that you are decoding only a small chunk, if that is the case, then you just need to queue the buffers to play on a source.
This is how I do it (Sorry that the code sucks):
RE: Ogg playback for Mac apps - gnurf - May 11, 2011 01:46 AM
Definitely always stream music and other long ambient loops (or longer speech), yes. You should probably implement some sort of sound cache for handling sound effects, too. Anything that needs to be available instantly, like weapon effects, probably should preload. Or at least buffer on first use.
I like this thing for iOS: OpenALManager (formerly ObjectAL)
The author is active on the Cocos2D forums, and has mentioned he doesn't want to limit it only to iOS Modifying it for OS X is supposedly easy. Great little library if you want some fancy caching handled and just want to get on with your game
RE: Ogg playback for Mac apps - carmine - May 11, 2011 11:13 AM
(May 10, 2011 02:18 PM)Oddity007 Wrote: I wouldn't advise decoding completely into memory as uncompressed sound files can be huge (on the order of GB, sometimes) Instead, I'd look into streaming. It's likely that you are decoding only a small chunk, if that is the case, then you just need to queue the buffers to play on a source.
I was able to take your code and merge it with my own stuff and get it all to work! This saved me a ton of time and research. Thanks!
RE: Ogg playback for Mac apps - ugriffin - May 11, 2011 01:36 PM
Ah, those statics, didn't even remotely know that could be done. Great.
I'll mess around with this. Thanks a lot.