Until now we did not use the thing that makes delphi (object-pascal) a great tool to use: Object-oriented programming.
Now it is even easier to use OpenAL. In the uses we need to add oooal, then:
- in the form create event we need
- in the form destroy event we need
if sound1.playing then sound1.Stop;
- changing the position is as easy as:
if sound1.playing then sound1.update;
For the time being we still need to init openal in the form create event and close it in the form destroy event. Also setting up the listener pos is still done in the form create event.
How things work inside oooal.pas is explained in the previous lessons. oooal.pas will be extended in the future lessons.
Take a look at the example. It shows how to play a single sound and how to change a looped sound's position realtime.