Jump to content

  • Log In with Google      Sign In   
  • Create Account


OpenAL playing too fast.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 metsfan   Members   -  Reputation: 653

Like
0Likes
Like

Posted 24 November 2012 - 03:02 PM

Hello all. I am having an issue with a basic OpenAL implementation. I am loading in a WAV file, which loads in just fine. However when I try to play it, it plays at about 10x its normal speed. I tried loading it in other media players and it loads just fine. Here is my code:

ALenum format;
ALsizei size;
ALsizei freq;
ALboolean loop;
void *data;
alutLoadWAVFile((ALbyte *)mFilepath.c_str(), &format, &data, &size, &freq, &loop);
alGetError();
glm::vec3 velocity(0, 0, 0);
alListenerfv(AL_POSITION, &position[0]);
alListenerfv(AL_VELOCITY, &velocity[0]);
alListener3f(AL_ORIENTATION, 0, 0, -1);
error = alGetError();
if (error != AL_NO_ERROR) {
  Logger::log(LogError, "Failed to init OpenAL listener.");
}
alGenBuffers(1, &mBufferId);
error = alGetError();
if (error != AL_NO_ERROR) {
  Logger::log(LogError, "Failed to init OpenAL buffer.");
}
alBufferData(mBufferId, format, data, size, freq);
error = alGetError();
if (error != AL_NO_ERROR) {
  Logger::log(LogError, "OpenAL buffer error: %d", error);
}

alGenSources(1, &mSourceId);
alSourcef(mSourceId, AL_PITCH, 1.0);
alSourcef(mSourceId, AL_GAIN, 1.0);
alSourcefv(mSourceId, AL_VELOCITY, &velocity[0]);
alSourcefv(mSourceId, AL_POSITION, &position[0]);
alSourcei(mSourceId, AL_BUFFER, mBufferId);
alSourcei(mSourceId, AL_LOOPING, AL_FALSE);


Does anyone see anything wrong? Thank you.

Sponsor:

#2 metsfan   Members   -  Reputation: 653

Like
0Likes
Like

Posted 24 November 2012 - 07:44 PM

Solved it. The issue was that I was using ALUT to load in the WAV files, but I was initializing the OpenAL context manually, so ALUT didn't have certain properties set which I guess make it work. By calling alutInit, the issue was solved. I'm looking to ditch ALUT asap, if anyone has any recommendations for audio libraries that can read WAV and OGG files into a structure with the basic information (buffer size, format, byte rate) I would be most appreciative (something simliar to assimp or FreeImage but for audio files). Thanks.

Edited by metsfan, 24 November 2012 - 07:44 PM.


#3 metsfan   Members   -  Reputation: 653

Like
0Likes
Like

Posted 24 November 2012 - 09:45 PM

Just wanted to reply and say that I settled on FMOD for my audio system. I promise I won't bump this thread anymore, just wanted to provide answers in case anyone comes by in the future Posted Image




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS