• 12
• 12
• 9
• 10
• 13

# Very odd OpenAL problem

This topic is 4297 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I was very happy to get OpenAL working and installed on my computer. I read the documentation and got some code to work on my computer. Now, in my game I have a bunch of sound/music in my game. But for SOME REASON, it will only play on my computer. I'm sure that I have the sound files all in the write places. Its a very weird problem and I would really appreciate it if someone could help me out. If you have EVER gotten a program to play sound using OpenAL on multiple computers, PLEASE contact me: email: bballmitch2@sbcglobal.net AIM: gamer12121 MSN: lubanfamily@sbcglobal.net

##### Share on other sites
Come on...please. I finished every aspect of my game, the only problem is that sound won't plat on OTHER people's computers. Will someone who is experience with OpenAL PLEASE contact me?

##### Share on other sites
I have gotten AL working on multiple machines, although I didn't have any troubles like you are describing. I used alut though (I'd like to rewrite that actually), and wouldn't call myself an expert. Anyway, could you give more detail? In your code are you checking for errors (init fails, load fails, etc)? Are you sure the other machine has a working soundcard and has the volume turned up? It seems dumb, but that's a good place to start... Give us more detail, and perhaps show us some of your sound init, loading, and play back code.

##### Share on other sites
ok

int drawGLScene(GLvoid){...	//set listener properties	SetListenerPosition(player1->getX(),player1->getY(),player1->getZ() );	//set listener orientation, first 3 numbers are for the forward vector, last three are for the up vector	SetListenerOrientation(player1->getX() + cos(view_angle)*cos(sight),		                   player1->getY() + sin(sight),						   player1->getZ() + sin(view_angle)*cos(sight),						   -sin(sight)*cos(view_angle),						   cos(sight),						   -sin(sight)*sin(view_angle));...}int WINAPI WinMain(	HINSTANCE	hInstance,			// Instance					HINSTANCE	hPrevInstance,		// Previous Instance					LPSTR		lpCmdLine,			// Command Line Parameters					int			nCmdShow)			// Window Show State{...	ALCcontext *Context;	ALCdevice *Device;	//Open device	Device = alcOpenDevice((ALCchar*)"MMSYSTEM");	//Device = alcOpenDevice(NULL);	//Create context(s)	Context=alcCreateContext(Device,0);	//Set active context	alcMakeContextCurrent(Context);	// Clear Error Code	alGetError();	//load up our background music	background.LoadSound("Data/Menu.wav",1);	//set the position of the sound effect	background.SetSourceRelative();	background.SetProperties(0.0f,0.0f,0.0f,0.0f,0.0f,0.0f);	background.PlaySound();	SetListenerPosition(player1->getX(),player1->getY(),player1->getZ() );...//if the user quits out of the program// Shutdown	//Get active context	Context=alcGetCurrentContext();	//Get device for active context	Device=alcGetContextsDevice(Context);	//Disable context	alcMakeContextCurrent(NULL);	//Release context(s)	alcDestroyContext(Context);	//Close device	alcCloseDevice(Device);...}

my LoadSound function looks like this:
void Sound::LoadSound(char fname[40], bool looping){	//load our sound	ALboolean loop;	loop = looping;	alutLoadWAVFile(fname,&alFormatBuffer, (void **) &alBuffer,(ALsizei *)&alBufferLen, &alFreqBuffer, &loop);	alGenSources(1, &alSource);	alGenBuffers(1, &alSampleSet);	alBufferData(alSampleSet, alFormatBuffer, alBuffer, alBufferLen, alFreqBuffer);	alSourcei(alSource, AL_BUFFER, alSampleSet);	alutUnloadWAV(alFormatBuffer, alBuffer, alBufferLen, alFreqBuffer);				//set the pitch	alSourcef(alSource,AL_PITCH,1.0f);	//set the gain	alSourcef(alSource,AL_GAIN,1.0f);	//set looping to true	alSourcei(alSource,AL_LOOPING,AL_TRUE);	Volume = 1.0;	//alutUnloadWAV(alFormatBuffer, alBuffer, alBufferLen, alFreqBuffer);}

Keep in mind two things:

1. All things in relation to sound work PERFECTLY on my computer (just on no one else's)
2. The sound file that I load is relative to the executable, so there shouldn't be any problem on other people's computers finding that file.

Does that help?

##### Share on other sites
I would agree to what Mr. Grinch suggested. Make sure you check for errors starting with the obvious stuff such as whether the file has really loaded. Besides the lack of error-checking your code looks fine. Good Luck.

In this code snippet, I check for errors after every OpenAL call
//Should be called after every ALfunction - return false on errorbool isALOK(const char* nameoffunc2chk){   	ALint	error;   	if ((error = alGetError()) != AL_NO_ERROR)      {      	DisplayALError(nameoffunc2chk,error);      return false;      }   return true;	//NO ERROR}bool sr_audio::InitSoundSystem(Uint32 flags){	ALCcontext *Context=NULL;	ALCdevice *Device=NULL;   //Opens a device    Device=alcOpenDevice("MMSYSTEM");   //Device=alcOpenDevice("DirectSound3D");//   if(NULL == Device)return false;   //Creates a context using a specified device.   Context=alcCreateContext(Device,NULL);   if(NULL == Context){alcCloseDevice(Device);return false;}   //Makes a specified context the current context.   alcMakeContextCurrent(Context);   //   alGetError(); // Clear Error Code   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,1.0,0.0};	// Listener facing into the screen	// Position ...	alListenerfv(AL_POSITION,listenerPos);	isALOK("sr_audio::InitSoundSystem()-alListenerfv(POS)");	// Velocity ...	alListenerfv(AL_VELOCITY,listenerVel);	isALOK("sr_audio::InitSoundSystem()-alListenerfv(VEL)");	// Orientation ...	alListenerfv(AL_ORIENTATION,listenerOri);        isALOK("sr_audio::InitSoundSystem()-alListenerfv(ORI)");}

##### Share on other sites
well, i tested for those errors on my computer and im not getting any errors. But you're not realizing the MOST important part of this problem...it works 100% on my computer. It has something to do with when the program is moved to other people's computers. The things that i know FOR SURE are that the files are where they are supposed to be, and all the .dll files are where they are supposed to be.

I am relativly certain, however, that the problem lies with the Device. On a friedn of mine's computer, when i tested if the device was null (and if it was the program would quit) as soon as he opened my program, it closed.

The weird thing, though, is that I tried multiple Devices; NULL, MMSYSTEM, DirectSound3D...none of them worked. anymore ideas?

##### Share on other sites
Quote:
 Original post by bballmitchwell, i tested for those errors on my computer and im not getting any errors. But you're not realizing the MOST important part of this problem...it works 100% on my computer. It has something to do with when the program is moved to other people's computers. The things that i know FOR SURE are that the files are where they are supposed to be, and all the .dll files are where they are supposed to be. I am relativly certain, however, that the problem lies with the Device. On a friedn of mine's computer, when i tested if the device was null (and if it was the program would quit) as soon as he opened my program, it closed. The weird thing, though, is that I tried multiple Devices; NULL, MMSYSTEM, DirectSound3D...none of them worked. anymore ideas?

That's why you should check to see what goes wrong on other computers. There is a relatively small amount of things that can be happening. Either it can't fiind the files, openAL is missing/messed up, or the other computers can't support what you want to do. Does it have anything to do with release or debug builds?

##### Share on other sites
I tried checking for errors on someone else's computer (one that won't play sound) and there are no errors (at least according to alGetError() ).

I am compiling my project in release mode. Could that have something to do with the problem?

##### Share on other sites

Did you try the SDK samples on the other computer ?

They should provide the base line for making a working OpenAL program.

I have made an OpenAL program working on several computers.

Sometimes it happens that one thing works on one computer but not on another computer.

There are issues such as the maximum amount of sources. It isn't safe to assume any number of available sources. I don't know if it is your case, but it might cause head ache too :)

Best regards

##### Share on other sites
Maybe it has something to do with drivers?

I vagely remember there might small differences between driver
implementation, such as certain drivers returning '0' as an id
for the first soundsource, others returning 1... So any 0-check
would be bad (rather check return-codes).

Again, I might be wrong here...