Sign in to follow this  

Minimum File Size in OpenAL?

Recommended Posts

Hey, Just yesterday I decided to implement OpenAL into my current game project and with the provided documentation it was virtually painless and seems to work fine with my full length tracks. The problem I have is that I can't seem to get very short wavs (3-6 second sound effects) to play. So I was wondering if there was a minimum file size for OpenAL to function properly. None of the code changes, just the file size. They are stored in the same directory and I used ::playsound() to make sure the files were valid. My idea was to load very common sound effects (player taking damage) into buffers in the beginning of the game and then generate sources later as needed associated with already initialized buffers. The full length tracks that work fine are between 2 and 4 minutes long. Do I need to post any code, or am I going at it the wrong way? Thanks a lot

Share this post

Link to post
Share on other sites
Hmmm...means I must be doing something wrong. Well, I'll go ahead and post some code if anyone feels like browsing through it.

ALuint SoundBuffers[2]; //For majestic Tracks
ALuint SoundSources[2]; //For majestic Tracks
ALfloat ListenerPos[3];
ALfloat ListenerVel[3];
ALfloat ListenerOri[6];

void InitializeOpenAL();
void CreateSourceSound(CString,ALuint&,ALuint&,int,int);


void GameController::InitializeOpenAL()
int argc; char *argv[5];
alutInit(&argc, argv);

ListenerPos[0]=Hero.X; ListenerPos[1]=Hero.Y; ListenerPos[2]=0.0;
ListenerVel[0]=0.0; ListenerVel[1]=0.0; ListenerVel[2]=0.0;
ListenerOri[0]=0.0; ListenerOri[1]=0.0; ListenerOri[2]=-1.0;
ListenerOri[3]=0.0; ListenerOri[4]=1.0; ListenerOri[5]=0.0;

void GameController::CreateSourceSound(CString track,ALuint &thisBuffer,ALuint &thisSource,int xpos, int ypos)
ALfloat SourcePos[]={float(xpos),float(ypos),0.0};
ALfloat SourceVel[]={0.0,0.0,0.0};

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


//Message("Generated Source");


alListenerfv(AL_POSITION, ListenerPos);
alListenerfv(AL_VELOCITY, ListenerVel);
alListenerfv(AL_ORIENTATION, ListenerOri);

//Message("Playing Source!!");

//Relevant calls to CreateSourceSound
CreateSourceSound("Resources/Theme.wav",SoundBuffers[0],SoundSources[0],1500,1500); //This works

CreateSourceSound("Resources/Pain.wav",SoundBuffers[0],SoundSources[0],1500,1500); //This doesn't

I might be doing something terribly wrong. I have a days worth of experience with OpenAL so please point out any things that could/should be changed.


Share this post

Link to post
Share on other sites

I didn't have any problems with short sounds either. If I were you, I'd add error checking after every OpenAl command. It is just too easy to break the OpenAl api. Is the .Wav file correct ? does the order of loading have some effect ?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this