Jump to content
  • Advertisement
Sign in to follow this  
kozlojak

Openal

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am having a problem when playing back a wav file using OpenAL AND alut to load it, when the sound starts there is a loud corrupt sound then the actuall playback, if it is on loop then the strange sound is only at the beginning not on every loop. it may also be a system problem(ubuntu) any ideas? or would I be better off using fmod? or some other libary? I use alutInit(0,0); to start it up then the folowing class to play sounds

bool sound::init(std::string filename)
{


    alGenBuffers(1, &m_soundID);
    alGenSources(1, &m_sourceID);

    float SourcePos[] = { 0.0, 0.0, 0.0 };
    float SourceVel[] = { 0.0, 0.0, 0.0 };

    float ListenerPos[] = { 0.0, 0.0, 0.0 };
    float ListenerVel[] = { 0.0, 0.0, 0.0 };
    float ListenerOri[] = { 0.0, 0.0, -1.0,  0.0, 1.0, 0.0 };

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

    alutLoadWAVFile((ALbyte*)filename.c_str(), &format, &data, &size, &freq, &loop);
    alBufferData(m_soundID, format, data, size, freq);
    alutUnloadWAV(format, data, size, freq);

    //m_soundID = alutCreateBufferFromFile (filename.c_str());

    alSourcei (m_sourceID, AL_BUFFER,   m_soundID);
    alSourcef (m_sourceID, AL_PITCH,    1.0f     );
    alSourcef (m_sourceID, AL_GAIN,     1.0f     );
    alSourcefv(m_sourceID, AL_POSITION, SourcePos);
    alSourcefv(m_sourceID, AL_VELOCITY, SourceVel);
    alSourcei (m_sourceID, AL_LOOPING,  AL_TRUE );
}

void sound::play()
{
    alSourcePlay(m_sourceID);
}

void sound::stop()
{
    alSourceStop(m_sourceID);
}

void sound::distroy()
{
    alDeleteSources(1, &m_sourceID);
    alDeleteBuffers(1, &m_soundID);

}

Share this post


Link to post
Share on other sites
Advertisement
Looks to be a problem with my system, I am getting the same problem with fmod. i tries to use OSS with fmod but it just crashes

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!