OSDN Git Service

1183, OpenAL panning fixed.
authorNathanSweet <nathan.sweet@gmail.com>
Wed, 2 Jan 2013 12:41:57 +0000 (13:41 +0100)
committerNathanSweet <nathan.sweet@gmail.com>
Wed, 2 Jan 2013 12:41:57 +0000 (13:41 +0100)
backends/gdx-openal/src/com/badlogic/gdx/backends/openal/OpenALAudio.java
tests/gdx-tests/src/com/badlogic/gdx/tests/SoundTest.java

index 44ee12a..e2efffa 100644 (file)
@@ -27,6 +27,7 @@ import com.badlogic.gdx.Audio;
 import com.badlogic.gdx.audio.AudioDevice;\r
 import com.badlogic.gdx.audio.AudioRecorder;\r
 import com.badlogic.gdx.files.FileHandle;\r
+import com.badlogic.gdx.math.MathUtils;\r
 import com.badlogic.gdx.utils.Array;\r
 import com.badlogic.gdx.utils.GdxRuntimeException;\r
 import com.badlogic.gdx.utils.IntArray;\r
@@ -149,7 +150,7 @@ public class OpenALAudio implements Audio {
                                alSourcei(sourceId, AL_BUFFER, 0);\r
                                AL10.alSourcef(sourceId, AL10.AL_GAIN, 1);\r
                                AL10.alSourcef(sourceId, AL10.AL_PITCH, 1);\r
-                               AL10.alSource3f(sourceId, AL10.AL_POSITION, 0, 0, 0);\r
+                               AL10.alSource3f(sourceId, AL10.AL_POSITION, 0, 0, 1f);\r
                                return sourceId;\r
                        }\r
                }\r
@@ -235,7 +236,8 @@ public class OpenALAudio implements Audio {
                if (!soundIdToSource.containsKey(soundId)) return;\r
                int sourceId = soundIdToSource.get(soundId);\r
 \r
-               AL10.alSource3f(sourceId, AL10.AL_POSITION, pan, 0, 0);\r
+               AL10.alSource3f(sourceId, AL10.AL_POSITION, MathUtils.cos((pan - 1) * MathUtils.PI / 2), 0,\r
+                       MathUtils.sin((pan + 1) * MathUtils.PI / 2));\r
                AL10.alSourcef(sourceId, AL10.AL_GAIN, volume);\r
        }\r
 \r
index 9abffda..7a85685 100644 (file)
@@ -61,8 +61,10 @@ public class SoundTest extends GdxTest {
                table.setFillParent(true);\r
 \r
                table.align(Align.center | Align.top);\r
+               table.columnDefaults(0).expandX().right().uniformX();\r
+               table.columnDefaults(2).expandX().left().uniformX();\r
                table.add(play);\r
-               table.add(stop);\r
+               table.add(stop).left();\r
                table.row();\r
                table.add(new Label("Pitch", skin));\r
                table.add(pitch);\r