Jogamp
www/devmaster/lesson*.html: net.java.games.joal.* -> com.jogamp.openal.*
[joal-demos.git] / www / devmaster / lesson1.html
Content-type: text/html jogamp.org Git - joal-demos.git/blame - www/devmaster/lesson1.html
Jogamp


500 - Internal Server Error

Malformed UTF-8 character (fatal) at (eval 5) line 1, <$fd> line 637.
CommitLineData
4e95ad3e 1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3<head>
aaf9d0a3
XR
4<title>JOAL OpenAL Tutorials from DevMaster.net Lesson 1: Single Static Source</title>
5<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" >
4e95ad3e 6<link rel="stylesheet" type="text/css" href="general.css">
7</head>
8<body>
aaf9d0a3 9<a href="../index.html"><img src="../../../images/jogamp_symbols/website_final_blue_joal_346x70pel.png" alt="JOAL Symbol"></a><a href="http://www.openal.org"><img src="../openal_c.gif"></a>
995eac95 10<br>
4e95ad3e 11<br>
12OpenAL Tutorials from DevMaster.net. Reprinted with Permission.<br>
13<br>
14
15<table border="0" cellspacing="0" style="border-collapse: collapse" width="100%" cellpadding="0" id="AutoNumber1" height="12" bgcolor="#666699">
16 <tr>
17 <td width="47%" height="12" valign="middle"><p><b><font color="#FFFFFF">OpenAL
18 Tutorials</font></b></p></td>
19 <td width="53%" height="12" align="right" valign="middle"><p align="right"><a href="http://devmaster.net/"><font color="#66FF99">DevMaster.net</font></a></p></td>
20 </tr>
21 </table>
aaf9d0a3
XR
22<p align="left" class="title"><span class="title"><font size="5"><h1>Single Static
23Source</h1></font></span><font size="4">
24<h2>Lesson 1</h2></font></p>
4e95ad3e 25
26<p align="right" class="title"> <span class="author">Author: <a href="mailto:lightonthewater@hotmail.com"><font color="#888888">Jesse
27 Maurais<br>
28 </font></a></span>Adapted for Java by: <a href="mailto:athomas@dev.java.net"><font color="#888888">Athomas
aaf9d0a3
XR
29 Goldberg</font></a>
30</p>
2c621756 31<p><a href="../../../deployment/jogamp-current/joal-demos/jnlp-files/joal-lesson1.jnlp">Launch the Demo via Java Web Start</a></p>
ec096f51
XR
32<p align="justify">This is a translation of <a href="http://devmaster.net/posts/2888/openal-lesson-1-simple-static-sound">
33OpenAL Lesson 1: Simple Static Sound</a>
34tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
35
36</p>
a6abfd2d 37<p align="justify">Welcome to the exciting world of OpenAL! OpenAL is still in
38 a stage of growth, and even though there is an ever larger following to the
39 API it still hasn't reached it's full potential. One of the big reasons for
40 this is that there is still not yet hardware acceleration built in for specific
41 cards. However, Creative Labs is a major contributor to the OpenAL project and
42 also happens to be one of the largest soundcard manufacturers. So there is a
43 promise of hardware accelerated features in the near future. OpenAL's only other
44 major contributor, Loki, has gone the way of the dinosaur. So the future of
45 OpenAL on Linux platforms is uncertain. You can still obtain the Linux binaries
46 on some more obscure websites.</p>
47<p align="justify">OpenAL has also not been seen in many major commercial products,
48 which may have also hurt it's growth. As far as I know the only pc game to use
49 OpenAL has been Metal Gear 2 (although recently I've discovered that Unreal
50 2 does as well). The popular modeling program, Blender3D, was also known to
51 use OpenAL for all it's audio playback. Aside from these however the only other
52 OpenAL uses have been in the sdk examples and a few obscure tutorials on the
53 internet.</p>
54<p align="justify">But lets face it, OpenAL has a lot of potential. There are
55 many other audio libraries that claim to work with the hardware on a lower level
56 (and this may be true), but the designers of OpenAL did several things in it's
57 design which make it a superior API. First of all they emulated the OpenGL API
58 which is one of the best ever designed. The API style is flexible, so different
59 coding methods and hardware implementations will take advantage of this. People
60 who have had a lot of experience with OpenGL will be able to pick up OpenAL
61 quite fast. OpenAL also has the advantage of creating 3D surround sound which
62 a lot of other API's cannot boast. On top of all of that it also has the ability
63 to extend itself into EAX and AC3 flawlessly. To my knowledge no other audio
64 library has that capability.</p>
65<p align="justify">If you still haven't found a reason here to use OpenAL then
66 here's another. It's just cool. It's a nice looking API and will integrate well
67 into your code. You will be able to do many cool sound effects with it. But
68 before we do that we have to learn the basics.</p>
4e95ad3e 69
70<p>So let's get coding!</p>
06a3aaa5
XR
71<pre class=code><font color="#0000FF">import</font> com.jogamp.openal.*;
72<font color="#0000FF">import</font> com.jogamp.openal.util.*;
4e95ad3e 73<font color="#0000FF">import</font> java.io.*;
74<font color="#0000FF">import</font> java.nio.ByteBuffer;</pre>
75<pre class=code><font color="#0000FF">public</font> <font color="#0000FF">class</font> SingleStaticSource {
76
77 <font color="#0000FF"><span class=codeComment>static</span></font><span class=codeComment> AL al = ALFactory.getAL();
78
79 <font color="#006600">// Buffers hold sound data.</font></span>
80<font color="#0000FF"> static int</font>[] buffer = new <font color="#0000FF">int</font>[1];;
81
82<span class=codeComment><font color="#006600"> // Sources are points emitting sound.</font></span>
83<font color="#0000FF"> static int</font>[] source = <font color="#0000FF">new</font> <font color="#0000FF">int</font>[1];
84</pre>
a6abfd2d 85<p align="justify">Those familiar with OpenGL know that it uses &quot;texture
86 objects&quot; (or &quot;texture names&quot;) to handle textures used by a program.
87 OpenAL does a similar thing with audio samples. There are essentially 3 kinds
88 of objects in OpenAL. A buffer which stores all the information about how a
89 sound should be played and the sound data itself, and a source which is a point
90 in space that emits a sound. It's important to understand that a source is not
91 itself an audio sample. A source only plays back sound data from a buffer bound
92 to it. The source is also given special properties like position and velocity.
93</p>
94<p align="justify">The third object which I have not mentioned yet is the listener.
95 There is only one listener which represents where 'you' are, the user. The listener
96 properties along with the source properties determine how the audio sample will
97 be heard. For example their relative positions will determine the intensity
98 of the sound.</p>
4e95ad3e 99
100<pre class=code>
101<span class=codeComment><font color="#006600"> // Position of the source sound.</font></span>
102<font color="#0000FF"><span class=codeComment><font color="#006600"> </font></span>static float</font>[] sourcePos = { 0.0f, 0.0f, 0.0f };
103<font color="#006600">
104<span class=codeComment><font color="#006600"> </font>// Velocity of the source sound.</span></font>
105<font color="#0000FF"><span class=codeComment><font color="#006600"> </font></span>static float</font>[] sourceVel = { 0.0f, 0.0f, 0.0f };
106
107<span class=codeComment><font color="#006600"> </font><font color="#006600">// Position of the listener.</font></span>
108<span class=codeComment><font color="#006600"> </font></span><font color="#0000FF">static float</font>[] listenerPos = { 0.0f, 0.0f, 0.0f };
109
110<span class=codeComment><font color="#006600"> </font><font color="#006600">// Velocity of the listener.</font></span>
111<span class=codeComment><font color="#006600"> </font></span><font color="#0000FF">static float</font>[] listenerVel = { 0.0f, 0.0f, 0.0f };
112
113<span class=codeComment><font color="#006600"> </font><font color="#006600">// Orientation of the listener. (first 3 elements are "at", second 3 are "up")</font></span>
114<span class=codeComment><font color="#006600"> </font></span><font color="#0000FF">static float</font>[] listenerOri = { 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f };
115</pre>
116
a6abfd2d 117<p align="justify">In the above code we specify the position and velocity of the
118 source and listener objects. These arrays are vector based Cartesian coordinates.
119 You could easily build a structure or class to do the same thing. In this example
120 I used arrays for simplicity.</p>
4e95ad3e 121<p>Here we will create a function that loads all of our sound data from a file.
122</p>
06a3aaa5 123<pre class=code><span class=codeComment><font color="#006600"> </font></span><font color="#0000FF">static int</font> loadALData() {
4e95ad3e 124
125<span class=codeComment><font color="#006600"> </font><font color="#006600"> </font><font color="#006600">// variables to load into</font>
126
127<font color="#006600"> </font><font color="#006600"> </font><font color="#0000FF">int</font>[] format = <font color="#0000FF">new int</font>[1];<br><font color="#006600"> </font><font color="#006600"> </font><font color="#0000FF">int</font>[] size = <font color="#0000FF">new int</font>[1];<br><font color="#006600"> </font><font color="#006600"> </font>ByteBuffer[] data = <font color="#0000FF">new</font> ByteBuffer[1];<br><font color="#006600"> </font><font color="#006600"> </font><font color="#0000FF">int</font>[] freq = new <font color="#0000FF">int</font>[1];
128<font color="#006600"> </font><font color="#006600"> </font><font color="#0000FF">int</font>[] loop = new <font color="#0000FF">int</font>[1];<br></span>
129<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><font color="#006600">// Load wav data into a buffer.</font>
06a3aaa5 130<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alGenBuffers(1, buffer, 0);
4e95ad3e 131<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeKeyword>if</span> (al.alGetError() != AL.AL_NO_ERROR)
132<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeKeyword>return</span> AL.AL_FALSE;
133
134<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>ALut.alutLoadWAVFile(&quot;wavdata/FancyPants.wav&quot;, format, data, size, freq, loop);
135<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alBufferData(buffer[0], format[0], data[0], size[0], freq[0]);
06a3aaa5
XR
136<!-- JOAL never implemented alutUnloadWAV because JOAL implements ALut in Java and Java uses GC hence it was un-needed to implement for this binding. -->
137<!-- <span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>ALut.alutUnloadWAV(format[0],data[0],size[0],freq[0]); -->
4e95ad3e 138</pre>
a6abfd2d 139<p align="justify">The function 'alGenBuffers' will create the buffer objects
140 and store them in the variable we passed it. It's important to do an error check
141 to make sure everything went smoothly. There may be a case in which OpenAL could
142 not generate a buffer object due to a lack of memory. In this case it would
143 set the error bit.</p>
144<p align="justify">The ALut is very helpful here. It opens up the file for us
06a3aaa5
XR
145 and gives us all the information we need to create the buffer.<!-- And after we
146 have attached all this data to the buffer it will help use dispose of the data. -->
a6abfd2d 147 It all works in a clean and efficient manner.</p>
4e95ad3e 148<pre>
149
150<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><font color="#006600">// Bind buffer with a source.</font>
06a3aaa5 151<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alGenSources(1, source, 0);
4e95ad3e 152
153<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeKeyword>if</span> (al.alGetError() != AL.AL_NO_ERROR)
154 <span class=codeComment><font color="#006600"> </font></span><span class=codeKeyword>return</span> AL.AL_FALSE;
155
156 <span class=codeComment><font color="#006600"> </font></span>al.alSourcei (source[0], AL.AL_BUFFER, buffer[0] );
157<span class=codeComment><font color="#006600"> </font></span> al.alSourcef (source[0], AL.AL_PITCH, 1.0f );
158<span class=codeComment><font color="#006600"> </font></span> al.alSourcef (source[0], AL.AL_GAIN, 1.0f );
06a3aaa5
XR
159<span class=codeComment><font color="#006600"> </font></span> al.alSourcefv(source[0], AL.AL_POSITION, sourcePos, 0);
160<span class=codeComment><font color="#006600"> </font></span> al.alSourcefv(source[0], AL.AL_VELOCITY, sourceVel, 0);
4e95ad3e 161<span class=codeComment><font color="#006600"> </font></span> al.alSourcei (source[0], AL.AL_LOOPING, loop[0] );</pre>
a6abfd2d 162<p align="justify">We generate a source object in the same manner we generated
163 the buffer object. Then we define the source properties that it will use when
164 it's in playback. The most important of these properties is the buffer it should
165 use. This tells the source which audio sample to playback. In this case we only
166 have one so we bind it. We also tell the source it's position and velocity which
167 we defined earlier.</p>
168<p align="justify">One more thing on 'alGenBuffers' and 'alGenSources'. In some
169 example code I have seen these functions will return an integer value for the
170 number of buffers/sources created. I suppose this was meant as an error checking
171 feature that was left out in a later version. If you see this done in other
172 code don't use it yourself. If you want to do this check, use 'alGetError' instead
173 (like we have done above).</p>
4e95ad3e 174<pre class=code>
175
176<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><font color="#006600">// Do another error check and return.</font>
177 <span class=codeComment><font color="#006600"> </font></span><font color="#0000FF">if</font>(al.alGetError() == AL.AL_NO_ERROR)
178<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><font color="#0000FF">return</font> AL.AL_TRUE;
179
180<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeKeyword><font color="#0000FF">return</font></span> AL.AL_FALSE;
181<span class=codeComment><font color="#006600"> </font></span>}
182</pre>
183<p>To end the function we just do one more check to make sure all is well, then
184we return success.</p>
185<pre class=code><font color="#0000FF"><span class=codeComment><font color="#006600"> </font></span>static <span class=codeKeyword>void</span> </font>setListenerValues() {
06a3aaa5
XR
186<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alListenerfv(AL.AL_POSITION, listenerPos, 0);
187<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alListenerfv(AL.AL_VELOCITY, listenerVel, 0);
188<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alListenerfv(AL.AL_ORIENTATION, listenerOri, 0);
4e95ad3e 189<span class=codeComment><font color="#006600"> </font></span>}
190</pre>
191<p>We created this function to update the listener properties.</p>
192<pre class=code><font color="#0000FF"><span class=codeComment><font color="#006600"> </font></span>static <span class=codeKeyword>void</span> </font>killALData() {
06a3aaa5
XR
193<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alDeleteBuffers(1, buffer, 0);
194<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alDeleteSources(1, source, 0);
195<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>ALut.alutExit();
4e95ad3e 196<span class=codeComment><font color="#006600"> </font></span>}
197</pre>
198<p>This will be our shutdown procedure. It is necessary to call this to release
199all the memory and audio devices that our program may be using.</p>
200<pre class=code><font color="#0000FF"><span class=codeComment><font color="#006600"> </font></span>public static void main</font>(<span class=codeKeyword>String[] args</span>) {
201<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600">// Initialize OpenAL and clear the error bit.</font></span>
202<span class=codeComment>
203<font color="#006600"> </font><font color="#006600"> </font>ALut.alutInit();</span>
204<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alGetError();
205
206</pre>
a6abfd2d 207<p align="justify">The function 'alutInit' will setup everything that the Alc
06a3aaa5 208 needs to do for us. Basically ALut creates a single OpenAL context through Alc
a6abfd2d 209 and sets it to current. On the Windows platform it initializes DirectSound.
210 We also do an initial call to the error function to clear it. Every time we
211 call 'glGetError' it will reset itself to 'AL_NO_ERROR'.</p>
4e95ad3e 212<pre class=code>
213
214<span class=codeComment><font color="#006600"> </font><font color="#006600"> </font><font color="#006600">// Load the wav data.</font></span>
215<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeKeyword><font color="#0000FF">if</font></span> (loadALData() == AL.AL_FALSE)
06a3aaa5 216<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>System.exit(-1);
4e95ad3e 217
218<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>setListenerValues();
219
220<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600">// Setup an exit procedure.</font></span>
221
222<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>Runtime runtime = Runtime.getRuntime();
223<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>runtime.addShutdownHook(
224<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><font color="#0000FF">new</font> Thread(
225<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><font color="#0000FF">new</font> Runnable() {
226<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><font color="#0000FF">public void</font> run() {
06a3aaa5 227<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>killALData();
4e95ad3e 228<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>}
229<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>}
230<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>)
231<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>);
232</pre>
8bf2b32d 233<p align="justify">We will check to see if the wav files loaded correctly. If not we must exit the program. Then we update the listener values,
234and finally we set our exit procedure.</p>
4e95ad3e 235<pre class=code><font color="#0000FF"> char</font>[] c = new <font color="#0000FF">char</font>[1];
236<font color="#0000FF"> </font><font color="#0000FF"> while</font>(c[0] != 'q') {
237<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF">try</font> {
238<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font>BufferedReader buf =
239<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF">new</font> BufferedReader(<font color="#0000FF">new</font> InputStreamReader(System.in));
240<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font>System.out.println(&quot;Press a key and hit ENTER: &quot; +
241<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font>&quot;'p' to play, 's' to stop, 'h' to pause and 'q' to quit&quot;);
242<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font>buf.read(c);
243<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF">switch</font>(c[0]) {
244<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF">case</font> 'p':
245<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#006600">// Pressing 'p' will begin playing the sample.</font>
246<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font>al.alSourcePlay(source[0]);
247<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF">break</font>;
248<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF">case</font> 's':
249<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#006600">// Pressing 's' will stop the sample from playing.</font>
06a3aaa5 250<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font>al.alSourceStop(source[0]);
4e95ad3e 251<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF">break</font>;
252<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF">case</font> 'h':
253<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#006600">// Pressing 'n' will pause (hold) the sample.</font>
06a3aaa5 254<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font>al.alSourcePause(source[0]);
4e95ad3e 255<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF">break</font>;
256<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font>}
257<font color="#0000FF"> </font><font color="#0000FF"> </font>} <font color="#0000FF">catch</font> (IOException e) {
258 System.exit(1);
259<font color="#0000FF"> </font><font color="#0000FF"> </font>}
260<font color="#0000FF"> </font>}
261}
262
06a3aaa5 263} // class SingleStaticSource
4e95ad3e 264</pre>
a6abfd2d 265<p align="justify">This is the interesting part of the tutorial. It's a very basic
266 loop that lets us control the playback of the audio sample. Pressing 'p' will
267 replay the sample, pressing 's' will stop the sample, and pressing 'h' will
268 pause the sample. Pressing 'q' will exit the program.</p>
269<p align="justify">Well there it is. Your first delve into OpenAL. I hope it was
270 made simple enough for you. It may have been a little too simple for the 1337
271 h4X0r, but we all got to start somewhere. Things will get more advanced as we
272 go along.</p>
4e95ad3e 273<table border="0" cellspacing="1" style="border-collapse: collapse" width="100%" id="AutoNumber2" bgcolor="#666699">
274 <tr>
275
http://JogAmp.org git info: FAQ, tutorial and man pages.