OpenAL WAV Playback

Apprentice
Posts: 19
Joined: 2006.11
Post: #1
Supposedly the OpenAL API is real simple and one can learn it in less than a day. I feel like I understand everything, yet nothing I put together works. What I'm trying to do is play a WAV file every time my method is called. I think my real problem is loading the WAV file into a buffer. Could somebody please explain how this is done? I hate to ask people to do things for me, but I just can't get OpenAL to work.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
If you're on 10.4.6 or earlier, you have OpenAL 1.0, which has a function called alutLoadWAVFile() which will do all the hard work for you.

If you're on 10.4.7 or later, you have OpenAL 1.1, which doesn't have [a header for] that function. You can write the prototype yourself and call it anyway, or you can implement your own WAV loading.

If you're going to attempt the latter, you might like to use ogg/vorbis instead, since there's a nice library to do it for you.

Other than that, it should be a simple matter of making a source, a listener and a buffer, and telling the source to play the buffer.
Quote this message in a reply
Apprentice
Posts: 19
Joined: 2006.11
Post: #3
Oh great. I'm on 10.4.8, and I've been trying to use alutLoadWAVFile(). No wonder I couldn't make it work. Thanks, I'll look into ogg/vorbis.

EDIT: You mention there's a "nice library" for working with ogg/vorbis. Googling is doing me no good, could you perhaps point me in the right direction with a link?

EDIT 2: Nevermind, got it. Thanks.
Quote this message in a reply
Apprentice
Posts: 19
Joined: 2006.11
Post: #4
Okay, so I downloaded the source to the Ogg.framework, compiled it, and placed it in /System/Library/Frameworks. Then I downloaded the source to the Vorbis.framework, compiled it, and put it in /System/Library/Frameworks.

I added Vorbis.framework to my project, then added #import <Vorbis/vorbisfile.h> to my source, tried to compile just to check that it worked and got an error. It tells me "error: Vorbis/vorbisfile.h: No such file or directory". Any ideas why it isn't seeing my framework?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
Is there a Headers folder within those frameworks?
You should *never* modify /System. /Library/Frameworks is an appropriate place to put these.
Quote this message in a reply
Apprentice
Posts: 19
Joined: 2006.11
Post: #6
I've moved them to /Library/Frameworks. Thanks for that tip.

There isn't a "Headers" folder, but an alias that points to ./Versions/A/Headers

Any idea?
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #7
As there should be. Look in the folder the alias points too, and make sure all the headers are there. If so, it's likely not added to your project/target correctly.
Quote this message in a reply
Apprentice
Posts: 19
Joined: 2006.11
Post: #8
Everything looks right, all the headers are there. I guess I'm just an idiot and I'm missing something obvious. I'll look through my project.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  24 Bit Audio Playback TREMS 2 3,253 Sep 29, 2006 06:00 PM
Last Post: Jones
  no ogg sound playback GryphonClaw 1 2,602 Jan 9, 2006 06:32 PM
Last Post: OneSadCookie
  Dynamic sound playback? napthali 6 3,218 Dec 7, 2003 10:38 PM
Last Post: kelvin