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 7654387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:14:36+00:00 2026-05-31T12:14:36+00:00

That’s pretty much it. I’ve got a function to set up an OpenAL context

  • 0

That’s pretty much it. I’ve got a function to set up an OpenAL context and device, and load a WAV file into a buffer and pass that buffer along with data from the file to alBufferData. I then try to call alSourcePlay(source) and no sound comes out. The whole function compiles and runs fine, but through debugging I found that the alGetError() function returned AL_ILLEGAL_ENUM after my call to alListener3f(AL_ORIENTATION, 0, 0, -1). Surely AL_ORIENTATION is a valid OpenAL enum? I’ve been following the tutorial here: http://enigma-dev.org/forums/index.php?topic=730.0

Here’s my code (excuse the mess, frantic debugging…):

void initOpenAL() {

ALenum errorNum = alGetError();
// initialise OpenAL
ALCdevice* device = alcOpenDevice(NULL);
ALCcontext* context = alcCreateContext(device, NULL);
alcMakeContextCurrent(context);

errorNum = alGetError();

alListener3f(AL_POSITION, 0, 0, 0);

errorNum = alGetError();

alListener3f(AL_VELOCITY, 0, 0, 0);

errorNum = alGetError();

alListener3f(AL_ORIENTATION, 0, 0, -1);

errorNum = alGetError(); // this is where alGetError == AL_INVALID_ENUM

alGenSources(1, &source);

errorNum = alGetError();

alSourcef(source, AL_PITCH, 1);
alSourcef(source, AL_GAIN, 2);
alSource3f(source, AL_POSITION, 0, 0, 0);
alSource3f(source, AL_VELOCITY, 0, 0, 0);
alSourcei(source, AL_LOOPING, AL_FALSE);

errorNum = alGetError();

ALuint buffer;
alGenBuffers(1, &buffer);
alSourcei(source, AL_BUFFER, buffer);

errorNum = alGetError();

FILE* file;
file = fopen("../../arcade.wav", "r");
if (file == NULL) {
    printf("File access error\n");
    exit(1);
}

char xbuffer[5];
if (fread(xbuffer, sizeof(char), 4, file) != 4 || strcmp(xbuffer, "RIFF") != 0)
    throw "Not a WAV file";

file_read_int32_le(xbuffer, file);
if (fread(xbuffer, sizeof(char), 4, file) != 4 || strcmp(xbuffer, "WAVE") != 0)
    throw "Not a WAV file!";

if (fread(xbuffer, sizeof(char), 4, file) != 4 || strcmp(xbuffer, "fmt ") != 0)
    throw "Invalid WAV file!";

printf("char size: %i", sizeof(char));

errorNum = alGetError();

file_read_int32_le(xbuffer, file);
short audioFormat = file_read_int16_le(xbuffer, file);
short channels = file_read_int16_le(xbuffer, file);
int sampleRate = file_read_int32_le(xbuffer, file);
int byteRate = file_read_int32_le(xbuffer, file);
file_read_int16_le(xbuffer, file);
short bitsPerSample = file_read_int16_le(xbuffer, file);

if (fread(xbuffer, sizeof(char), 4, file) != 4 || strcmp(xbuffer, "data") != 0)
    throw "Invalid WAV file";

int dataChunkSize = file_read_int32_le(xbuffer, file)+4;
unsigned char* bufferData = file_allocate_and_read_bytes(file, (size_t)dataChunkSize);

printf("Error before alBufferData: %x\n", alGetError());

float duration = float(dataChunkSize)/byteRate;
alBufferData(buffer, GetFormatFromInfo(channels, bitsPerSample), bufferData, dataChunkSize, sampleRate);
free(bufferData);
fclose(file);

errorNum = alGetError();

printf("Error after alBufferData, before alSourcePlay: %x\n");

alSourcePlay(source);
errorNum = alGetError();
if (errorNum != AL_NO_ERROR) {
    printf("Error starting playback: %x", errorNum);
}
fgetc(stdin);
}
  • 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-31T12:14:38+00:00Added an answer on May 31, 2026 at 12:14 pm

    I found the answer to this a while ago and I’ve only just remembered to answer it on here: the AL_ORIENTATION enum is used in the alListenerfv method, not alListener3f. And it takes a vector instead of 3 ints. I’m amazed how long it took to find that out!

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
That's pretty much it. I need to read a server controls event, which will
That's it. If you want to document a function or a class, you put
That's the question... Do you think ASP.Net is a technology suitable for high-load sites?
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That is to say, if I set an animation to take 1 second, will

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.