OpenAL: "No sound" problem

eldritch 101 May 06, 2005 at 13:56

Hello there, new here :)

I have begun to work with OpenAL as part of my game to get some sounds (and later music) going. Though, when I first compiled my game (no errors or warnings) and ran it, there was no sound to be heard. I quad-checked everything, and it was in order.

I then downloaded one of the samples from this site (great site btw!), and it ran just fine. I could even modify it. But… if I use the very same .CPP file from the sample in my own project file (linking to OpenAL32.lib and alut.lib), I get the same problem as above, there is no sound to be heard. I am checking if the file I am attempting to load is existant and the path is correct, so that is not the problem.

Have I managed to miss something important in the project settings??

15 Replies

Please log in or register to post a reply.

eldritch 101 May 06, 2005 at 17:44

I’ll post the parts of the code where I have put the OpenAL stuff, though it is pretty intact from the tutorial, and I have compared the code a million times (and it does not really lie there since the very same file works perfectly with the original project file (.DSW/.DSP).

// The includes at the top of the file.
#include <alut.h>
#include <al.h>

// Global variables.
ALuint Buffer;
ALuint Source;
ALfloat SourcePos[] = { 0.0, 0.0, 0.0 };
ALfloat SourceVel[] = { 0.0, 0.0, 0.0 };
ALfloat ListenerPos[] = { 0.0, 0.0, 0.0 };
ALfloat ListenerVel[] = { 0.0, 0.0, 0.0 };
ALfloat ListenerOri[] = { 0.0, 0.0, -1.0, 0.0, 0.0, 1.0 }; // Z is up for me. 2D game.

// Special AL functions.
ALboolean LoadALData()
  // Variables to load into.

  ALenum format;
  ALsizei size;
  ALvoid* data;
  ALsizei freq;
  ALboolean loop;

    // Load wav data into a buffer.
  alGenBuffers(1, &Buffer);
  if (alGetError() != AL_NO_ERROR)
    return AL_FALSE;

    FILE *fp = fopen("wavdata/phaser.wav", "r");
    if (!fp)
 MessageBox(NULL, "Error loading sound!", "Error", MB_OK);

  alutLoadWAVFile("wavdata/phaser.wav", &format, &data, &size, &freq, &loop);
  alBufferData(Buffer, format, data, size, freq);
  alutUnloadWAV(format, data, size, freq);

    // Bind buffer with a source.
  alGenSources(1, &Source);

  if (alGetError() != AL_NO_ERROR)
    return AL_FALSE;

  alSourcei (Source, AL_BUFFER,  Buffer  );
  alSourcef (Source, AL_PITCH,  1.0f   );
  alSourcef (Source, AL_GAIN,   1.0f   );
  alSourcefv(Source, AL_POSITION, SourcePos);
  alSourcefv(Source, AL_VELOCITY, SourceVel);
  alSourcei (Source, AL_LOOPING, AL_TRUE );

 // Do another error check and return.
  if (alGetError() == AL_NO_ERROR)
    return AL_TRUE;

  return AL_FALSE;

void SetListenerValues()
  alListenerfv(AL_POSITION,  ListenerPos);
  alListenerfv(AL_VELOCITY,  ListenerVel);
  alListenerfv(AL_ORIENTATION, ListenerOri);

void KillALData()
  alDeleteBuffers(1, &Buffer);
  alDeleteSources(1, &Source);

// Excerpt from the main() function.
alutInit(NULL, 0);

if (LoadALData() == AL_FALSE)
    return -1;



// Excerpt from the keyboard control function.
if (key == 'p')

if (key == 'o')

if (key == 27) { KillALData(); exit(0); }

The program uses GLUT to draw a window and OpenGL to draw primitives (it’s just my simulator thingy where I test mathematical stuff).

That should work, right? I have included OpenAL32.lib and alut.lib in the Linker. And the phaser.wav file is in the correct location. Have I missed something?

eldritch 101 May 07, 2005 at 09:40

Okey.. I managed to find out what was causing these anomalies.

It seems that the OpenAL32.dll that comes with the OpenAL SDK is errorful. When I use that one, I get no sounds, but programs can be quit without problems. If I use the one I already had (no idea where it came from, but probably either with Windows, the soundcard or some driver), I get sounds but an error whenever I close any program using OpenAL.

Has anyone else experienced a similar problem?

DragonCode 101 Oct 28, 2005 at 12:50

Hey Eldritch, I am experiencing the same problem. I have gone over my code many times and it looks right. I am using the most recent SDK from the Creative web sight.

When I run the example binary it plays sounds, if I build it from the source code… I get no errors but also no sound.

Can you send me the lib file that works for you, so I can try it?

rdillon 101 Nov 26, 2005 at 04:20

I think your code’d work fine in OpenAL1.0 but now you are using the new release 1.1, right?
I had the same problem afer updating the library. It looks the problem is in the alutInit function which doesn’t seem to work properly anymore.

You have to initialize the device and context directly, for example, like this:


ALCcontext *Context;
ALCdevice *Device;

Device = alcOpenDevice((ALchar*)”DirectSound3D”);
if (Device == NULL)

//Create context(s)

//Set active context



we’d also note that the alutLoadWavfile function is now deprecated (but still works fine in current version).

Hope this helps.

SpreeTree 101 Nov 26, 2005 at 11:32


we’d also note that the alutLoadWavfile function is now deprecated (but still works fine in current version).

ALut now comes in its own dll/lib (don’t know which as I do not actually use it, I load all the sound data myself), so alutLoadWav is probably in there, rather than actually being depreciated.


rdillon 101 Nov 27, 2005 at 05:19

I am not sure what you mean by “depreciated”…. actually, the ALUT specification published on the official OpenAL site ( clearly states that AlutLoadWavFile, ALutLoadWavMemory and AlutUnloadWav are now deprecated but still available for backward compatibility.
Interestingly, the same document doesn’t say anything particular about the AlutInit function which was the one causing the problem here reported (at least on my machine).

All best!

SpreeTree 101 Nov 27, 2005 at 11:54

As I said, I do not use alut, so I am not an authority here. But as I said, AlutLoadWavFile has been moved to the alut library, and whilst it looks like ti has been ‘officially’ depreciated, is still available.

Reading the OpenAL developers mailing list doesn’t really make this clear though, as there seems to be a lot of too’ing and fro’ing about it.

But it looks like it has been replaced with alutCreateBufferFromFile (and the various variations that come with it), which seems to work in a similar way.


Citizen_Erased 101 Jan 25, 2006 at 01:36

I’m having the same 1.1 SDK problem. I’m pretty new to programming in general and completly new to OpenAL. Copy pasting rdillions code doesn’t seem to solve the problem (although I’m probably doing something wrong), could someone quickly explain how to get the code in the first OpenAL tutorial on this site to work with the 1.1 release? Thanks.

wazoo 101 Feb 04, 2006 at 10:37
Device = alcOpenDevice((ALchar*)"DirectSound3D");

I just use:

Device= alcOpenDevice(NULL);

and it does the trick for me using the new 1.1 lib. I seem to remember not getting any love from the DirectSound3D flag.

Also, the SDK documentation just recommended initializing this way as well IIRC..

Zeussy 101 Feb 20, 2006 at 04:16

i cant get OpenAL to play a sound on my creative card.

Plays on the onboard nvidia sound, but my Audigy won’t play sounds.

OpenAL initialises, inits buffers, sources, plays the source, i get no sound, and no error.

I dont know if its a driver issue, or just openal being crap. Driving me insaine.

Reedbeta 167 Feb 20, 2006 at 05:19

Zeussy, have you tried making sure the volume is turned up? (I don’t just mean the volume in your speakers, but the OpenAL volume control. You never know, it might default to zero or something dumb like that.)

Zeussy 101 Feb 20, 2006 at 10:36

thanks Reedbeta, listener gain was set to 1, upped it to like 1000.f as well as the 1000 gain on the source, makes it audible.

was almost going to convert my sound handling class to fmod

L1zb3th 101 Apr 06, 2007 at 04:16

“FILE *fp = fopen(“wavdata/phaser.wav”, “r”);
if (!fp)
MessageBox(NULL, “Error loading sound!”, “Error”, MB_OK);


Reedbeta 167 Apr 06, 2007 at 06:10

L1zb3th, that is just a check that the file exists before passing it to ALUT.

L1zb3th 101 Apr 08, 2007 at 03:19

ahh , i didnt read well xDDDDDDDD