Login  Register

Implementing openal to game

classic Classic list List threaded Threaded
3 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Implementing openal to game

Dawn
1 post
 So. After Sources Sharing Buffers lesson 5 at your site i have made a class. And then implemented in two different classes as described below. The interesting part is that it is working, but the sad that it isn't working correct. I'm new in ( at ) Java at all so my brain ( experiences ) won't see out of this so called "my brain loop".

 I'm here to ask you for any advice and that would be really, really appreciated.

Thanks a lot. Regards Andrew ( hrenovka :-) ).

else if (key == KeyEvent.VK_SPACE) {
			if (System.currentTimeMillis() - lastPressProcessed > 1000) {
				
				GameFrame.addMissle(new Missle(x, y - 5));
				contest = new contest();
				contest.initOpenAL();
				contest.loadALData();
				contest.addSource(0);
				lastPressProcessed = System.currentTimeMillis();
				
				}


GameFrame.removeEnemy(this);
				GameFrame.removeMissle(m);
				contest = new contest();
				contest.initOpenAL();
				contest.loadALData();
				contest.addSource(1);
				contest.addSource(2);
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Implementing openal to game

gouessej
Administrator
6045 posts
Hi

If you want to use JOAL but without having to understand the low level concepts, rather use Paul Lamb Sound System like me. I don't understand what is wrong. What's your problem?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Implementing openal to game

Xerxes Rånby
557 posts
In reply to this post by Dawn
Dawn wrote
So. After Sources Sharing Buffers lesson 5 at your site i have made a class. And then implemented in two different classes as described below. The interesting part is that it is working, but the sad that it isn't working correct. I'm new in ( at ) Java at all so my brain ( experiences ) won't see out of this so called "my brain loop".
You should re-design your application to only initialize OpenAL and load the samples at start-up, you only need to initialize it once!
If you have a different class that needs to play audio make sure this class can access the already initialized "contest".

When your application start do:
                                contest = new contest();
                                contest.initOpenAL();
                                contest.loadALData();


When you create a new class that needs to play audio give it access to the "contest" using its constructor.

GameInputHandler handler = new GameInputHandler(contest);


And inside this GameInputHandler use the already initialized "contest":

else if (key == KeyEvent.VK_SPACE) {
                        if (System.currentTimeMillis() - lastPressProcessed > 1000) {
                                GameFrame.addMissle(new Missle(x, y - 5));
                                contest.addSource(0);

GameFrame.removeEnemy(this);
                                GameFrame.removeMissle(m);
                                contest.addSource(1);
                                contest.addSource(2);


You can also take a look at the main of lession5
http://jogamp.org/joal-demos/www/devmaster/lesson5.html
and see that OpenAl only needs to be initialized once.

If you need further help publish the complete source-code, under a free software license, for your game.