summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXerxes Rånby <xerxes@zafena.se>2013-07-09 17:13:32 +0200
committerXerxes Rånby <xerxes@zafena.se>2013-07-09 17:13:32 +0200
commit06a3aaa5fd38097a4644921a269d6ca282fb31eb (patch)
tree8d3d4700caab723b29ef7cef11c8cab07a5a3ad3
parentec096f5131f084477931c9e3507d2d4da392d243 (diff)
www/devmaster/lesson*.html: net.java.games.joal.* -> com.jogamp.openal.*v2.1.1v2.1.0v2.0.2
The Java OpenAL JOAL HTML tutorials are now usefull. This change made is possible to copy and paste the many code sections of the JOAL tutorial into working applications. Signed-off-by: Xerxes Rånby <xerxes@zafena.se>
-rw-r--r--www/devmaster/lesson1.html44
-rw-r--r--www/devmaster/lesson2.html34
-rw-r--r--www/devmaster/lesson3.html42
-rw-r--r--www/devmaster/lesson4.html24
-rw-r--r--www/devmaster/lesson5.html115
-rw-r--r--www/devmaster/lesson6.html24
6 files changed, 166 insertions, 117 deletions
diff --git a/www/devmaster/lesson1.html b/www/devmaster/lesson1.html
index 7960c7d..12c7c7f 100644
--- a/www/devmaster/lesson1.html
+++ b/www/devmaster/lesson1.html
@@ -68,8 +68,8 @@ tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
before we do that we have to learn the basics.</p>
<p>So let's get coding!</p>
-<pre class=code><font color="#0000FF">import</font> net.java.games.joal.*;
-<font color="#0000FF">import</font> net.java.games.joal.util.*;
+<pre class=code><font color="#0000FF">import</font> com.jogamp.openal.*;
+<font color="#0000FF">import</font> com.jogamp.openal.util.*;
<font color="#0000FF">import</font> java.io.*;
<font color="#0000FF">import</font> java.nio.ByteBuffer;</pre>
<pre class=code><font color="#0000FF">public</font> <font color="#0000FF">class</font> SingleStaticSource {
@@ -120,20 +120,21 @@ tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
I used arrays for simplicity.</p>
<p>Here we will create a function that loads all of our sound data from a file.
</p>
-<pre class=code><span class=codeComment><font color="#006600"> </font></span><font color="#0000FF">static int</font> LoadALData() {
+<pre class=code><span class=codeComment><font color="#006600"> </font></span><font color="#0000FF">static int</font> loadALData() {
<span class=codeComment><font color="#006600"> </font><font color="#006600"> </font><font color="#006600">// variables to load into</font>
<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];
<font color="#006600"> </font><font color="#006600"> </font><font color="#0000FF">int</font>[] loop = new <font color="#0000FF">int</font>[1];<br></span>
<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>
-<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alGenBuffers(1, buffer);
+<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alGenBuffers(1, buffer, 0);
<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)
<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;
<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);
<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]);
-<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]);
+<!-- JOAL never implemented alutUnloadWAV because JOAL implements ALut in Java and Java uses GC hence it was un-needed to implement for this binding. -->
+<!-- <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]); -->
</pre>
<p align="justify">The function 'alGenBuffers' will create the buffer objects
and store them in the variable we passed it. It's important to do an error check
@@ -141,13 +142,13 @@ tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
not generate a buffer object due to a lack of memory. In this case it would
set the error bit.</p>
<p align="justify">The ALut is very helpful here. It opens up the file for us
- and gives us all the information we need to create the buffer. And after we
- have attached all this data to the buffer it will help use dispose of the data.
+ and gives us all the information we need to create the buffer.<!-- And after we
+ have attached all this data to the buffer it will help use dispose of the data. -->
It all works in a clean and efficient manner.</p>
<pre>
<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>
-<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alGenSources(1, source);
+<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alGenSources(1, source, 0);
<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)
<span class=codeComment><font color="#006600"> </font></span><span class=codeKeyword>return</span> AL.AL_FALSE;
@@ -155,8 +156,8 @@ tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
<span class=codeComment><font color="#006600"> </font></span>al.alSourcei (source[0], AL.AL_BUFFER, buffer[0] );
<span class=codeComment><font color="#006600"> </font></span> al.alSourcef (source[0], AL.AL_PITCH, 1.0f );
<span class=codeComment><font color="#006600"> </font></span> al.alSourcef (source[0], AL.AL_GAIN, 1.0f );
-<span class=codeComment><font color="#006600"> </font></span> al.alSourcefv(source[0], AL.AL_POSITION, sourcePos);
-<span class=codeComment><font color="#006600"> </font></span> al.alSourcefv(source[0], AL.AL_VELOCITY, sourceVel);
+<span class=codeComment><font color="#006600"> </font></span> al.alSourcefv(source[0], AL.AL_POSITION, sourcePos, 0);
+<span class=codeComment><font color="#006600"> </font></span> al.alSourcefv(source[0], AL.AL_VELOCITY, sourceVel, 0);
<span class=codeComment><font color="#006600"> </font></span> al.alSourcei (source[0], AL.AL_LOOPING, loop[0] );</pre>
<p align="justify">We generate a source object in the same manner we generated
the buffer object. Then we define the source properties that it will use when
@@ -182,16 +183,16 @@ tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
<p>To end the function we just do one more check to make sure all is well, then
we return success.</p>
<pre class=code><font color="#0000FF"><span class=codeComment><font color="#006600"> </font></span>static <span class=codeKeyword>void</span> </font>setListenerValues() {
-<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alListenerfv(AL.AL_POSITION, listenerPos);
-<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alListenerfv(AL.AL_VELOCITY, listenerVel);
-<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alListenerfv(AL.AL_ORIENTATION, listenerOri);
+<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alListenerfv(AL.AL_POSITION, listenerPos, 0);
+<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alListenerfv(AL.AL_VELOCITY, listenerVel, 0);
+<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alListenerfv(AL.AL_ORIENTATION, listenerOri, 0);
<span class=codeComment><font color="#006600"> </font></span>}
</pre>
<p>We created this function to update the listener properties.</p>
<pre class=code><font color="#0000FF"><span class=codeComment><font color="#006600"> </font></span>static <span class=codeKeyword>void</span> </font>killALData() {
-<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alDeleteBuffers(1, buffer);
-<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alDeleteSources(1, source);
-<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>Alut.alutExit();
+<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alDeleteBuffers(1, buffer, 0);
+<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>al.alDeleteSources(1, source, 0);
+<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>ALut.alutExit();
<span class=codeComment><font color="#006600"> </font></span>}
</pre>
<p>This will be our shutdown procedure. It is necessary to call this to release
@@ -204,7 +205,7 @@ all the memory and audio devices that our program may be using.</p>
</pre>
<p align="justify">The function 'alutInit' will setup everything that the Alc
- needs to do for us. Basically Alut creates a single OpenAL context through Alc
+ needs to do for us. Basically ALut creates a single OpenAL context through Alc
and sets it to current. On the Windows platform it initializes DirectSound.
We also do an initial call to the error function to clear it. Every time we
call 'glGetError' it will reset itself to 'AL_NO_ERROR'.</p>
@@ -212,7 +213,7 @@ all the memory and audio devices that our program may be using.</p>
<span class=codeComment><font color="#006600"> </font><font color="#006600"> </font><font color="#006600">// Load the wav data.</font></span>
<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)
-<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><font color="#0000FF">return</font></span> -1;
+<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);
<span class=codeComment><font color="#006600"> </font></span><span class=codeComment><font color="#006600"> </font></span>setListenerValues();
@@ -223,7 +224,7 @@ all the memory and audio devices that our program may be using.</p>
<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(
<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() {
<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() {
-<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>killAllData();
+<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();
<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><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>)
@@ -246,11 +247,11 @@ and finally we set our exit procedure.</p>
<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>;
<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF">case</font> 's':
<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>
-<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font>alSourceStop(source[0]);
+<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font>al.alSourceStop(source[0]);
<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>;
<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF">case</font> 'h':
<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>
-<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font>alSourcePause(source[0]);
+<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF"> </font>al.alSourcePause(source[0]);
<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>;
<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">catch</font> (IOException e) {
@@ -259,6 +260,7 @@ and finally we set our exit procedure.</p>
<font color="#0000FF"> </font>}
}
+} // class SingleStaticSource
</pre>
<p align="justify">This is the interesting part of the tutorial. It's a very basic
loop that lets us control the playback of the audio sample. Pressing 'p' will
diff --git a/www/devmaster/lesson2.html b/www/devmaster/lesson2.html
index 91bbb3e..f1b0b2c 100644
--- a/www/devmaster/lesson2.html
+++ b/www/devmaster/lesson2.html
@@ -39,10 +39,10 @@ tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
real quick and easy tutorial. It won't get too much more complicated at this point.</p>
<pre >
<font color="#0000FF">import </font>java.nio.ByteBuffer;
- <font color="#0000FF">import </font>net.java.games.joal.AL;
- <font color="#0000FF">import</font> net.java.games.joal.ALC;
- <font color="#0000FF">import</font> net.java.games.joal.ALFactory;
- <font color="#0000FF">import</font> net.java.games.joal.util.ALut;
+ <font color="#0000FF">import</font> com.jogamp.openal.AL;
+ <font color="#0000FF">import</font> com.jogamp.openal.ALC;
+ <font color="#0000FF">import</font> com.jogamp.openal.ALFactory;
+ <font color="#0000FF">import</font> com.jogamp.openal.util.ALut;
<font color="#0000FF">public</font> <font color="#0000FF">class</font> LoopingAndFadeaway {
@@ -72,7 +72,7 @@ real quick and easy tutorial. It won't get too much more complicated at this poi
<font color="#006600"> // Load wav data into a buffer.</font>
- al.alGenBuffers(1, buffer);
+ al.alGenBuffers(1, buffer, 0);
<font color="#0000FF">if </font>(al.alGetError() != AL.AL_NO_ERROR)
<font color="#0000FF">return</font> AL.AL_FALSE;
ALut.alutLoadWAVFile(
@@ -83,14 +83,14 @@ real quick and easy tutorial. It won't get too much more complicated at this poi
freq,
loop);
al.alBufferData(buffer[0], format[0], data[0], size[0], freq[0]);
- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]);
+<!-- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]); -->
- al.alGenSources(1, source);
+ al.alGenSources(1, source, 0);
al.alSourcei(source[0], AL.AL_BUFFER, buffer[0]);
al.alSourcef(source[0], AL.AL_PITCH, 1.0f);
al.alSourcef(source[0], AL.AL_GAIN, 1.0f);
- al.alSourcefv(source[0], AL.AL_POSITION, sourcePos);
- al.alSourcefv(source[0], AL.AL_POSITION, sourceVel);
+ al.alSourcefv(source[0], AL.AL_POSITION, sourcePos, 0);
+ al.alSourcefv(source[0], AL.AL_POSITION, sourceVel, 0);
al.alSourcei(source[0], AL.AL_LOOPING, AL.AL_TRUE);
<font color="#0000FF"> if </font>(al.alGetError() != AL.AL_NO_ERROR) {
<font color="#0000FF">return</font> AL.AL_FALSE;
@@ -104,15 +104,15 @@ real quick and easy tutorial. It won't get too much more complicated at this poi
clip has ended.</p>
<pre class=code>
<font color="#0000FF">static <span class=codeKeyword>void</span> </font>setListenerValues() {
- al.alListenerfv(AL.AL_POSITION, listenerPos);
- al.alListenerfv(AL.AL_VELOCITY, listenerVel);
- al.alListenerfv(AL.AL_ORIENTATION, listenerOri);
+ al.alListenerfv(AL.AL_POSITION, listenerPos, 0);
+ al.alListenerfv(AL.AL_VELOCITY, listenerVel, 0);
+ al.alListenerfv(AL.AL_ORIENTATION, listenerOri, 0);
}
<font color="#0000FF">static <span class=codeKeyword>void</span> </font>killALData() {
- al.alDeleteBuffers(1, buffer);
- al.alDeleteSources(1, source);
- Alut.alutExit();
+ al.alDeleteBuffers(1, buffer, 0);
+ al.alDeleteSources(1, source, 0);
+ ALut.alutExit();
}
</pre>
<p>Nothing has changed here.</p>
@@ -130,7 +130,7 @@ real quick and easy tutorial. It won't get too much more complicated at this poi
<font color="#0000FF">long</font> elapsed = 0;
<font color="#0000FF">long</font> ticker = 0;
<font color="#0000FF">long</font> lastTime = 0;
- <font color="#0000FF">while</font> (elapsed < 5000) {
+ <font color="#0000FF">while</font> (elapsed < 10000) {
elapsed = System.currentTimeMillis() - startTime;
<font color="#0000FF">if</font> (ticker > 100) {
ticker = 0;
@@ -140,7 +140,7 @@ real quick and easy tutorial. It won't get too much more complicated at this poi
al.alSourcefv(
source[0],
AL.AL_POSITION,
- sourcePos);
+ sourcePos, 0);
}
ticker += System.currentTimeMillis() - lastTime;
lastTime = System.currentTimeMillis();
diff --git a/www/devmaster/lesson3.html b/www/devmaster/lesson3.html
index a308680..4d20ca4 100644
--- a/www/devmaster/lesson3.html
+++ b/www/devmaster/lesson3.html
@@ -43,9 +43,9 @@ tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
<font color="#0000FF">import</font> java.nio.ByteBuffer;
<font color="#0000FF">import</font> java.util.Random;
-<font color="#0000FF">import</font> net.java.games.joal.AL;
-<font color="#0000FF">import</font> net.java.games.joal.ALFactory;
-<font color="#0000FF">import</font> net.java.games.joal.util.ALut;
+<font color="#0000FF">import</font> com.jogamp.openal.AL;
+<font color="#0000FF">import</font> com.jogamp.openal.ALFactory;
+<font color="#0000FF">import</font> com.jogamp.openal.util.ALut;
<font color="#0000FF">public</font> <font color="#0000FF">class</font> MultipleSources {
@@ -102,7 +102,7 @@ tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
<font color="#006600">
// load wav data into buffers</font>
- al.alGenBuffers(NUM_BUFFERS, buffers);
+ al.alGenBuffers(NUM_BUFFERS, buffers, 0);
<font color="#0000FF">if </font>(al.alGetError() != AL.AL_NO_ERROR) {
<font color="#0000FF">return</font> AL.AL_FALSE;
}
@@ -120,7 +120,7 @@ tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
data[0],
size[0],
freq[0]);
- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]);
+<!-- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]); -->
ALut.alutLoadWAVFile(
"wavdata/Gun1.wav",
@@ -135,7 +135,7 @@ tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
data[0],
size[0],
freq[0]);
- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]);
+<!-- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]); -->
ALut.alutLoadWAVFile(
"wavdata/Gun2.wav",
@@ -150,30 +150,30 @@ tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
data[0],
size[0],
freq[0]);
- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]);
+<!-- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]); -->
<font color="#006600"> // bind buffers into audio sources</font>
- al.alGenSources(NUM_SOURCES, sources);
+ al.alGenSources(NUM_SOURCES, sources, 0);
al.alSourcei(sources[BATTLE], AL.AL_BUFFER, buffers[BATTLE]);
al.alSourcef(sources[BATTLE], AL.AL_PITCH, 1.0f);
al.alSourcef(sources[BATTLE], AL.AL_GAIN, 1.0f);
- al.alSourcefv(sources[BATTLE], AL.AL_POSITION, sourcePos[BATTLE]);
- al.alSourcefv(sources[BATTLE], AL.AL_POSITION, sourceVel[BATTLE]);
+ al.alSourcefv(sources[BATTLE], AL.AL_POSITION, sourcePos[BATTLE], 0);
+ al.alSourcefv(sources[BATTLE], AL.AL_POSITION, sourceVel[BATTLE], 0);
al.alSourcei(sources[BATTLE], AL.AL_LOOPING, AL.AL_TRUE);
al.alSourcei(sources[GUN1], AL.AL_BUFFER, buffers[GUN1]);
al.alSourcef(sources[GUN1], AL.AL_PITCH, 1.0f);
al.alSourcef(sources[GUN1], AL.AL_GAIN, 1.0f);
- al.alSourcefv(sources[GUN1], AL.AL_POSITION, sourcePos[GUN1]);
- al.alSourcefv(sources[GUN1], AL.AL_POSITION, sourceVel[GUN1]);
+ al.alSourcefv(sources[GUN1], AL.AL_POSITION, sourcePos[GUN1], 0);
+ al.alSourcefv(sources[GUN1], AL.AL_POSITION, sourceVel[GUN1], 0);
al.alSourcei(sources[GUN1], AL.AL_LOOPING, AL.AL_FALSE);
al.alSourcei(sources[GUN2], AL.AL_BUFFER, buffers[GUN2]);
al.alSourcef(sources[GUN2], AL.AL_PITCH, 1.0f);
al.alSourcef(sources[GUN2], AL.AL_GAIN, 1.0f);
- al.alSourcefv(sources[GUN2], AL.AL_POSITION, sourcePos[GUN2]);
- al.alSourcefv(sources[GUN2], AL.AL_POSITION, sourceVel[GUN2]);
+ al.alSourcefv(sources[GUN2], AL.AL_POSITION, sourcePos[GUN2], 0);
+ al.alSourcefv(sources[GUN2], AL.AL_POSITION, sourceVel[GUN2], 0);
al.alSourcei(sources[GUN2], AL.AL_LOOPING, AL.AL_FALSE);
<font color="#006600"> // do another error check and return</font>
@@ -192,14 +192,14 @@ tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
<pre>
<font color="#0000FF">static</font> <font color="#0000FF">void</font> setListenerValues() {
- al.alListenerfv(AL.AL_POSITION, listenerPos);
- al.alListenerfv(AL.AL_VELOCITY, listenerVel);
- al.alListenerfv(AL.AL_ORIENTATION, listenerOri);
+ al.alListenerfv(AL.AL_POSITION, listenerPos, 0);
+ al.alListenerfv(AL.AL_VELOCITY, listenerVel, 0);
+ al.alListenerfv(AL.AL_ORIENTATION, listenerOri, 0);
}
<font color="#0000FF">static</font> <font color="#0000FF">void</font> killAllData() {
- al.alDeleteBuffers(NUM_BUFFERS, buffers);
- al.alDeleteSources(NUM_SOURCES, sources);
+ al.alDeleteBuffers(NUM_BUFFERS, buffers, 0);
+ al.alDeleteSources(NUM_SOURCES, sources, 0);
ALut.alutExit();
}
</pre>
@@ -238,7 +238,7 @@ tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
// Skip the first source because it is looping anyway (will always be playing).</font>
<font color="#0000FF">int</font> pick = Math.abs((rand.nextInt()) % 2) + 1;
- al.alGetSourcei(sources[pick], AL.AL_SOURCE_STATE, state);
+ al.alGetSourcei(sources[pick], AL.AL_SOURCE_STATE, state, 0);
<font color="#0000FF">if</font> (state[0] != AL.AL_PLAYING) {
@@ -252,7 +252,7 @@ tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
al.alSourcefv(
sources[pick],
AL.AL_POSITION,
- sourcePos[pick]);
+ sourcePos[pick], 0);
al.alSourcePlay(sources[pick]);
}
diff --git a/www/devmaster/lesson4.html b/www/devmaster/lesson4.html
index 5830f15..64b44f3 100644
--- a/www/devmaster/lesson4.html
+++ b/www/devmaster/lesson4.html
@@ -28,20 +28,20 @@ OpenAL Lesson 4: The ALC</a>
tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
</p>
-<p align="justify">Up until now we have been letting Alut do all the real tricky
+<p align="justify">Up until now we have been letting ALut do all the real tricky
stuff for us. For example handling the audio devices. It's really nice that
- the Alut library is there to provide this functionality, but any smart coder
+ the ALut library is there to provide this functionality, but any smart coder
will want to know exactly what their doing. We may want to, at some point, use
the Alc directly. In this tutorial we will expose the Alc layer and take a look
at how to handle the devices on our own.</p>
<pre class=code>
-ALFactory.initialize();
ALC alc = ALFactory.getALC();
String deviceName = "DirectSound3D";
+// deviceName = <font color="#0000FF">null</font>; // Passing a null String to alcOpenDevice will open the default device on your system!
-ALC.Device device = alc.alcOpenDevice(deviceName);
+ALCdevice device = alc.alcOpenDevice(deviceName);
</pre>
<p align="justify">So what is an Alc device? Try to think of it in terms of a
resource. OpenAL grabs a handle to the hardware being used, which must in turn
@@ -53,7 +53,7 @@ ALC.Device device = alc.alcOpenDevice(deviceName);
to 'alcOpenDevice' is a perfectly valid argument. It forces the Alc to use a
default device.</p>
<pre>
-ALC.Context context = alc.alcCreateContext(device, <font color="#0000FF">null</font>);
+ALCcontext context = alc.alcCreateContext(device, <font color="#0000FF">null</font>);
alc.alcMakeContextCurrent(context);
</pre>
<p align="justify">What is an Alc context? OpenGL coders will recall that there
@@ -85,10 +85,10 @@ alc.alcMakeContextCurrent(context);
appropriate context is current. And if you do decide to do this, then there
may be times when you want to know exactly which context is current without
going through a big check.</p>
-<pre class=code>ALC.Context curContext = alc.alcGetCurrentContext();
+<pre class=code>ALCcontext curContext = alc.alcGetCurrentContext();
</pre>
<p>Once you have your context you can also obtain the device in use by that context.</p>
-<pre class=code>ALC.Device curDevice = alc.alcGetContextsDevice(curContext);
+<pre class=code>ALCdevice curDevice = alc.alcGetContextsDevice(curContext);
</pre>
<p align="justify">Above we used the context we retrieved to find out which device
it was using. There is also one other cool feature that was built into Alc for
@@ -116,13 +116,13 @@ alc.alcCloseDevice(device);
There is but a few more Alc functions we have not yet covered.</p>
<pre class=code><font color="#0000FF">public int</font> alcGetError();
-<font color="#0000FF">public</font> <font color="#0000FF">boolean</font> alcIsExtensionPresent(ALC.Device device, String extName);
+<font color="#0000FF">public</font> <font color="#0000FF">boolean</font> alcIsExtensionPresent(ALCdevice device, String extName);
-<font color="#0000FF">public</font> <font color="#0000FF">int</font> alcGetEnumValue(ALC.Device device, String enumName);
+<font color="#0000FF">public</font> <font color="#0000FF">int</font> alcGetEnumValue(ALCdevice device, String enumName);
-<font color="#0000FF">public </font>String alcGetString(ALC.Device device, <font color="#0000FF">int</font> token);
+<font color="#0000FF">public </font>String alcGetString(ALCdevice device, <font color="#0000FF">int</font> token);
-<font color="#0000FF">public</font> <font color="#0000FF">void</font> alcGetIntegerv(ALC.Device device, <font color="#0000FF">int</font> token, <font color="#0000FF">int</font> size, <font color="#0000FF">int</font>[] dest);
+<font color="#0000FF">public</font> <font color="#0000FF">void</font> alcGetIntegerv(ALCdevice device, <font color="#0000FF">int</font> token, <font color="#0000FF">int</font> size, <font color="#0000FF">int</font>[] dest);
</pre>
<p align="justify">It may be pretty obvious to you what these do, but lets humour
ourselves and have a closer look. First we have 'alcGetError' which is just
@@ -145,7 +145,7 @@ alc.alcCloseDevice(device);
exist yet.</p>
<p align="justify">Well that's most of Alc for you. I hope it gave you a better
understanding of how OpenAL interacts with the operation system. You might try
- writing your own initialization routines so you can cast off Alut altogether.
+ writing your own initialization routines so you can cast off ALut altogether.
Either way have fun with it.</p>
<table border="0" cellspacing="1" style="border-collapse: collapse" width="100%" id="AutoNumber2" bgcolor="#666699">
<tr>
diff --git a/www/devmaster/lesson5.html b/www/devmaster/lesson5.html
index dbd582c..c1a9d7a 100644
--- a/www/devmaster/lesson5.html
+++ b/www/devmaster/lesson5.html
@@ -38,10 +38,20 @@ tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
may find this interesting. Plus, we will be implementing the Alc layer directly
so that we can use some of that knowledge gained in lesson 4. On top of that
we will create a program you might even use!</p>
-<p align="justify">Well, here we go. I've decided to only go over bits of the
+<p align="justify">Well, here we go. <!-- I've decided to only go over bits of the
code that are significant, since most of the code has been repeated so far in
- the series. Check out the full source code in the download.</p>
-<pre class=code><span class=codeComment><font color="#0000FF">static</font> ALC alc;
+ the series. Check out the full source code in the download.--></p>
+<pre class=code>
+<font color="#0000FF">import</font> java.io.*;
+<font color="#0000FF">import</font> java.nio.*;
+<font color="#0000FF">import</font> java.util.*;
+
+<font color="#0000FF">import</font> com.jogamp.openal.*;
+<font color="#0000FF">import</font> com.jogamp.openal.util.*;
+
+<font color="#0000FF">public</font> <font color="#0000FF">class</font> SourceSharingBuffers {
+
+<span class=codeComment><font color="#0000FF">static</font> ALC alc;
<font color="#0000FF">static</font> AL al;<font color="#006600">
// These index the buffers.</font></span>
@@ -57,9 +67,24 @@ tutorial from <a href="http://devmaster.net/">DevMaster.net</a> to JOAL.
<font color="#006600"><span class=codeComment>// Buffers hold sound data.</span>
</font><font color="#0000FF">static int</font>[] buffers = <font color="#0000FF">new int</font>[NUM_BUFFERS];
-<span class=codeComment><font color="#006600">// A vector list of sources for multiple emissions.</font></span>
-Vector sources = <font color="#0000FF">new </font>Vector();
+<span class=codeComment><font color="#006600">// A list of sources for multiple emissions.</font></span>
+static List sources = <font color="#0000FF">new </font>ArrayList();
+
+// Position of the source sounds.
+static float[] sourcePos = { 0.0f, 0.0f, 0.0f };
+
+// Velocity of the source sounds.
+static float[] sourceVel = { 0.0f, 0.0f, 0.0f };
+
+// Position of the listener.
+static float[] listenerPos = { 0.0f, 0.0f, 0.0f };
+
+// Velocity of the listener.
+static float[] listenerVel = { 0.0f, 0.0f, 0.0f };
+
+// Orientation of the listener. (first 3 elements are "at", second 3 are "up")
+static float[] listenerOri = { 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f };
</pre>
<p align="justify">First I've written out a few macros that we can use to index
the buffer array. We will be using several wav files so we need quite a few
@@ -69,11 +94,13 @@ Vector sources = <font color="#0000FF">new </font>Vector();
of them. This is also the first tutorial where we will deal with sources as
being a resource that will run out. And yes, they will run out; they are finite.</p>
<pre class=code><font color="#0000FF">static int </font>initOpenAL() {
-
- ALC.Device device;
- ALC.Context context;
+ al = ALFactory.getAL();
+ alc = ALFactory.getALC();
+ ALCdevice device;
+ ALCcontext context;
String deviceSpecifier;
- String deviceName = "DirectSound3D";
+ String deviceName = &quot;DirectSound3D&quot;; // You may choose to open a specific OpenAL device if you know its name.
+ deviceName = <font color="#0000FF">null</font>; // Passing a null String to alcOpenDevice will open the default device on your system!
<span class=codeComment><font color="#006600">// Get handle to device.</font></span>
device = alc.alcOpenDevice(deviceName);
@@ -81,7 +108,7 @@ Vector sources = <font color="#0000FF">new </font>Vector();
<font color="#006600"><span class=codeComment>// Get the device specifier.</span></font>
deviceSpecifier = alc.alcGetString(device, ALC.ALC_DEVICE_SPECIFIER);
- System.out.println("Using device &quot; + deviceSpecifier);
+ System.out.println(&quot;Using device &quot; + deviceSpecifier);
<span class=codeComment><font color="#006600">// Create audio context.</font></span>
context = alc.alcCreateContext(device, <font color="#0000FF">null</font>);
@@ -90,7 +117,7 @@ Vector sources = <font color="#0000FF">new </font>Vector();
alc.alcMakeContextCurrent(context);
<span class=codeComment><font color="#006600">// Check for an error.</font></span>
- <span class=codeKeyword><font color="#0000FF">if </font></span>(alc.alcGetError() != ALC.ALC_NO_ERROR)
+ <span class=codeKeyword><font color="#0000FF">if </font></span>(alc.alcGetError(device) != ALC.ALC_NO_ERROR)
<span class=codeKeyword><font color="#0000FF">return</font></span> AL.AL_FALSE;
<span class=codeKeyword><font color="#0000FF">return</font></span> AL.AL_TRUE;
@@ -101,8 +128,8 @@ Vector sources = <font color="#0000FF">new </font>Vector();
context for our application. This context is set to current and the function
will check if everything went smoothly before we return success.</p>
<pre class=code><span class=codeKeyword><font color="#0000FF">static void</font></span> exitOpenAL() {
- ALC.Context curContext;
- ALC.Device curDevice;
+ ALCcontext curContext;
+ ALCdevice curDevice;
<font color="#006600"><span class=codeComment>// Get the current context.</span></font>
curContext = alc.alcGetCurrentContext();
@@ -137,34 +164,34 @@ Vector sources = <font color="#0000FF">new </font>Vector();
<font color="#0000FF">int</font>[] loop = new <font color="#0000FF">int</font>[1];
<span class=codeComment><font color="#006600">// Load wav data into buffers.</font></span>
- al.alGenBuffers(NUM_BUFFERS, buffers);
+ al.alGenBuffers(NUM_BUFFERS, buffers, 0);
<span class=codeKeyword><font color="#0000FF">if</font></span>(al.alGetError() != AL.AL_NO_ERROR)
<span class=codeKeyword><font color="#0000FF">return</font></span> AL.AL_FALSE;
ALut.alutLoadWAVFile("wavdata/thunder.wav", format, data, size, freq, loop);
al.alBufferData(buffers[THUNDER], format[0], data[0], size[0], freq[0]);
- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]);
+<!-- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]); -->
ALut.alutLoadWAVFile("wavdata/waterdrop.wav", format, data, size, freq, loop);
al.alBufferData(buffers[WATERDROP], format[0], data[0], size[0], freq[0]);
- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]);
+<!-- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]); -->
ALut.alutLoadWAVFile("wavdata/stream.wav", format, data, size, freq, loop);
al.alBufferData(buffers[STREAM], format[0], data[0], size[0], freq[0]);
- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]);
+<!-- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]); -->
ALut.alutLoadWAVFile("wavdata/rain.wav", format, data, size, freq, loop);
al.alBufferData(buffers[RAIN], format[0], data[0], size[0], freq[0]);
- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]);
+<!-- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]); -->
ALut.alutLoadWAVFile("wavdata/ocean.wav", format, data, size, freq, loop);
al.alBufferData(buffers[OCEAN], format[0], data[0], size[0], freq[0]);
- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]);
+<!-- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]); -->
ALut.alutLoadWAVFile("wavdata/chimes.wav", format, data, size, freq, loop);
al.alBufferData(buffers[CHIMES], format[0], data[0], size[0], freq[0]);
- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]);
+<!-- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]); -->
<font color="#006600"> <span class=codeComment>// Do another error check and return.</span>
</font><span class=codeKeyword><font color="#0000FF">if</font> </span>(al.alGetError() != AL.AL_NO_ERROR)
@@ -178,7 +205,7 @@ Vector sources = <font color="#0000FF">new </font>Vector();
<pre class=code><span class=codeKeyword><font color="#0000FF">static void</font></span><font color="#0000FF"> </font>addSource(int type) {
<font color="#0000FF">int[]</font> source = <font color="#0000FF">new int</font>[1];
- al.alGenSources(1, source);
+ al.alGenSources(1, source, 0);
<span class=codeKeyword><font color="#0000FF">if</font> </span>(al.alGetError() != AL.AL_NO_ERROR) {
System.err.println("Error generating audio source.");
@@ -186,17 +213,22 @@ Vector sources = <font color="#0000FF">new </font>Vector();
}
al.alSourcei (source[0], AL.AL_BUFFER, buffers[type]);
- al.alSourcef (source[0], AL.AL_PITCH, 1.0 );
- al.alSourcef (source[0], AL.AL_GAIN, 1.0 );
- al.alSourcefv(source[0], AL.AL_POSITION, sourcePos );
- al.alSourcefv(source[0], AL.AL_VELOCITY, sourceVel );
+ al.alSourcef (source[0], AL.AL_PITCH, 1.0f );
+ al.alSourcef (source[0], AL.AL_GAIN, 1.0f );
+ al.alSourcefv(source[0], AL.AL_POSITION, sourcePos , 0);
+ al.alSourcefv(source[0], AL.AL_VELOCITY, sourceVel , 0);
al.alSourcei (source[0], AL.AL_LOOPING, AL.AL_TRUE );
- al.alSourcePlay(source);
+ al.alSourcePlay(source[0]);
- sources.put(new Integer(source[0]));
+ sources.add(new Integer(source[0]));
}
+static void setListenerValues() {
+ al.alListenerfv(AL.AL_POSITION, listenerPos, 0);
+ al.alListenerfv(AL.AL_VELOCITY, listenerVel, 0);
+ al.alListenerfv(AL.AL_ORIENTATION, listenerOri, 0);
+}
</pre>
<p align="justify">Here's the function that will generate the sources for us.
This function will generate a single source for any one of the loaded buffers
@@ -208,17 +240,29 @@ Vector sources = <font color="#0000FF">new </font>Vector();
Iterator iter = sources.iterator();
<span class=codeKeyword><font color="#000000">while</font></span>(iter.hasNext()) {
- al.alDeleteSources(1, <font color="#0000FF">new int</font>[] { ((Integer)iter.next()).intValue() });
+ al.alDeleteSources(1, <font color="#0000FF">new int</font>[] { ((Integer)iter.next()).intValue() }, 0);
}
sources.clear();
- al.alDeleteBuffers(NUM_BUFFERS, buffers);
+ al.alDeleteBuffers(NUM_BUFFERS, buffers, 0);
exitOpenAL();
}
</pre>
-<p align="justify">This function has been modified a bit to accommodate the Vector.
+<p align="justify">This function has been modified a bit to accommodate the List.
We have to delete each source in the list individually and then clear the list
which will effectively destroy it.</p>
-<pre class=code><font color="#0000FF"> char</font>[] c = <font color="#0000FF">new char</font>[1];
+<pre class=code>
+ public static void main(String[] args) {
+ try {
+ initOpenAL();
+ } catch (ALException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ if (loadALData() == AL.AL_FALSE)
+ System.exit(1);
+ setListenerValues();
+
+<font color="#0000FF"> char</font>[] c = <font color="#0000FF">new char</font>[1];
<font color="#0000FF"> </font><font color="#0000FF">while</font>(c[0] != 'q') {
<font color="#0000FF"> </font><font color="#0000FF"> </font><font color="#0000FF">try</font> {
@@ -240,12 +284,15 @@ Vector sources = <font color="#0000FF">new </font>Vector();
<font color="#0000FF"></font><font color="#0000FF"> case</font> 'r': addSource(RAIN); <font color="#0000FF">break</font>;
<font color="#0000FF"></font><font color="#0000FF"> case</font> 'o': addSource(OCEAN); <font color="#0000FF">break</font>;
<font color="#0000FF"></font><font color="#0000FF"> case</font> 'c': addSource(CHIMES); <font color="#0000FF">break</font>;
-<font color="#0000FF"></font>}
+<font color="#0000FF"></font> }
<font color="#0000FF"> </font><font color="#0000FF"> </font>} <font color="#0000FF">catch</font> (IOException e) {
System.exit(1);
<font color="#0000FF"> </font><font color="#0000FF"> </font>}
-<font color="#0000FF"> </font>}</pre>
-<p align="justify">Here is the programs inner loop taken straight out of our main.
+<font color="#0000FF"> </font>}
+ killALData();
+ } // main
+} // class</pre>
+<p align="justify"> Here is the programs inner loop<!-- taken straight out of our main-->.
Basically it waits for some keyboard input and on certain key hits it will create
a new source of a certain type and add it to the audio scene. Essentially what
we have created here is something like one of those nature tapes that people
diff --git a/www/devmaster/lesson6.html b/www/devmaster/lesson6.html
index ed4ee9b..4590cd7 100644
--- a/www/devmaster/lesson6.html
+++ b/www/devmaster/lesson6.html
@@ -122,12 +122,12 @@ public static int </font>loadALBuffer(String path) <font color="#0000FF">throws<
our code will be up to date with later versions.</p>
<pre class=code><font color="#0000FF">public</font> String getALCErrorString(<font color="#0000FF">int</font> err) {
<span class=codeKeyword><font color="#0000FF">switch</font></span>(err) {
- <span class=codeKeyword><font color="#0000FF">case</font></span> ALC_NO_ERROR: <span class=codeKeyword><font color="#0000FF">return</font></span> "ALC_NO_ERROR";
-<span class=codeKeyword> <font color="#0000FF">case</font></span> ALC_INVALID_DEVICE: <span class=codeKeyword><font color="#0000FF">return</font></span> "ALC_INVALID_DEVICE";
-<span class=codeKeyword> <font color="#0000FF">case</font></span> ALC_INVALID_CONTEXT: <span class=codeKeyword><font color="#0000FF">return</font></span> "ALC_INVALID_CONTEXT";
-<span class=codeKeyword> <font color="#0000FF">case</font></span> ALC_INVALID_ENUM: <span class=codeKeyword><font color="#0000FF">return</font></span> "ALC_INVALID_ENUM";
-<span class=codeKeyword> <font color="#0000FF">case</font></span> ALC_INVALID_VALUE: <span class=codeKeyword><font color="#0000FF">return</font></span> "ALC_INVALID_VALUE";
-<span class=codeKeyword> <font color="#0000FF">case</font></span> ALC_OUT_OF_MEMORY: <span class=codeKeyword><font color="#0000FF">return</font></span> "ALC_OUT_OF_MEMORY";
+ <span class=codeKeyword><font color="#0000FF">case</font></span> ALC.ALC_NO_ERROR: <span class=codeKeyword><font color="#0000FF">return</font></span> "ALC_NO_ERROR";
+<span class=codeKeyword> <font color="#0000FF">case</font></span> ALC.ALC_INVALID_DEVICE: <span class=codeKeyword><font color="#0000FF">return</font></span> "ALC_INVALID_DEVICE";
+<span class=codeKeyword> <font color="#0000FF">case</font></span> ALC.ALC_INVALID_CONTEXT: <span class=codeKeyword><font color="#0000FF">return</font></span> "ALC_INVALID_CONTEXT";
+<span class=codeKeyword> <font color="#0000FF">case</font></span> ALC.ALC_INVALID_ENUM: <span class=codeKeyword><font color="#0000FF">return</font></span> "ALC_INVALID_ENUM";
+<span class=codeKeyword> <font color="#0000FF">case</font></span> ALC.ALC_INVALID_VALUE: <span class=codeKeyword><font color="#0000FF">return</font></span> "ALC_INVALID_VALUE";
+<span class=codeKeyword> <font color="#0000FF">case</font></span> ALC.ALC_OUT_OF_MEMORY: <span class=codeKeyword><font color="#0000FF">return</font></span> "ALC_OUT_OF_MEMORY";
<font color="#0000FF">default</font>: <font color="#0000FF">return</font> <font color="#0000FF">null</font>;
}
}
@@ -155,7 +155,7 @@ public static int </font>loadALBuffer(String path) <font color="#0000FF">throws<
int result;
<span class=codeComment><font color="#006600">// Generate a buffer. Check that it was created successfully.</font></span>
- al.alGenBuffers(1, buffer);
+ al.alGenBuffers(1, buffer, 0);
<span class=codeKeyword><font color="#0000FF">if</font> </span>((result = al.alGetError()) != AL.AL_NO_ERROR)
<span class=codeKeyword><font color="#0000FF">throw</font></span><font color="#0000FF"> new</font> IOException(getALErrorString(result));
@@ -173,9 +173,9 @@ public static int </font>loadALBuffer(String path) <font color="#0000FF">throws<
<span class=codeKeyword><font color="#0000FF">if</font> </span>((result = al.alGetError()) != AL.AL_NO_ERROR)
<span class=codeKeyword><font color="#0000FF">throw</font></span> new IOException(getALErrorString(result));
-<font color="#006600"> <span class=codeComment>// Get rid of the temporary data.</span>
+<!-- <font color="#006600"> <span class=codeComment>// Get rid of the temporary data.</span>
</font>
- ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]);
+ ALut.alutUnloadWAV(format[0], data[0], size[0], freq[0]); -->
<span class=codeKeyword><font color="#0000FF">if</font> </span>((result = al.alGetError()) != AL.AL_NO_ERROR)
<span class=codeKeyword><font color="#0000FF">throw</font></span> new IOException(getALErrorString(result));
@@ -237,7 +237,7 @@ public static int </font>loadALBuffer(String path) <font color="#0000FF">throws<
buffer = getLoadedALBuffer(path);
<span class=codeComment><font color="006600">// Generate a source.</font></span>
- al.alGenSources(1, source);
+ al.alGenSources(1, source, 0);
<span class=codeKeyword><font color="000066">if</font> </span>((result = al.alGetError()) != AL.AL_NO_ERROR)
<span class=codeKeyword><font color="0000ff">throw</font></span> new IOException(getALErrorString(result));
@@ -247,8 +247,8 @@ public static int </font>loadALBuffer(String path) <font color="#0000FF">throws<
al.alSourcei (source[0], AL.AL_BUFFER, buffer );
al.alSourcef (source[0], AL.AL_PITCH, 1.0f );
al.alSourcef (source[0], AL.AL_GAIN, 1.0f );
- al.alSourcefv(source[0], AL.AL_POSITION, sourcePos);
- al.alSourcefv(source[0], AL.AL_VELOCITY, sourceVel);
+ al.alSourcefv(source[0], AL.AL_POSITION, sourcePos, 0);
+ al.alSourcefv(source[0], AL.AL_VELOCITY, sourceVel, 0);
al.alSourcei (source[0], AL.AL_LOOPING, loop ? AL.AL_TRUE : AL.AL_FALSE );
<span class=codeComment>// Save the source id.</span>