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.