JOAL学习笔记
先是例行的连续代码页,修复了原文中的错误并增加了必要的修改。
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.Vector;
import com.jogamp.openal.AL;
import com.jogamp.openal.ALC;
import com.jogamp.openal.ALCcontext;
import com.jogamp.openal.ALCdevice;
import com.jogamp.openal.ALFactory;
import com.jogamp.openal.util.ALut;
public class AdvALTest {
private static AL al;
private static ALC alc;
private static Vector<String> loadedFiles = new Vector<>(); // 临时储存加载的文件路径
private static Vector<Integer> buffers = new Vector<>(); // 储存所有被加载的缓冲区
private static Vector<Integer> sources = new Vector<>(); // 储存所有合法的声源
// 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 };
public static String getALErrorString(int err) {
switch (err) {
case AL.AL_NO_ERROR:
return "AL_NO_ERROR";
case AL.AL_INVALID_NAME:
return "AL_INVALID_NAME";
case AL.AL_INVALID_ENUM:
return "AL_INVALID_ENUM";
case AL.AL_INVALID_VALUE:
return "AL_INVALID_VALUE";
case AL.AL