Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7399539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:04:23+00:00 2026-05-29T04:04:23+00:00

I’m new using OpenAl library. I’m following the OpenAl programming guide but i can’t

  • 0

I’m new using OpenAl library. I’m following the OpenAl programming guide but i can’t find.

I have this code extracted from page 10 of the OpenAl programming guide but still have no sound. I use OSX Snow Leopard, i know OSX doesn’t have ALUT defined.

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>

#include <OpenAL/al.h>
#include <OpenAL/alc.h>

using namespace std;

#define NUM_BUFFERS 3
#define BUFFER_SIZE 4096

int main(int argc, char **argv)
{
    ALCdevice *dev;
    ALCcontext *ctx;
    struct stat statbuf;

    Aluint buffer[NUM_BUFFERS];
    Aluint source[NUM_SOURCES];

    ALsizei size, freq;
    ALenum format;
    ALvoid *data;

    // Initialization 
    dev = alcOpenDevice(NULL); // select the "preferred dev" 

    if (dev) 
    { 
        ctx = alcCreateContext(dev,NULL); 
        alcMakeContextCurrent(ctx);  
    } 
    // Check for EAX 2.0 support 
    // g_bEAX = alIsExtensionPresent("EAX2.0");

    // Generate Buffers 
    alGetError(); // clear error code 
    alGenBuffers(NUM_BUFFERS, buffer); 
    if ((error = alGetError()) != AL_NO_ERROR) 
    { 
        DisplayALError("alGenBuffers :", error); 
        return 1; 
    } 
    // Load test.wav 
    loadWAVFile("sample.wav", &format, &data, &size, &freq, &loop); 
    if ((error = alGetError()) != AL_NO_ERROR) 
    { 
        DisplayALError("LoadWAVFile sample.wav : ", error); 
        alDeleteBuffers(NUM_BUFFERS, buffer); 
     return 1; 
    }

    // Copy test.wav data into AL Buffer 0 
    alBufferData(buffer[0], format, data, size, freq); 
    if ((error = alGetError()) != AL_NO_ERROR) 
    { 
     DisplayALError("alBufferData buffer 0 : ", error); 
     alDeleteBuffers(NUM_BUFFERS, buffer); 
     return 1; 
    } 

    // Unload test.wav 
    unloadWAV(format, data, size, freq); 
    if ((error = alGetError()) != AL_NO_ERROR) 
    { 
        DisplayALError("UnloadWAV : ", error); 
        alDeleteBuffers(NUM_BUFFERS, buffer); 
        return 1; 
    } 
    // Generate Sources 
    alGenSources(1, source); 
    if ((error = alGetError()) != AL_NO_ERROR) 
    { 
        DisplayALError("alGenSources 1 : ", error); 
        return 1; 
    } 
    // Attach buffer 0 to source
    alSourcei(source[0], AL_BUFFER, buffer[0]); 
    if ((error = alGetError()) != AL_NO_ERROR) 
    { 
        DisplayALError("alSourcei AL_BUFFER 0 : ", error); 
    } 

    // Exit 
    ctx = alcGetCurrentContext(); 
    dev = alcGetContextsDevice(ctx); 
    alcMakeContextCurrent(NULL); 
    alcDestroyContext(ctx); 
    alcCloseDevice(dev);

    return 0;
}

What things I missed to make this code work ???
What i’m doing wrong ???

Any advice could help, thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:04:24+00:00Added an answer on May 29, 2026 at 4:04 am

    You are not calling alSourcePlay(source[0]) to start the playback.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.