Hi
I add a bachgroun sound to my game to work since the player use the game …
So I use OPENAL to do that but what I notice that the sound musn’t be in a loop orelse it will repeat itself even the sound not yet finished … and the result is noise instead of music …
Here the code I used in my main routine:
alutInit(NULL, 0); alGetError ();
if(alGetError() != AL_NO_ERROR) return ;
alGenBuffers(1, &SoundBuffer);
if(alGetError() != AL_NO_ERROR) return ;
alutLoadWAVFile(“MONO.wav”, &formats, &datas, &sizes, &frequencys, &loops);
alBufferData(SoundBuffer, formats, datas, sizes, frequencys);
alutUnloadWAV(formats, datas, sizes, frequencys);
alGenSources(1, &Source); if(alGetError() != AL_NO_ERROR) return;
alSourcei(Source, AL_BUFFER, SoundBuffer);
alSourcef(Source, AL_PITCH, 1.0);
alSourcef(Source, AL_GAIN, 1.0);
alSourcefv(Source, AL_POSITION, SourcePosition);
alSourcefv(Source, AL_VELOCITY, SourceVelocity);
alSourcei(Source, AL_LOOPING, loops);
if(alGetError() != AL_NO_ERROR) return ;
alListenerfv(AL_POSITION, ListenerPosition);
alListenerfv(AL_VELOCITY, ListenerVelocity);
alListenerfv(AL_ORIENTATION, ListenerOrientation);
if(alGetError() != AL_NO_ERROR) return ; // Error checking…
.
.
.
.
and in my dispkay routine I put the following which I think make the mistake …
alSourcePlay(Source);
But where else I can put that function to play the sound … ?
Thanks in advance for any help …