{{tip|For more information on how the openAL works, look the documentation [[http://connect.creativelabs.com/openal/Documentation/OpenAL_Programmers_Guide.pdf openAL programmers Guide ]]}}

{{tip|For more information on how the openAL works, look the documentation [[http://connect.creativelabs.com/openal/Documentation/OpenAL_Programmers_Guide.pdf openAL programmers Guide ]]}}

+

+

{{Box|TODO|={{{Create KALStream}}}

Revision as of 12:37, 13 February 2009

KALEngine tutorial

Tutorial Series

KALEngine developement

Prerequisites

None

What's Next

Nothing at the moment

Further Reading

KGLEngine2d's code

Abstract

Phonon is not really designed to handle multiple sounds at the same time. KALEngine is made for games and create one thread per sound, using the excellent openAL librairy. you also get all the other openAL goodness like 3D sounds, effects and multichannel.

Installation

1: Be sure you have installed dependent librairy.

openAL ( sound api)

alut (openal toolkit)

libSndFile (load sound file).

You can install them, from your package manager.
for exemple in kubuntu :

delete son; //when it finished! Don't forget to clear the buffer!!
snd.shutdown(); // and close the device!!

return 0;

}

-At the first line, we initialize the sound engine. KALengine::init(QString device) take in arguments the deviceName. If you want recover the list of device, you can call the static function :

QStringList KALEngine::getDevicesList().

-At the second time, we create a KALsource. KALSource is the base of openAL, for playing small sound, like shoot, scream, tic, walk ..... It load all the file sound inside a buffer! Then, be carefull if you try to load a Big music with it.
If you play your own sound, download a short song : [ocean.wav] and do like this :

KALSource *son = new KALSource("ocean.wav");

So, currently, it can only play wav file. But, in few time, maybe 1 day..., it will play ogg files.
If you want to play music, please wait tutorial for KALStream.

-And now, we can play the sound by calling :

KALSource::play()

This work like a thread! It doesn't wait the end of the song, the programm continue to work.

-Then, we must to create a loop for waiting the end of the song.
KALSource->getStatus() return the status of the song. AL_PLAYING or AL_STOPED.

-For wait inside the loop, we can print the elapsed time of playing by call :
KALSource::getElapsedTime(). It return in second the duration.

-At the end, we must clear the buffer of the KALSource , by calling :
delete son. And close the device by calling : KALEngine::shutdown().