iDevGames Forums
openAL problems - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Designer's Studio (/forum-6.html)
+--- Thread: openAL problems (/thread-6186.html)



openAL problems - drzeip - Oct 12, 2004 02:48 PM

Hi I've been struggling to get any output from my computer using OpenAL. Granted I have a dodgy 24 bit soundcard but I can't even get output through my internal speaker. This is my source:

Code:
#define clickSound 1

{
    alutInit(&argc, argv);
    
    alListenerfv(AL_POSITION,listenerPos);
    alListenerfv(AL_VELOCITY,listenerVel);
    alListenerfv(AL_ORIENTATION,listenerOri);
    
    alGetError(); // clear any error messages
    
    // Generate buffers, or else no sound will happen!
    alGenBuffers(NUM_BUFFERS, buffer);
    
    if(alGetError() != AL_NO_ERROR)
    {
        printf("- Error creating buffers !!\n");
        exit(1);
    }
    else
    {
        printf("init() - No errors yet.");
        
    }
    
alutLoadWAVFile("sound/click.wav",&format,&data,&size,&freq);
    alBufferData(buffer[clickSound],format,data,size,freq);
    alutUnloadWAV(format,data,size,freq);

    alGetError(); /* clear error */
    alGenSources(NUM_SOURCES, source);
    
    if(alGetError() != AL_NO_ERROR)
    {
        printf("- Error creating sources !!\n");
        exit(2);
    }
    else
    {
        printf("init - no errors after alGenSources\n");
    }
    
    alSourcef(source[clickSound],AL_PITCH,1.0f);
    alSourcef(source[clickSound],AL_GAIN,1.0f);
    alSourcefv(source[clickSound],AL_POSITION,sourcePos);
    alSourcefv(source[clickSound],AL_VELOCITY,sourceVel);
    alSourcei(source[clickSound],AL_BUFFER,buffer[clickSound]);
    alSourcei(source[clickSound],AL_LOOPING,AL_FALSE);

alSourcePlay(source[clickSound]);


I receive no error messages. Should i check for errors after i try to play the sound?

Thanks in advance

David


openAL problems - OneSadCookie - Oct 12, 2004 05:23 PM

My bet is that alutLoadWAVFile is failing, since you're not checking whether it's succeeded...


openAL problems - drzeip - Oct 13, 2004 07:22 AM

I dunno what was happening before but after a bit of fiddling and updating OpenAL along with getting the new CoreAudio SDK i have sound!!! Wow

I think it was the way i bundled the sounds.

Thanks