openAL problems

drzeip
Unregistered
 
Post: #1
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
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
My bet is that alutLoadWAVFile is failing, since you're not checking whether it's succeeded...
Quote this message in a reply
drzeip
Unregistered
 
Post: #3
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
Quote this message in a reply
Post Reply