DevMaster.net Forums
[[ Home | Forums | 3D Engines Database | Wiki | Articles/Tutorials | Game Dev Jobs | IRC Chat Network | Contact Us ]]

Go Back   DevMaster.net Forums > Programming & Development > Sound and Music Programming
User Name
Password
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
Old 05-06-2005, 07:56 AM   #1
eldritch
New Member
 
Join Date: May 2005
Posts: 3
Default

Hello there, new here :)

I have begun to work with OpenAL as part of my game to get some sounds (and later music) going. Though, when I first compiled my game (no errors or warnings) and ran it, there was no sound to be heard. I quad-checked everything, and it was in order.

I then downloaded one of the samples from this site (great site btw!), and it ran just fine. I could even modify it. But... if I use the very same .CPP file from the sample in my own project file (linking to OpenAL32.lib and alut.lib), I get the same problem as above, there is no sound to be heard. I am checking if the file I am attempting to load is existant and the path is correct, so that is not the problem.

Have I managed to miss something important in the project settings??
eldritch is offline   Reply With Quote
Old 05-06-2005, 11:44 AM   #2
eldritch
New Member
 
Join Date: May 2005
Posts: 3
Default

I'll post the parts of the code where I have put the OpenAL stuff, though it is pretty intact from the tutorial, and I have compared the code a million times (and it does not really lie there since the very same file works perfectly with the original project file (.DSW/.DSP).

Code:
// The includes at the top of the file. #include <alut.h> #include <al.h> // Global variables. ALuint Buffer; ALuint Source; ALfloat SourcePos[] = { 0.0, 0.0, 0.0 }; ALfloat SourceVel[] = { 0.0, 0.0, 0.0 }; ALfloat ListenerPos[] = { 0.0, 0.0, 0.0 }; ALfloat ListenerVel[] = { 0.0, 0.0, 0.0 }; ALfloat ListenerOri[] = { 0.0, 0.0, -1.0, 0.0, 0.0, 1.0 }; // Z is up for me. 2D game. // Special AL functions. ALboolean LoadALData() { // Variables to load into. ALenum format; ALsizei size; ALvoid* data; ALsizei freq; ALboolean loop; // Load wav data into a buffer. alGenBuffers(1, &Buffer); if (alGetError() != AL_NO_ERROR) return AL_FALSE; FILE *fp = fopen("wavdata/phaser.wav", "r"); if (!fp) MessageBox(NULL, "Error loading sound!", "Error", MB_OK); else fclose(fp); alutLoadWAVFile("wavdata/phaser.wav", &format, &data, &size, &freq, &loop); alBufferData(Buffer, format, data, size, freq); alutUnloadWAV(format, data, size, freq); // Bind buffer with a source. alGenSources(1, &Source); if (alGetError() != AL_NO_ERROR) return AL_FALSE; alSourcei (Source, AL_BUFFER, Buffer ); alSourcef (Source, AL_PITCH, 1.0f ); alSourcef (Source, AL_GAIN, 1.0f ); alSourcefv(Source, AL_POSITION, SourcePos); alSourcefv(Source, AL_VELOCITY, SourceVel); alSourcei (Source, AL_LOOPING, AL_TRUE ); // Do another error check and return. if (alGetError() == AL_NO_ERROR) return AL_TRUE; return AL_FALSE; } void SetListenerValues() { alListenerfv(AL_POSITION, ListenerPos); alListenerfv(AL_VELOCITY, ListenerVel); alListenerfv(AL_ORIENTATION, ListenerOri); } void KillALData() { alDeleteBuffers(1, &Buffer); alDeleteSources(1, &Source); alutExit(); } // Excerpt from the main() function. alutInit(NULL, 0); alGetError(); if (LoadALData() == AL_FALSE) return -1; SetListenerValues(); alSourcePlay(Source); // Excerpt from the keyboard control function. if (key == 'p') alSourcePlay(Source); if (key == 'o') alSourceStop(Source); if (key == 27) { KillALData(); exit(0); }

The program uses GLUT to draw a window and OpenGL to draw primitives (it's just my simulator thingy where I test mathematical stuff).

That should work, right? I have included OpenAL32.lib and alut.lib in the Linker. And the phaser.wav file is in the correct location. Have I missed something?
eldritch is offline   Reply With Quote
Old 05-07-2005, 03:40 AM   #3
eldritch
New Member
 
Join Date: May 2005
Posts: 3
Default

Okey.. I managed to find out what was causing these anomalies.

It seems that the OpenAL32.dll that comes with the OpenAL SDK is errorful. When I use that one, I get no sounds, but programs can be quit without problems. If I use the one I already had (no idea where it came from, but probably either with Windows, the soundcard or some driver), I get sounds but an error whenever I close any program using OpenAL.

Has anyone else experienced a similar problem?
eldritch is offline   Reply With Quote
Old 10-28-2005, 06:50 AM   #4
DragonCode
New Member
 
Join Date: Oct 2005
Location: FL
Posts: 3
Default Re: OpenAL: "No sound" problem

Hey Eldritch, I am experiencing the same problem. I have gone over my code many times and it looks right. I am using the most recent SDK from the Creative web sight.

When I run the example binary it plays sounds, if I build it from the source code... I get no errors but also no sound.

Can you send me the lib file that works for you, so I can try it?
DragonCode is offline   Reply With Quote
Old 11-25-2005, 09:20 PM   #5
rdillon
New Member
 
Join Date: Nov 2005
Location: Singapore
Posts: 2
Default Re: OpenAL: "No sound" problem

I think your code'd work fine in OpenAL1.0 but now you are using the new release 1.1, right?
I had the same problem afer updating the library. It looks the problem is in the alutInit function which doesn't seem to work properly anymore.

You have to initialize the device and context directly, for example, like this:

>>>>>>>>>>>>>>>>>

ALCcontext *Context;
ALCdevice *Device;

Device = alcOpenDevice((ALchar*)"DirectSound3D");
if (Device == NULL)
{
exit(-1);
}

//Create context(s)
Context=alcCreateContext(Device,NULL);

//Set active context
alcMakeContextCurrent(Context);

alGetError();

<<<<<<<<<<<<<<<<<<

we'd also note that the alutLoadWavfile function is now deprecated (but still works fine in current version).

Hope this helps.
cheers,
Roberto
rdillon is offline   Reply With Quote
Old 11-26-2005, 04:32 AM   #6
SpreeTree
Valued Member
 
SpreeTree's Avatar
 
Join Date: Jan 2004
Location: England
Posts: 265
Default Re: OpenAL: "No sound" problem

Quote:
Originally Posted by rdillon
we'd also note that the alutLoadWavfile function is now deprecated (but still works fine in current version).

ALut now comes in its own dll/lib (don't know which as I do not actually use it, I load all the sound data myself), so alutLoadWav is probably in there, rather than actually being depreciated.

Spree
SpreeTree is offline   Reply With Quote
Old 11-26-2005, 10:19 PM   #7
rdillon
New Member
 
Join Date: Nov 2005
Location: Singapore
Posts: 2
Default Re: OpenAL: "No sound" problem

Hello,
I am not sure what you mean by "depreciated".... actually, the ALUT specification published on the official OpenAL site (http://www.openal.org/openal_webstf/specs/alut.html) clearly states that AlutLoadWavFile, ALutLoadWavMemory and AlutUnloadWav are now deprecated but still available for backward compatibility.
Interestingly, the same document doesn't say anything particular about the AlutInit function which was the one causing the problem here reported (at least on my machine).

All best!
Roberto
rdillon is offline   Reply With Quote
Old 11-27-2005, 04:54 AM   #8
SpreeTree
Valued Member
 
SpreeTree's Avatar
 
Join Date: Jan 2004
Location: England
Posts: 265
Default Re: OpenAL: "No sound" problem

As I said, I do not use alut, so I am not an authority here. But as I said, AlutLoadWavFile has been moved to the alut library, and whilst it looks like ti has been 'officially' depreciated, is still available.

Reading the OpenAL developers mailing list doesn't really make this clear though, as there seems to be a lot of too'ing and fro'ing about it.

But it looks like it has been replaced with alutCreateBufferFromFile (and the various variations that come with it), which seems to work in a similar way.

Spree
SpreeTree is offline   Reply With Quote
Old 01-24-2006, 06:36 PM   #9
Citizen Erased
New Member
 
Join Date: Jan 2006
Posts: 1
Default Re: OpenAL: "No sound" problem

I'm having the same 1.1 SDK problem. I'm pretty new to programming in general and completly new to OpenAL. Copy pasting rdillions code doesn't seem to solve the problem (although I'm probably doing something wrong), could someone quickly explain how to get the code in the first OpenAL tutorial on this site to work with the 1.1 release? Thanks.
Citizen Erased is offline   Reply With Quote
Old 02-04-2006, 03:37 AM   #10
wazoo
New Member
 
Join Date: Oct 2005
Posts: 27
Default Re: OpenAL: "No sound" problem

Code:
Device = alcOpenDevice((ALchar*)"DirectSound3D");

I just use:
Code:
Device= alcOpenDevice(NULL);

and it does the trick for me using the new 1.1 lib. I seem to remember not getting any love from the DirectSound3D flag.

Also, the SDK documentation just recommended initializing this way as well IIRC..
___________________________________________
Wazoo
Game Programming in C++: Start to Finish | Game Tutorials
wazoo is offline   Reply With Quote
Old 02-19-2006, 09:16 PM   #11
Zeussy
New Member
 
Join Date: Feb 2006
Posts: 3
Default Re: OpenAL: "No sound" problem

i cant get OpenAL to play a sound on my creative card.

Plays on the onboard nvidia sound, but my Audigy won't play sounds.

OpenAL initialises, inits buffers, sources, plays the source, i get no sound, and no error.

I dont know if its a driver issue, or just openal being crap. Driving me insaine.
Zeussy is offline   Reply With Quote
Old 02-19-2006, 10:19 PM   #12
Reedbeta
DevMaster Staff
 
Join Date: Oct 2004
Location: Seattle, WA
Posts: 3,707
Default Re: OpenAL: "No sound" problem

Zeussy, have you tried making sure the volume is turned up? (I don't just mean the volume in your speakers, but the OpenAL volume control. You never know, it might default to zero or something dumb like that.)
___________________________________________
Currently working at Sucker Punch
reedbeta.com - OpenGL demos and other projects
Luabridge - a lightweight, dependency-free C++/Lua binding library.
CD Lite - an unobtrusive, minimal CD player application for Windows.
Reedbeta is offline   Reply With Quote
Old 02-20-2006, 03:36 AM   #13
Zeussy
New Member
 
Join Date: Feb 2006
Posts: 3
Default Re: OpenAL: "No sound" problem

thanks Reedbeta, listener gain was set to 1, upped it to like 1000.f as well as the 1000 gain on the source, makes it audible.

was almost going to convert my sound handling class to fmod
Zeussy is offline   Reply With Quote
Old 04-05-2007, 10:16 PM   #14
L1zb3th
New Member
 
Join Date: Mar 2007
Location: Argentina
Posts: 10
Default Re: OpenAL: "No sound" problem

"FILE *fp = fopen("wavdata/phaser.wav", "r");
if (!fp)
MessageBox(NULL, "Error loading sound!", "Error", MB_OK);
else
fclose(fp);"

REMOVE THIS, FIRST LOAD THE WAV, THEN USE FOPEN ....
L1zb3th is offline   Reply With Quote
Old 04-06-2007, 12:10 AM   #15
Reedbeta
DevMaster Staff
 
Join Date: Oct 2004
Location: Seattle, WA
Posts: 3,707
Default Re: OpenAL: "No sound" problem

L1zb3th, that is just a check that the file exists before passing it to ALUT.
___________________________________________
Currently working at Sucker Punch
reedbeta.com - OpenGL demos and other projects
Luabridge - a lightweight, dependency-free C++/Lua binding library.
CD Lite - an unobtrusive, minimal CD player application for Windows.
Reedbeta is offline   Reply With Quote
Old 04-07-2007, 09:19 PM   #16
L1zb3th
New Member
 
Join Date: Mar 2007
Location: Argentina
Posts: 10
Default Re: OpenAL: "No sound" problem

ahh , i didnt read well xDDDDDDDD
-.-''
L1zb3th is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Forum Jump


All times are GMT -7. The time now is 05:04 AM.


Powered by vBulletin
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.