   2 Questions about OpenAL
  I just started messing with OpenAL a day or two ago, and I got OpenAL set up in my OpenGL program. And I can get it to load a small wav file and play it. Well I got 2 problems:1. The small wav file is just a guy saying "well hello mr. fancy pants." It sounds pretty clear. Every bit as clear as it does in windows media player. However, when I have it load and play a particular song instead, it sounds absolutely horrible. It sounds good in windows media player, but not in my program. Why is that?2. The song I have it play is the only song I have in WAV format. Every other one I have is mp3. How do I load a mp3 file and play it in OpenAL?Here's the code that initializes OpenAL, don't know if it can help, but it can't hurt, and thanks in advance for any help.ALCdevice* alcDevice;ALCcontext* alcContext;ALuint Buffer;ALuint Source;ALfloat SourcePos[] = {0.0f, 0.0f, 0.0f};ALfloat SourceVel[] = {0.0f, 0.0f, 0.0f};ALfloat SourceOri[] = {0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f};ALfloat ListenerPos[] = {0.0f, 0.0f, 0.0f};ALfloat ListenerVel[] = {0.0f, 0.0f, 0.0f};ALfloat ListenerOri[] = {0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f};bool InitializeAL(){ALenum format;ALsizei size;ALsizei freq;ALboolean loop;ALvoid* data;alutInit(0, NULL);alGetError();alcDevice = alcOpenDevice(NULL);if(alGetError() != AL_NO_ERROR){MessageBox(NULL, "alcOpenDevice failed in InitializeAL.", "Error", MB_OK | MB_ICONSTOP);CleanUp();return FALSE;}alcContext = alcCreateContext(alcDevice, NULL);if(alGetError() != AL_NO_ERROR){MessageBox(NULL, "alcCreateContext failed in InitializeAL.", "Error", MB_OK | MB_ICONSTOP);CleanUp();return FALSE;}alcMakeContextCurrent(alcContext);if(alGetError() != AL_NO_ERROR){MessageBox(NULL, "alcMakeContextCurrent failed in InitializeAL.", "Error", MB_OK | MB_ICONSTOP);CleanUp();return FALSE;}alGenBuffers(1, &Buffer);if(alGetError() != AL_NO_ERROR){MessageBox(NULL, "Error occured after alGenBuffers in InitializeAL.", "Error", MB_OK | MB_ICONSTOP);CleanUp();return FALSE;}char YoakeMae[] = "../../Big Downloads/Other Downloads/Music/Heart of Sword - Yoake Mae.wav";char FancyPants[] = "FancyPants.wav";alutLoadWAVFile(FancyPants, &format, &data, &size, &freq, &loop);if(alGetError() != AL_NO_ERROR){MessageBox(NULL, "Error occured after alutLoadWAVFile in InitializeAL.", "Error", MB_OK | MB_ICONSTOP);CleanUp();return FALSE;}alBufferData(Buffer, format, data, size, freq);if(alGetError() != AL_NO_ERROR){MessageBox(NULL, "Error occured after alBufferData in InitializeAL.", "Error", MB_OK | MB_ICONSTOP);CleanUp();return FALSE;}alutUnloadWAV(format, data, size, freq);if(alGetError() != AL_NO_ERROR){MessageBox(NULL, "alutUnloadWAV failed in InitializeAL.", "Error", MB_OK | MB_ICONSTOP);CleanUp();return FALSE;}alGenSources(1, &Source);if(alGetError() != AL_NO_ERROR){MessageBox(NULL, "alGenSources failed in InitializeAL.", "Error", MB_OK | MB_ICONSTOP);CleanUp();return FALSE;}alSourcei (Source, AL_BUFFER,   Buffer   );alSourcef (Source, AL_PITCH,    1.0 );alSourcef (Source, AL_GAIN,1.0 );alSourcefv(Source, AL_POSITION, SourcePos);alSourcefv(Source, AL_VELOCITY, SourceVel);alSourcefv(Source, AL_DIRECTION,SourceOri);alSourcei (Source, AL_LOOPING,  loop);if(alGetError() != AL_NO_ERROR){MessageBox(NULL, "alSource failed in InitializeAL.", "Error", MB_OK | MB_ICONSTOP);CleanUp();return FALSE;}alListenerfv(AL_POSITION, ListenerPos);alListenerfv(AL_VELOCITY, ListenerVel);alListenerfv(AL_ORIENTATION, ListenerOri);if(alGetError() != AL_NO_ERROR){MessageBox(NULL, "alListener failed in InitializeAL.", "Error", MB_OK | MB_ICONSTOP);CleanUp();return FALSE;}return TRUE;}
  Well, what you would need is an mp3 loading library, personally i would suggest going for ogg (vorbis) because of the liscense issues involved with using mp3.hope that helpscheers-Dan   ;  Yeah I've been googling around trying to find some tutorial on how to load an mp3 and I kept getting these linkgs with ogg voribis in em. What exactly is ogg voribis?   ;  Ogg Vorbis is just another file format, but the difference between mp3 and ogg is that ogg is free for use, and you also get access to the ogg vorbis SDK, which will help you with ogg streaming.  There is more information on the DevMaster Sound and Music Wiki, along with some links to OpenAL tutorials on streaming ogg files.Regarding the dodgy sounding wav.  It is strange that the music sample is distorted.  I know the Fansy Pants sample works fine (I have it here too!), so are you changing _anything_ or just the file name of the sample?  Is the music wav large?  Music samples are generally very large as wav's due to the lack of compression.  That could be a source of your problem.  Maybe you could try just shortening the msuic sample to about 1/2 secs, to see if the distortion still occurs.Hope that helpsSpree   ;  Hrm. I thought mp3s were just like any other format, what exactly do you mean they're not free for use? And I would still like to know how to load mp3 files anyway. I mean I'm just programming as a hobby right now, I just want to be able to play some of my music files. I'm going to be the only one running these programs. Also, the wav file is 3.04 MB. And I'm not changing anything except the file alutLoadWAVFile loads.   ;  Mp3 is a licenced compression format, which means that any application that uses them (or more specifically decodes them and plays them) has to pay a licence fee.  Now if no-one but you is going to use it, and no-one but you will ever see it, you don't have to pay, simply because the mp3 guys won't know about it.For more information have a look at the mp3 licencing web site.I have never bothered looking for mp3 decoding tutorials, I have always stuck with ogg.  There are probably some resources out there, you will just have to google to find them.You could of course look at Wots Its Format, which has some information on the mp3 file format, and might help you out.Regarding the distorted sample.  Try other sample (try all the window wav files) or record another song (you could use Audacity/ if you have no other way), and try that one.  It could just be the wav file.I don't know if you know, but the wav file format has many different actual definitions, and if you are using alut to load the sample (or you have created your own), it might not be guarenteed to load it correctly.Spree;  Hrm. K thx. Well I won't bother trying to figure out what went wrong with it since, as I said, it's the only song I have that's in wav format, and it wasn't particularly a favorite anyway. Thx for the help. =)   