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

Go Back   DevMaster.net Forums > Site Discussions > Articles Discussion
User Name
Password
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
Old 06-14-2003, 06:59 PM   #1
DmEditor
DevMaster Editor
 
Join Date: Jan 2005
Posts: 54
Default

OpenAL Lesson 1: Single Static Source
Author:: Jesse Maurais
Description: The simplest OpenAL program involving only one non-moving source.

Post your discussions/comments here by clicking on Add Reply.
DmEditor is offline   Reply With Quote
Old 06-15-2003, 02:26 AM   #2
baldurk
DevMaster Staff
 
baldurk's Avatar
 
Join Date: Jan 2003
Location: Mars
Posts: 1,141
Default

It looks all screwed up on my screen. The text is OK, but the code is black on black :/
___________________________________________
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.
baldurk is offline   Reply With Quote
Old 06-15-2003, 09:06 AM   #3
Noor
Senior Member
 
Join Date: Jan 2003
Location: ON, Canada
Posts: 524
Default

hmmm, It's looks good to me... Maybe it's because your using linux?
___________________________________________
"What ever happened to happily ever after?"
Noor is offline   Reply With Quote
Old 06-15-2003, 10:12 AM   #4
Dia Kharrat
DevMaster Staff
 
Join Date: Jan 2003
Posts: 1,201
Default

baldurk: very strange. Anyone else having the same problems?
Dia Kharrat is offline   Reply With Quote
Old 06-15-2003, 10:24 AM   #5
donBerto
Senior Member
 
donBerto's Avatar
 
Join Date: Jan 2003
Location: East Coast, USA
Posts: 370
Default

same here!

conio! NOoo...

___________________________________________
Imagine.
donBerto is offline   Reply With Quote
Old 06-15-2003, 11:17 AM   #6
baldurk
DevMaster Staff
 
baldurk's Avatar
 
Join Date: Jan 2003
Location: Mars
Posts: 1,141
Default

I'll bet good money that it's non HTML compliant code, which IE renders incorrectly, but it looks good :/
___________________________________________
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.
baldurk is offline   Reply With Quote
Old 06-15-2003, 02:28 PM   #7
anubis
DevMaster Staff
 
anubis's Avatar
 
Join Date: Apr 2003
Location: Germany
Posts: 2,328
Default

same here ( i use mozilla-firebird ). the text is ok but black on black code.
___________________________________________
If Prolog is the answer, what is the question ?
anubis is offline   Reply With Quote
Old 06-15-2003, 02:30 PM   #8
anubis
DevMaster Staff
 
anubis's Avatar
 
Join Date: Apr 2003
Location: Germany
Posts: 2,328
Default

and sure enough it looks fine with IE.
___________________________________________
If Prolog is the answer, what is the question ?
anubis is offline   Reply With Quote
Old 06-15-2003, 04:02 PM   #9
Dia Kharrat
DevMaster Staff
 
Join Date: Jan 2003
Posts: 1,201
Default

ok...its fixed now. Let me know if there are any other problems.
Dia Kharrat is offline   Reply With Quote
Old 06-16-2003, 01:51 AM   #10
anubis
DevMaster Staff
 
anubis's Avatar
 
Join Date: Apr 2003
Location: Germany
Posts: 2,328
Default

looks good now. what did you do to fix it ?
___________________________________________
If Prolog is the answer, what is the question ?
anubis is offline   Reply With Quote
Old 06-16-2003, 10:05 AM   #11
Dia Kharrat
DevMaster Staff
 
Join Date: Jan 2003
Posts: 1,201
Default

just changed some minor syntax errors
Its strange that IE still parsed those errors correctly.
Dia Kharrat is offline   Reply With Quote
Old 06-16-2003, 11:23 AM   #12
baldurk
DevMaster Staff
 
baldurk's Avatar
 
Join Date: Jan 2003
Location: Mars
Posts: 1,141
Default

told you so
___________________________________________
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.
baldurk is offline   Reply With Quote
Old 10-15-2003, 01:18 AM   #13
i2eye
New Member
 
Join Date: Oct 2003
Posts: 4
Default

Hello, I've been following up the tutorials and seeing how the programs work. And I tried to assign a different position for the source by modifying the line

ALfloat SourcePos[] = { 0.0, 0.0, 0.0 };

hoping that I would hear the 'FancyPants' sound from some other place.
But it didn't work. Is there anything else I should have changed also? Am I missing something...?
i2eye is offline   Reply With Quote
Old 10-15-2003, 02:09 PM   #14
TheCell
New Member
 
Join Date: Jun 2003
Posts: 24
Default

If you want to change a source's position, you must ensure that your source is mono(1 channel). The FancyPants.wav is a stereo sound file(2 channels) and thus, you cannot change it's position.
TheCell is offline   Reply With Quote
Old 10-15-2003, 06:02 PM   #15
i2eye
New Member
 
Join Date: Oct 2003
Posts: 4
Default

Grrrr...that was it. I overlooked that part. Thanks a lot
i2eye is offline   Reply With Quote
Old 07-12-2004, 06:47 AM   #16
DaRkZeAlOt
New Member
 
Join Date: Jul 2004
Posts: 1
Angry

Hi,
I'm trying to compile the source with MinGW and getting severals errors :

Linking...
Warning: .drectve `-defaultlib:uuid.lib ' unrecognized
Warning: .drectve `-defaultlib:uuid.lib ' unrecognized
D:\Office\MinGWStudio\Lib\alut.lib(.\Release\ALut. obj.B)(.text+0x6):C:\Documents and S: undefined reference to `alcOpenDevice'
D:\Office\MinGWStudio\Lib\alut.lib(.\Release\ALut. obj.B)(.text+0xe):C:\Documents and S: undefined reference to `alcCreateContext'
D:\Office\MinGWStudio\Lib\alut.lib(.\Release\ALut. obj.B)(.text+0x14):C:\Documents and S: undefined reference to `alcMakeContextCurrent'
D:\Office\MinGWStudio\Lib\alut.lib(.\Release\ALut. obj.B)(.text+0x3):C:\Documents and S: undefined reference to `alcGetCurrentContext'
D:\Office\MinGWStudio\Lib\alut.lib(.\Release\ALut. obj.B)(.text+0xb):C:\Documents and S: undefined reference to `alcGetContextsDevice'
D:\Office\MinGWStudio\Lib\alut.lib(.\Release\ALut. obj.B)(.text+0x14):C:\Documents and S: undefined reference to `alcMakeContextCurrent'
D:\Office\MinGWStudio\Lib\alut.lib(.\Release\ALut. obj.B)(.text+0x1a):C:\Documents and S: undefined reference to `alcDestroyContext'
D:\Office\MinGWStudio\Lib\alut.lib(.\Release\ALut. obj.B)(.text+0x20):C:\Documents and S: undefined reference to `alcCloseDevice'

I used the newest SDK from creative and added the openal32 and alut libs. Did i set up something wrong ?
DaRkZeAlOt is offline   Reply With Quote
Old 07-12-2004, 11:53 AM   #17
anubis
DevMaster Staff
 
anubis's Avatar
 
Join Date: Apr 2003
Location: Germany
Posts: 2,328
Default

i don't know... what's the library format used by mingw ?
___________________________________________
If Prolog is the answer, what is the question ?
anubis is offline   Reply With Quote
Old 08-11-2004, 05:13 AM   #18
Xiroxium
New Member
 
Join Date: Aug 2004
Posts: 3
Default

Quote:
Originally Posted by DaRkZeAlOt
Hi,
I'm trying to compile the source with MinGW and getting severals errors :

Linking...
Warning: .drectve `-defaultlib:uuid.lib ' unrecognized
Warning: .drectve `-defaultlib:uuid.lib ' unrecognized
D:\Office\MinGWStudio\Lib\alut.lib(.\Release\ALut. obj.B)(.text+0x6):C:\Documents and S: undefined reference to `alcOpenDevice'
D:\Office\MinGWStudio\Lib\alut.lib(.\Release\ALut. obj.B)(.text+0xe):C:\Documents and S: undefined reference to `alcCreateContext'
D:\Office\MinGWStudio\Lib\alut.lib(.\Release\ALut. obj.B)(.text+0x14):C:\Documents and S: undefined reference to `alcMakeContextCurrent'
D:\Office\MinGWStudio\Lib\alut.lib(.\Release\ALut. obj.B)(.text+0x3):C:\Documents and S: undefined reference to `alcGetCurrentContext'
D:\Office\MinGWStudio\Lib\alut.lib(.\Release\ALut. obj.B)(.text+0xb):C:\Documents and S: undefined reference to `alcGetContextsDevice'
D:\Office\MinGWStudio\Lib\alut.lib(.\Release\ALut. obj.B)(.text+0x14):C:\Documents and S: undefined reference to `alcMakeContextCurrent'
D:\Office\MinGWStudio\Lib\alut.lib(.\Release\ALut. obj.B)(.text+0x1a):C:\Documents and S: undefined reference to `alcDestroyContext'
D:\Office\MinGWStudio\Lib\alut.lib(.\Release\ALut. obj.B)(.text+0x20):C:\Documents and S: undefined reference to `alcCloseDevice'

I used the newest SDK from creative and added the openal32 and alut libs. Did i set up something wrong ?
[snapback]8696[/snapback]

Your undefined reference errors are coming from a bug in ld. You must include the libraries in a specific order on the command line - libALut.a must be specified before libOpenAL32.a (i.e. -lALut -lOpenAL32).

The other warnings - "Warning: .drectve `-defaultlib:uuid.lib ' unrecognized" - I am still trying to figure out. I have Googled around to no avail, but I suspect the problem is incompatible MS libs with MinGW32 (despite the fact I am also using an OpenAL package suited specifically for MinGW!).

Does anyone else know the meaning of this .drectve warning, or - even better - how to fix it?

- Xiroxium
Xiroxium is offline   Reply With Quote
Old 08-11-2004, 07:58 AM   #19
davepermen
Senior Member
 
davepermen's Avatar
 
Join Date: Jan 2003
Location: Switzerland
Posts: 1,333
Default

you can't use ms .lib's, you need some convertor.. i don't know where you get one, i just know i had to use one once..
___________________________________________
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....
davepermen is offline   Reply With Quote
Old 11-03-2004, 01:20 PM   #20
doc z
New Member
 
Join Date: Nov 2004
Posts: 1
Default

hi

i am pretty sure i have done everything in the tutorial

but i cant get the sound to play for me

not a single source would play .... well i only have a single source

i know the functions are working coz when i press 1 to play the sound, it does out put "1 pessed ..... playing source"

where could i be screwing it i wonder

any ideas ????

thanks

z
doc z is offline   Reply With Quote
Old 10-27-2005, 11:24 PM   #21
jeeva86
New Member
 
Join Date: Oct 2005
Posts: 4
Default Re: OpenAL Lesson 1: Single Static Source

Hi, I've read this tutorial and I've been trying to understand it..I'm a beginner at programming but I just want to play a dedicated wav file through this, similar to the tutorial. I can open the project in VC6++, and I can see the main.cpp file with all the coding. Why is it that when I compile and build and run the program, typing "p" or whatever doesn't do anything, while running the lesson1.exe file initially, without any changes works fine and I hear "hello mr. fancy pants" I can't seem to see the solution to this and have been messing around with it for quite some time now. I have a WAV file which I wanna be played in the same manner as hello mr. fancy pants..can anyone help me please. Thank you
jeeva86 is offline   Reply With Quote
Old 01-14-2006, 10:19 PM   #22
pa1
New Member
 
Join Date: Jan 2006
Location: Chile
Posts: 14
Default Re: OpenAL Lesson 1: Single Static Source

Hello, I changed the code so now It sounds. I added a context inicialization and a alternative exit function. The new code goes after the //NEW:.
I hope this will help you.

Code:
/********************************************** *Change by TheCell(TheCell61@hotmail.com) *I did not change much, other than headers and *library included to the project *Also, once you've downloaded the sdk, you must *copy the files you've got from the sdk *according to this template *$MSDEV/ * | * include/ * | * al/ * | * | al.h * | alc.h * | alut.h * | * lib/ * | * ! alut.lib * | openal32,lib * *If you don't copy all the .h files into the *include dir, you'll get compile error *and if you don't copy the .lib files *to the correct directory AND and add them to *the project, you'll get link error ***********************************************/ /********************************************** *Change: Added stdio.h * changed al/alut.c to al/alut.h * ***********************************************/ /********************************************** *Explanation 1:Since we use printf, we MUST * include stdio.h to use this * function * * 2:I have been searching for * the alut.c files, but I have * not found it. So I assume * that alut.h was intended * instead ************************************************/ #include <conio.h> #include <stdlib.h> #include <stdio.h> //For some reason, stdio.h were not included, so I added it(TheCell) //See Explanation 1 #include <al/al.h> #include <al/alc.h> //#include <al/alut.c> Since I have not found alut.c anywhere, I suppose we use alut.h #include <al/alut.h> //Added by TheCell //NEW: //See explanation 2 // Global variables; static ALCdevice *g_currentDevice = NULL; static ALCcontext *g_currentContext = NULL; //NEW: ALboolean ALinit(ALchar *device) { ALint lMajor, lMinor; g_currentDevice = alcOpenDevice(device); if(NULL == g_currentDevice) { return AL_FALSE; } alcGetError( g_currentDevice ); g_currentContext = alcCreateContext(g_currentDevice, NULL); if(NULL == g_currentContext) { return AL_FALSE; } alcMakeContextCurrent(g_currentContext); alcGetIntegerv( g_currentDevice, ALC_MAJOR_VERSION, 1, &lMajor ); alcGetIntegerv( g_currentDevice, ALC_MINOR_VERSION, 1, &lMinor ); printf( "\nOpen AL Version %d.%d\n", lMajor, lMinor ); printf("Renderer : %s\n", (ALchar*)alGetString(AL_RENDERER)); printf("Vendor : %s\n", (ALchar*)alGetString(AL_VENDOR)); return AL_TRUE; } //NEW: void ALclose() { alcDestroyContext(g_currentContext); alcCloseDevice(g_currentDevice); } /* * These are OpenAL "names" (or "objects"). They store and id of a buffer * or a source object. Generally you would expect to see the implementation * use values that scale up from '1', but don't count on it. The spec does * not make this mandatory (as it is OpenGL). The id's can easily be memory * pointers as well. It will depend on the implementation. */ // Buffers to hold sound data. ALuint Buffer; // Sources are points of emitting sound. ALuint Source; /* * These are 3D cartesian vector coordinates. A structure or class would be * a more flexible of handling these, but for the sake of simplicity we will * just leave it as is. */ // 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 }; /* * ALboolean LoadALData() * * This function will load our sample data from the disk using the Alut * utility and send the data into OpenAL as a buffer. A source is then * also created to play that buffer. */ 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; alutLoadWAVFile("wavdata/FancyPants.wav", &format, &data, &size, &freq, &loop); alBufferData(Buffer, format, data, size, freq); alutUnloadWAV(format, data, size, freq); // Bind the buffer with the source. alGenSources(1, &Source); if(alGetError() != AL_NO_ERROR) return AL_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); alSourcei (Source, AL_LOOPING, loop ); // Do another error check and return. if(alGetError() == AL_NO_ERROR) return AL_TRUE; return AL_FALSE; } /* * void SetListenerValues() * * We already defined certain values for the Listener, but we need * to tell OpenAL to use that data. This function does just that. */ void SetListenerValues() { alListenerfv(AL_POSITION, ListenerPos); alListenerfv(AL_VELOCITY, ListenerVel); alListenerfv(AL_ORIENTATION, ListenerOri); } /* * void KillALData() * * We have allocated memory for our buffers and sources which needs * to be returned to the system. This function frees that memory. */ void KillALData() { alDeleteBuffers(1, &Buffer); alDeleteSources(1, &Source); alutExit(); } int main(int argc, char *argv[]) { //NEW: if(AL_FALSE == ALinit(NULL)) { return 1; } printf("MindCode's OpenAL Lesson 1: Single Static Source\n\n"); printf("Controls:\n"); printf("p) Play\n"); printf("s) Stop\n"); printf("h) Hold (pause)\n"); printf("q) Quit\n\n"); // Initialize OpenAL and clear the error bit. alutInit(NULL, 0); alGetError(); // Load the wav data. if(LoadALData() == AL_FALSE) { printf("Error loading data."); return 0; } SetListenerValues(); // Setup an exit procedure. atexit(KillALData); // Loop. ALubyte c = ' '; while(c != 'q') { c = getche(); switch(c) { // Pressing 'p' will begin playing the sample. case 'p': alSourcePlay(Source); break; // Pressing 's' will stop the sample from playing. case 's': alSourceStop(Source); break; // Pressing 'h' will pause the sample. case 'h': alSourcePause(Source); break; }; } //NEW: ALclose(); return 0; }
pa1 is offline   Reply With Quote
Old 04-21-2006, 07:04 AM   #23
ace4884
New Member
 
Join Date: Apr 2006
Location: lincoln
Posts: 1
Default Re: OpenAL Lesson 1: Single Static Source

hi
im new to all this programming stuff
I got the above code but I get the error:

--------------------Configuration: main - Win32 Debug--------------------
Linking...
main.obj : error LNK2001: unresolved external symbol __imp__alutUnloadWAV
main.obj : error LNK2001: unresolved external symbol __imp__alutLoadWAVFile
main.obj : error LNK2001: unresolved external symbol __imp__alutExit
main.obj : error LNK2001: unresolved external symbol __imp__alutInit
Debug/main.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.

main.exe - 5 error(s), 0 warning(s)
--------------------------------------------------------------------------

can any one tell me what it means and how i can fix it

Thanx AC
ace4884 is offline   Reply With Quote
Old 04-21-2006, 08:08 AM   #24
monjardin
Senior Member
 
Join Date: Oct 2005
Location: Pensacola, FL
Posts: 1,028
Default Re: OpenAL Lesson 1: Single Static Source

Are you linking to the ALUT library?
___________________________________________
monjardin's JwN Meter (1,2,3,4,5,6):
|----|----|----|----|----|----|----|----|----|----|
*
monjardin is offline   Reply With Quote
Old 05-02-2006, 03:42 AM   #25
sagoga69
New Member
 
Join Date: May 2006
Location: Spain
Posts: 10
Default Re: OpenAL Lesson 1: Single Static Source

Where´s the ALUT library?
I have only found the OpenAL32.lib in the OpenAL folder.
sagoga69 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 08:00 AM.


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