OpenAL Programming

This is a discussion on OpenAL Programming within the Game Programming forums, part of the General Programming Boards category; I've recently been confused about a couple of things on OpenAL so I set out on a quest to clear ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    28

    OpenAL Programming

    I've recently been confused about a couple of things on OpenAL so I set out on a quest to clear them up.

    1. I was unsure about the structure of OpenAL which I now understand.
    2. I was unsure how to load audio data into memory or how audio works in general.

    This is where I'm stuck. Here's some code to help explain my meaning:

    Code:
    GEsound::GEsound(ALint numBuf = 1 )
    
    {
        ALCdevice *device = alcOpenDevice(NULL);
    
        if (device != NULL)
        {
            alGetError(); //Clears error state out.
            buffer[numBuf]; //buffer declared private as ALuint *
    
            alGenBuffers(numBuf, buffer);
    
            if (alGetError() == AL_NO_ERROR)
            {
                //What do I do to load data into the buffers?
            }
        }
    }
    The programmers guide explains to simply load PCM audio data into buffers using alBufferData. In the alBufferData function, it explains that you need to pass a void pointer to the audio data. I have not a clue where to begin to generate that pointer to be honest since I can't find many examples on audio programming or the theory behind it. I'm guessing this is where where I decode audio. Anyone care to help?

    EDIT: Buffer is an array to unsigned integers which hold names of the buffers. Not the actual buffers.
    Last edited by computerquip; 06-17-2009 at 10:03 PM. Reason: Cleaning up grammar and spelling.

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    You can use freealut library to load in WAV files. Google for it.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    28
    No! That's exactly what I don't want to do! The point of this is to learn, not to use a utility class that does it for you.

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    28
    Alright. Well thanks for spending your time on me. *cough* I found my answer: GameDev.net - Introduction to Ogg Vorbis

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    Ogg Vorbis will load the Ogg format for you. What is the difference between having freealut load WAV files or using Ogg to load it's various formats?

    They are the same thing. A third party helper library. I would still use freealut to load WAV files and Ogg to load music files. Queueing buffers in OpenAL looks straightforward enough once you know how to get the raw data loaded and streamed in which is pretty trivial when a library is loading the data for you.

    I would try with a circular buffer of about 256 bytes. Always play the portion of the buffer you just loaded and always load into the portion of the buffer you just played.
    Last edited by VirtualAce; 06-19-2009 at 04:19 PM.

  6. #6
    Registered User
    Join Date
    Jan 2008
    Posts
    28
    It's hard to explain. Your right though, but I was confused about a couple of things. Anyways, thanks for the help.

    I was confused about how audio is decoded in general. I thought that it used some special magic that summoned a decoding god which decoded the audio then returned a pointer to the buffered data. I'm still confused about how decoding works, but I'm more clear on the process of decoding.
    Last edited by computerquip; 06-19-2009 at 10:25 PM.

  7. #7
    Registered User
    Join Date
    Jul 2009
    Posts
    3
    You could always use DirectSound or XACT and that way you wouldn't have to ship additional dll's with your application

    _______________________
    Winsock tutorials

  8. #8
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    Closed. Please do not bump old threads.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenAL
    By skiler in forum C++ Programming
    Replies: 1
    Last Post: 01-26-2008, 08:18 AM
  2. OpenAL issues
    By Slyde in forum Game Programming
    Replies: 2
    Last Post: 03-20-2004, 08:33 AM
  3. OpenAL
    By Donnellg in forum Game Programming
    Replies: 11
    Last Post: 11-21-2002, 08:39 PM
  4. OpenAL
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 05-31-2002, 06:32 PM
  5. OpenAL
    By DavidP in forum Game Programming
    Replies: 0
    Last Post: 05-24-2002, 03:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21