sounds

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
ondrew
Posts: 20
Joined: Fri Oct 03, 2003 2:24 pm
Location: Czech Republic

Post by ondrew »

I use OpenAL with Irrlicht. Basically I took the initialization code from this tutorial http://www.devmaster.net/articles/opena ... esson1.php.

And every frame I call this function

Code: Select all

void UpdateListener(scene::ICameraSceneNode *camera)
{
    core::vector3df cameraPosition, cameraTarget, cameraUp;	
    
    cameraPosition = camera->getPosition();
    ListenerPos[0] = cameraPosition.X/100;
    ListenerPos[1] = cameraPosition.Y/100;
    ListenerPos[2] = cameraPosition.Z/100;
        
    cameraTarget = camera->getTarget();
    ListenerOri[0] = (cameraTarget.X - cameraPosition.X);
    ListenerOri[1] = (cameraTarget.Y - cameraPosition.Y);
    ListenerOri[2] = -1 * (cameraTarget.Z - cameraPosition.Z);

    cameraUp = camera->getUpVector();
    ListenerOri[3] = cameraUp.X;
    ListenerOri[4] = cameraUp.Y;
    ListenerOri[5] = cameraUp.Z;
    
    alListenerfv(AL_POSITION,    ListenerPos);
    alListenerfv(AL_VELOCITY,    ListenerVel);
    alListenerfv(AL_ORIENTATION, ListenerOri);
}
I don't know why is the Z axis in target vector is constructed in different way than the X and Y, but I suppose it has something to do with differences in representation of 3D space between Irrlicht and OpenAL.

I'm dividing the Irrlicht coordinates by 100, but I should probably change listener's AL_MAX_DISTANCE, AL_REFERENCE_DISTANCE, .... Haven't time to play with it, yet.
LordNaikon
Posts: 164
Joined: Wed May 05, 2004 5:34 pm
Location: Germany Berlin
Contact:

Post by LordNaikon »

thx very much ondrew!
q|^.^|p beeing every time friendly to everyone
sys: 2500+Barton 512MB 6600GT WinXP
ondrew
Posts: 20
Joined: Fri Oct 03, 2003 2:24 pm
Location: Czech Republic

Post by ondrew »

Very simple Dev-Cpp project that shows how to use OpenAL with Irrlicht.

http://ludum.rvp.cz/downloads/openal.zip - 960kB
LordNaikon
Posts: 164
Joined: Wed May 05, 2004 5:34 pm
Location: Germany Berlin
Contact:

Post by LordNaikon »

thx , i have try it but it seems ti's not a problem of the implemantation it's more a problem of the correct lib linking. but i am not able to do this so that i can compile it :cry: :cry: :cry: :cry: :cry: :cry:
q|^.^|p beeing every time friendly to everyone
sys: 2500+Barton 512MB 6600GT WinXP
ondrew
Posts: 20
Joined: Fri Oct 03, 2003 2:24 pm
Location: Czech Republic

Post by ondrew »

Are you using Dev-Cpp?

If so, you need to add to
Project\Project options\Parameters\Linker
following lines
-lalut
-lOpenAL32
or
P:\ath\To\libAlut.a
P:\ath\To\libOpenAL32.a

The order is very important, libAlut must be first. According to OpenAL mailing list it will not work in different order. However noone knows why.
LordNaikon
Posts: 164
Joined: Wed May 05, 2004 5:34 pm
Location: Germany Berlin
Contact:

Post by LordNaikon »

no i use MSVC++ 6
if i am compiling your example this errors occurs:
--------------------Konfiguration: main - Win32 Debug--------------------
Linker-Vorgang läuft...
main.obj : error LNK2001: Nichtaufgeloestes externes Symbol __imp__alSourcefv
main.obj : error LNK2001: Nichtaufgeloestes externes Symbol __imp__alSourcef
main.obj : error LNK2001: Nichtaufgeloestes externes Symbol __imp__alSourcei
main.obj : error LNK2001: Nichtaufgeloestes externes Symbol __imp__alGenSources
main.obj : error LNK2001: Nichtaufgeloestes externes Symbol _alutUnloadWAV
main.obj : error LNK2001: Nichtaufgeloestes externes Symbol __imp__alBufferData
main.obj : error LNK2001: Nichtaufgeloestes externes Symbol _alutLoadWAVFile
main.obj : error LNK2001: Nichtaufgeloestes externes Symbol __imp__alGetError
main.obj : error LNK2001: Nichtaufgeloestes externes Symbol __imp__alGenBuffers
main.obj : error LNK2001: Nichtaufgeloestes externes Symbol __imp__alListenerfv
main.obj : error LNK2001: Nichtaufgeloestes externes Symbol _alutExit
main.obj : error LNK2001: Nichtaufgeloestes externes Symbol __imp__alDeleteSources
main.obj : error LNK2001: Nichtaufgeloestes externes Symbol __imp__alDeleteBuffers
main.obj : error LNK2001: Nichtaufgeloestes externes Symbol __imp__alSourcePlay
main.obj : error LNK2001: Nichtaufgeloestes externes Symbol _alutInit
Debug/main.exe : fatal error LNK1120: 15 unaufgeloeste externe Verweise
Fehler beim Ausführen von link.exe.

main.exe - 16 Fehler, 0 Warnung(en)
i am using the german version of MSVC++ 6 :wink:
but i have linked the include files and libs
q|^.^|p beeing every time friendly to everyone
sys: 2500+Barton 512MB 6600GT WinXP
LordNaikon
Posts: 164
Joined: Wed May 05, 2004 5:34 pm
Location: Germany Berlin
Contact:

Post by LordNaikon »

i think i solved the problem .. i have only a bit problems with it ... it was the linking problem :oops: as i said .. i am to silly for that 8)

how do i load and finally play mp3 with openAl? is there a function like alutLoadWAVFile() .... alutLoadMP3File()
q|^.^|p beeing every time friendly to everyone
sys: 2500+Barton 512MB 6600GT WinXP
ondrew
Posts: 20
Joined: Fri Oct 03, 2003 2:24 pm
Location: Czech Republic

Post by ondrew »

OpenAL can handle only wav files. However there is experimental ogg-vorbis support in the OpenAL's CVS via AL_FORMAT_VORBIS_EXT extension.

I'll post something here as soon as I find out how it works.

There is also other way to play ogg files. Decompress them to memory and play them as if they were waves http://www.devmaster.net/articles/opena ... esson8.php .

That would work also with mp3s, but I have no experience with it.
LordNaikon
Posts: 164
Joined: Wed May 05, 2004 5:34 pm
Location: Germany Berlin
Contact:

Post by LordNaikon »

would be nice if you find a way. why does the openAL guys only implemented wav file format natively? are there plans to implement other formats natively like mp3 or ogg? this first decompressing thing isn't really good i think because of lost of speed, isn't it?
q|^.^|p beeing every time friendly to everyone
sys: 2500+Barton 512MB 6600GT WinXP
ondrew
Posts: 20
Joined: Fri Oct 03, 2003 2:24 pm
Location: Czech Republic

Post by ondrew »

They didn't really implemented support for wav files. The wav file structure is so simple, you can just strip the headers and send it without modification to the soundcard. In linux you would do:

Code: Select all

cat sample.wav > /dev/dsp
As I wrote before, the ogg support is in the CVS. MP3 won't be supported because it's licensed format.

The problem is if the ogg/mp3 is stereo (how do you position stereo source in 3d space) or variable bit rate. With standard wav file you simply don't have these problems.

To uncompress ogg/mp3 to memory and play it from there doesn't have to be much memory consuming, if you use the streaming technique described in previous link. It's the standard way to do it. Every sound playing application does it this way.

In my application I use the wav files for sounds - if it's good enough for John Carmack, it's good enough for me :D . But I want to use ogg to do music, so I will inform you about my progress :D
LordNaikon
Posts: 164
Joined: Wed May 05, 2004 5:34 pm
Location: Germany Berlin
Contact:

Post by LordNaikon »

ondrew wrote:The problem is if the ogg/mp3 is stereo (how do you position stereo source in 3d space)
interesting :idea: i really don't thought about this problem :D

i have starting sound programmen only a few days before!
ondrew wrote: if it's good enough for John Carmack, it's good enough for me
thats right 8) but i want to use mp3 or ogg not because of the brilliant sound quality! wav is a very huge file format! and this increased tenfold the download time of my game! if i want to use lot of sound :cry:
q|^.^|p beeing every time friendly to everyone
sys: 2500+Barton 512MB 6600GT WinXP
The unholy
Posts: 31
Joined: Wed Dec 10, 2003 5:53 pm
Contact:

Post by The unholy »

E:\Programming\Game developing\Irrlicht\irrlicht-0.6\examples\hoc\main.cpp(3) : fatal error C1083: Cannot open include file: 'audiere.h': No such file or directory
Error executing cl.exe.
Creating browse info file...
BSCMAKE: error BK1506 : cannot open file '.\Debug\main.sbr': No such file or directory
Error executing bscmake.exe.
what the hell is going on.... :evil:
I got these error when I code like this
//**************sound****************************

AudioDevicePtr audiereDevice;
OutputStreamPtr stream;

audiereDevice = OpenDevice();
if (!audiereDevice)
return 1;

stream = OpenSound(audiereDevice.get(), "../../media/IrrlichtTheme.mp3", true);
if (!stream)
return 2;

stream->setRepeat(true);
stream->setVolume(1.0f); // 50% volume
stream->play();

//****************************************************
:( help me ... i am on the way

----------------------------------------------
jr.John Carmack ( who is that duplicate)[/list]
LordNaikon
Posts: 164
Joined: Wed May 05, 2004 5:34 pm
Location: Germany Berlin
Contact:

Post by LordNaikon »

Cannot open include file: 'audiere.h': No such file or directory
eventually you don't link to the header files or libs.. or you don't download and install audire?

make sure you have installed this!!

Code: Select all

#include <audiere.h> // your compiler throws an error here? get audiere from 
                     // http://audiere.sourceforge.net/ or uncomment 
                     // the define USE_AUDIERE above.
q|^.^|p beeing every time friendly to everyone
sys: 2500+Barton 512MB 6600GT WinXP
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

Post by Peter Müller »

Perhaps you didn't set the audiere directory in your dir options.
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

download the audiere sdk, and configure your compiler's paths to the "include" and "lib" folders of the sdk.
Image
Post Reply