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 04-30-2006, 10:55 AM   #1
animatedantmo
New Member
 
animatedantmo's Avatar
 
Join Date: Apr 2006
Posts: 4
Default need openal help

Im trying to see if i can produce a working openal console proj from "scratch". I can get the sample code to compile without errors but whenever i simply transfer the code to a blank project i can not produce any sounds. I recieve two warnings about the depricated alut functions but that is it. Would someone be kind enough to look at the code and tell me if i have done anything wrong?


Code:
#include <al/alut.h> #include <al/Framework.h> #define WAV_FILE "smile.wav" // Position of the source sound. ALfloat SourcePos[] = { 0.0, 0.0, 0.0 }; // Velocity of the source sound. ALfloat SourceVel[] = { 0.0, 0.0, 0.0 }; // Position of the Listener. ALfloat ListenerPos[] = { 0.0, 0.0, 0.0 }; // Velocity of the Listener. ALfloat ListenerVel[] = { 0.0, 0.0, 0.0 }; // Orientation of the Listener. (first 3 elements are "at", second 3 are "up") // Also note that these should be units of '1'. ALfloat ListenerOri[] = { 0.0, 0.0, -1.0, 0.0, 1.0, 0.0 }; int main() { ALuint buffer; ALuint source; ALenum format; ALsizei size; ALvoid *data; ALsizei freq; ALboolean loop; ALint error; ALCdevice *device = alcOpenDevice(NULL); if (device) { ALCcontext *context = alcCreateContext(device,NULL); alcMakeContextCurrent(context); } alGetError(); // clear error code alGenBuffers(1, &buffer); if ((error = alGetError()) != AL_NO_ERROR) { return(-1); } // Load test.wav alutLoadWAVFile(WAV_FILE,&format,&data,&size,&freq,&loop); if ((error = alGetError()) != AL_NO_ERROR) { alDeleteBuffers(1, &buffer); return(-2); } // Copy test.wav data into AL Buffer 0 alBufferData(buffer,format,data,size,freq); if ((error = alGetError()) != AL_NO_ERROR) { alDeleteBuffers(1, &buffer); return(-3); } // Unload test.wav alutUnloadWAV(format, data, size, freq); if ((error = alGetError()) != AL_NO_ERROR) { alDeleteBuffers(1, &buffer); return(-4); } // Generate Sources alGenSources(1, &source); if ((error = alGetError()) != AL_NO_ERROR) { return(-5); } 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); alSourcei (source, AL_LOOPING, loop ); if(alGetError() != AL_NO_ERROR) return(-6); // Attach buffer 0 to source alSourcei(source, AL_BUFFER, buffer); if ((error = alGetError()) != AL_NO_ERROR) { return(-7); } alListenerfv(AL_POSITION, ListenerPos); alListenerfv(AL_VELOCITY, ListenerVel); alListenerfv(AL_ORIENTATION, ListenerOri); alSourcePlay(source); // EXIT ALCcontext *Context=alcGetCurrentContext(); ALCdevice *Device=alcGetContextsDevice(Context); alcMakeContextCurrent(NULL); alcDestroyContext(Context); alcCloseDevice(Device); return(0); }
animatedantmo is offline   Reply With Quote
Old 04-30-2006, 11:02 AM   #2
Reedbeta
DevMaster Staff
 
Join Date: Oct 2004
Location: Seattle, WA
Posts: 3,707
Default Re: need openal help

When you transfer the code to a blank project, are you setting it to link with the OpenAL libraries? Also, is "smile.wav" in the new project directory?
___________________________________________
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-30-2006, 11:46 AM   #3
animatedantmo
New Member
 
animatedantmo's Avatar
 
Join Date: Apr 2006
Posts: 4
Default Re: need openal help

Quote:
Originally Posted by Reedbeta
When you transfer the code to a blank project, are you setting it to link with the OpenAL libraries? Also, is "smile.wav" in the new project directory?

I believe i have set it to link to the openal lib otherwise i would get linker errors right? I have "alut.lib OpenAL32.lib" listed in the additional dependencies spot for the linker settings. and smile.wav is in the project directory (with the main.cpp file)
animatedantmo is offline   Reply With Quote
Old 05-01-2006, 01:29 AM   #4
_fs
New Member
 
Join Date: May 2006
Location: Australia
Posts: 1
Default Re: need openal help

If you're using windows check any openal dlls are accessable (in the path or the same directory as the program)
_fs is offline   Reply With Quote
Old 05-01-2006, 11:11 AM   #5
animatedantmo
New Member
 
animatedantmo's Avatar
 
Join Date: Apr 2006
Posts: 4
Default Re: need openal help

Quote:
Originally Posted by _fs
If you're using windows check any openal dlls are accessable (in the path or the same directory as the program)

alut.dll is in the directory but i dont have any openal dll files. also the program doesnt run without the alut.dll file so does that mean alut.dll is the only one it needs?
animatedantmo is offline   Reply With Quote
Old 05-12-2006, 12:51 PM   #6
animatedantmo
New Member
 
animatedantmo's Avatar
 
Join Date: Apr 2006
Posts: 4
Default Re: need openal help

OK i managed to get sound to work. I used a different OpenAL32.dll and that seemed to fix the problem.

Thanks for trying guys
animatedantmo 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 06:03 AM.


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