Java 类org.lwjgl.openal.AL 实例源码

项目:LD38    文件:Mixer.java   
private void initialize(){
    device = alcOpenDevice((ByteBuffer)null);
    if(device == 0L){
        Application.error("Unable to open default audio device");
        return;
    }

    ALCCapabilities deviceCaps = ALC.createCapabilities(device);

    if(!deviceCaps.OpenALC10){
        Application.error("OpenALC10 Unsupported");
        return;
    }


    context = alcCreateContext(device, (IntBuffer)null);
    if(context == 0L){
        Application.error("Unable to create ALC Context");
        return;
    }

    ALC10.alcMakeContextCurrent(context);
    AL.createCapabilities(deviceCaps);
}
项目:BaseClient    文件:OpenALMODPlayer.java   
/**
* Initialise OpenAL LWJGL styley
*/
  public void init() {
    try {
    AL.create();
    soundWorks = true;
} catch (LWJGLException e) {
    System.err.println("Failed to initialise LWJGL OpenAL");
    soundWorks = false;
    return;
}

if (soundWorks) {
    IntBuffer sources = BufferUtils.createIntBuffer(1);
    AL10.alGenSources(sources);

    if (AL10.alGetError() != AL10.AL_NO_ERROR) {
        System.err.println("Failed to create sources");
        soundWorks = false;
    } else {
        source = sources.get(0);
    }

}
  }
项目:featurea    文件:OpenALImpl.java   
@Override
public void init() {
    if (!AL.isCreated()) {
        try {
            AL.create();
        } catch (LWJGLException e) {
            e.printStackTrace();
        }
        allSources = new IntArray(SIMULTANEOUS_SOURCES_COUNT);
        for (int i = 0; i < SIMULTANEOUS_SOURCES_COUNT; i++) {
            int sourceID = AL10.alGenSources();
            if (AL10.alGetError() == AL10.AL_NO_ERROR) {
                allSources.add(sourceID);
            }
        }
        idleSources = new IntArray(allSources);
        recentSounds = new SoundPoolImpl[SIMULTANEOUS_SOURCES_COUNT];
        AL10.alListener(AL10.AL_ORIENTATION, orientation);
        AL10.alListener(AL10.AL_VELOCITY, velocity);
        AL10.alListener(AL10.AL_POSITION, position);
    }
}
项目:Towan    文件:OpenALMODPlayer.java   
/**
* Initialise OpenAL LWJGL styley
*/
  public void init() {
    try {
    AL.create();
    soundWorks = true;
} catch (LWJGLException e) {
    System.err.println("Failed to initialise LWJGL OpenAL");
    soundWorks = false;
    return;
}

if (soundWorks) {
    IntBuffer sources = BufferUtils.createIntBuffer(1);
    AL10.alGenSources(sources);

    if (AL10.alGetError() != AL10.AL_NO_ERROR) {
        System.err.println("Failed to create sources");
        soundWorks = false;
    } else {
        source = sources.get(0);
    }

}
  }
项目:PhET    文件:SoundManager.java   
/**
 * Initializes the SoundManager
 *
 * @param channels Number of channels to create
 */
public void initialize(int channels) {
  try {
   AL.create();

   // allocate sources
   scratchBuffer.limit(channels);
   AL10.alGenSources(scratchBuffer);
   scratchBuffer.rewind();
   scratchBuffer.get(sources = new int[channels]);

   // could we allocate all channels?
   if(AL10.alGetError() != AL10.AL_NO_ERROR) {
    throw new LWJGLException("Unable to allocate " + channels + " sources");
   }

   // we have sound
   soundOutput = true;
  } catch (LWJGLException le) {
    le.printStackTrace();
    System.out.println("Sound disabled");
  }
}
项目:PhET    文件:SoundManager.java   
/**
 * Destroy this SoundManager
 */
public void destroy() {
  if(soundOutput) {

    // stop playing sounds
    scratchBuffer.position(0).limit(sources.length);
    scratchBuffer.put(sources).flip();
    AL10.alSourceStop(scratchBuffer);

    // destroy sources
    AL10.alDeleteSources(scratchBuffer);

    // destroy buffers
    scratchBuffer.position(0).limit(bufferIndex);
    scratchBuffer.put(buffers, 0, bufferIndex).flip();
    AL10.alDeleteBuffers(scratchBuffer);

    // destory OpenAL
    AL.destroy();
  }
}
项目:PhET    文件:BasicTest.java   
/**
 * Creates an instance of PlayTest
 */
protected BasicTest() {
  try {
    AL.create();

    System.out.println("Default device: " + ALC10.alcGetString(null, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER));

    if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) {
        String[] devices = ALC10.alcGetString(null, ALC10.ALC_DEVICE_SPECIFIER).split("\0");
    System.out.println("Available devices: ");
        for(int i=0; i<devices.length; i++) {
            System.out.println(i +": " + devices[i]);
        }
    }
  } catch (Exception e) {
    System.out.println("Unable to create OpenAL.\nPlease make sure that OpenAL is available on this system. Exception: " + e);
    return;
  }
}
项目:PhET    文件:OpenALInfo.java   
/**
 * Runs the actual test, using supplied arguments
 */
protected void execute(String[] args) {
    try {
        AL.create(null, -1, 60, false);
        checkForErrors();
    } catch (LWJGLException le) {
        die("Init", le.getMessage());
    }

    printALCInfo();
    printALInfo();
    printEFXInfo();

    checkForErrors();

    AL.destroy();
}
项目:PhET    文件:OpenAL.java   
public OpenAL() throws LWJGLException {

        try {
            AL.create();
        } catch (Exception e) {
            System.out.println("Unable to create OpenAL.\nPlease make sure that OpenAL is available on this system. Exception: " + e);
            return;
        }

        Thread t = new Thread() {

            public void run() {
                while (true) {
                    if (isVisible())
                        repaint();
                    Display.sync(60);
                }
            }
        };
        t.setDaemon(true);
        t.start();
    }
项目:PhET    文件:OpenAL.java   
public void stop() {
    int lastError;

       //stop source 0
       AL10.alSourceStop(sources.get(0));
       if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
           exit(lastError);
       }

       //delete buffers and sources
       sources.position(0).limit(1);
       AL10.alDeleteSources(sources);
       if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
           exit(lastError);
       }

       buffers.position(0).limit(1);
       AL10.alDeleteBuffers(buffers);
       if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
           exit(lastError);
       }

       AL.destroy();
}
项目:PhET    文件:LwjglAudioRenderer.java   
public void cleanupInThread(){
    if (audioDisabled){
        AL.destroy();
        return;
    }

    // delete channel-based sources
    ib.clear();
    ib.put(channels);
    ib.flip();
    alDeleteSources(ib);

    if (supportEfx){
        ib.position(0).limit(1);
        ib.put(0, reverbFx);
        EFX10.alDeleteEffects(ib);

        ib.position(0).limit(1);
        ib.put(0, reverbFxSlot);
        EFX10.alDeleteAuxiliaryEffectSlots(ib);
    }

    // XXX: Delete other buffers/sources
    AL.destroy();
}
项目:Undertailor    文件:OpenALAudio.java   
public void dispose () {
    if (noDevice) return;
    for (int i = 0, n = allSources.size; i < n; i++) {
        int sourceID = allSources.get(i);
        int state = alGetSourcei(sourceID, AL_SOURCE_STATE);
        if (state != AL_STOPPED) alSourceStop(sourceID);
        alDeleteSources(sourceID);
    }

    sourceToSoundId.clear();
    soundIdToSource.clear();

    AL.destroy();
    while (AL.isCreated()) {
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
        }
    }
}
项目:FEMultiPlayer-V2    文件:LevelEditor.java   
@Override
public void loop() {
    while(!Display.isCloseRequested()) {
        final long time = System.nanoTime();
        glClear(GL_COLOR_BUFFER_BIT |
                GL_DEPTH_BUFFER_BIT |
                GL_STENCIL_BUFFER_BIT);
        glClearDepth(1.0f);
        getInput();
        glPushMatrix();
            currentStage.beginStep(emptyList());
            currentStage.onStep();
            currentStage.processAddStack();
            currentStage.processRemoveStack();
            Renderer.getCamera().lookThrough();
            currentStage.render();
            currentStage.endStep();
        glPopMatrix();
        Display.update();
        timeDelta = System.nanoTime()-time;
    }
    AL.destroy();
    Display.destroy();
}
项目:Jumbo-Engine    文件:JumboAudioHandler.java   
public static final void init() throws InstantiationException {
    if (init) {
        throw new InstantiationException("[WARNING] Jumbo Audio Player was already initialized!"); //$NON-NLS-1$
    }
    try {
        AL.create();
    } catch (LWJGLException le) {
        le.printStackTrace();
        return;
    }
    buffer = BufferUtils.createIntBuffer(SOUND_NUM);
    AL10.alGenSources(source);
    AL10.alGenBuffers(buffer);
    buffer.limit(1);
    AL10.alDopplerFactor(1.0f);
    AL10.alDopplerVelocity(1.0f);
    check();
    init = true;
}
项目:Mystic-Bastion    文件:SoundManager.java   
public void cleanUp() {
    Set<String> keys = sourcesMap.keySet();
    Iterator<String> iter = keys.iterator();

    String name;
    IntBuffer buffer, source;
    while (iter.hasNext()) {
        name = iter.next();

        source = sourcesMap.get(name);
        System.out.println("Stopping " + name);
        AL10.alSourceStop(source);
        AL10.alDeleteSources(source);

        buffer = buffersMap.get(name);
        AL10.alDeleteBuffers(buffer);
    }
    AL.destroy();
}
项目:KillBox    文件:Sound.java   
public Sound()
{
    System.out.print("SFX initialisation");

    try
    {
        AL.create();
        IntSource = alGenSources();
    }
    catch (LWJGLException e)
    {
        e.printStackTrace();
    }

    System.out.println(".");
}
项目:golems    文件:ALAudioManager.java   
private void init() throws LWJGLException {
    this.executeInAudio(new Callable<Object>(){


        public Object call() throws Exception {
            try {
                AL.create();
            } catch (LWJGLException e) {
                StateManager.logError(e);
            }
            return null;
        }

    });

}
项目:golems    文件:ALAudioManager.java   
public void close() {
    if(!closed.compareAndSet(false, true))
        return;

    try{
        for(AudioStateListener listener:audioStateListeners)
        {
            try{
                listener.close();
            }catch(Exception e)
            {
                StateManager.logError(e);
            }
        }
    }finally{
        this.exec.shutdown();

        if(AL.isCreated()) {
              AL.destroy();
         }
    }
}
项目:TeacherSmash    文件:OpenAL.java   
public OpenAL() throws LWJGLException {

        try {
            AL.create();
        } catch (Exception e) {
            System.out.println("Unable to create OpenAL.\nPlease make sure that OpenAL is available on this system. Exception: " + e);
            return;
        }

        Thread t = new Thread() {

            public void run() {
                while (true) {
                    if (isVisible())
                        repaint();
                    Display.sync(60);
                }
            }
        };
        t.setDaemon(true);
        t.start();
    }
项目:Heightmap-Renderer    文件:Game.java   
private void Run(){

    CurrentState.GetState().Launch();



    while (CurrentState.GetState().LaunchMe) {
        try {

            if(CurrentState.GetState().LaunchMe){
                CurrentState.GetState().Toggle(true);
            }
        } catch (Exception e) {
            System.out.println(e.getLocalizedMessage());
        }
    }
    AL.destroy();
    Display.destroy();
    System.exit(0);

}
项目:libgdxcn    文件:OpenALAudio.java   
public void dispose () {
    if (noDevice) return;
    for (int i = 0, n = allSources.size; i < n; i++) {
        int sourceID = allSources.get(i);
        int state = alGetSourcei(sourceID, AL_SOURCE_STATE);
        if (state != AL_STOPPED) alSourceStop(sourceID);
        alDeleteSources(sourceID);
    }

    sourceToSoundId.clear();
    soundIdToSource.clear();

    AL.destroy();
    while (AL.isCreated()) {
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
        }
    }
}
项目:Wolf_game    文件:SoundManager.java   
/**
 * Initializes the SoundManager
 *
 * @param channels Number of channels to create
 */
public void initialize(int channels) {
  try {
   AL.create();

   // allocate sources
   scratchBuffer.limit(channels);
   AL10.alGenSources(scratchBuffer);
   scratchBuffer.rewind();
   scratchBuffer.get(sources = new int[channels]);

   // could we allocate all channels?
   if(AL10.alGetError() != AL10.AL_NO_ERROR) {
    throw new LWJGLException("Unable to allocate " + channels + " sources");
   }

   // we have sound
   soundOutput = true;
  } catch (LWJGLException le) {
    le.printStackTrace();
    System.out.println("Sound disabled");
  }
}
项目:Wolf_game    文件:SoundManager.java   
/**
 * Destroy this SoundManager
 */
public void destroy() {
  if(soundOutput) {

    // stop playing sounds
    scratchBuffer.position(0).limit(sources.length);
    scratchBuffer.put(sources).flip();
    AL10.alSourceStop(scratchBuffer);

    // destroy sources
    AL10.alDeleteSources(scratchBuffer);

    // destroy buffers
    scratchBuffer.position(0).limit(bufferIndex);
    scratchBuffer.put(buffers, 0, bufferIndex).flip();
    AL10.alDeleteBuffers(scratchBuffer);

    // destory OpenAL
    AL.destroy();
  }
}
项目:Wolf_game    文件:BasicTest.java   
/**
 * Creates an instance of PlayTest
 */
protected BasicTest() {
  try {
    AL.create();

    System.out.println("Default device: " + ALC10.alcGetString(null, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER));

    if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) {
        String[] devices = ALC10.alcGetString(null, ALC10.ALC_DEVICE_SPECIFIER).split("\0");
    System.out.println("Available devices: ");
        for(int i=0; i<devices.length; i++) {
            System.out.println(i +": " + devices[i]);
        }
    }
  } catch (Exception e) {
    System.out.println("Unable to create OpenAL.\nPlease make sure that OpenAL is available on this system. Exception: " + e);
    return;
  }
}
项目:SpaceStationAlpha    文件:OpenAL.java   
public void stop() {
    int lastError;

       //stop source 0
       AL10.alSourceStop(sources.get(0));
       if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
           exit(lastError);
       }

       //delete buffers and sources
       sources.position(0).limit(1);
       AL10.alDeleteSources(sources);
       if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
           exit(lastError);
       }

       buffers.position(0).limit(1);
       AL10.alDeleteBuffers(buffers);
       if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
           exit(lastError);
       }

       AL.destroy();
}
项目:9-Gates    文件:Game.java   
private void Run() {
    CurrentState.GetState().Launch();

    while (CurrentState.GetState().LaunchMe) {
        try {

            if (CurrentState.GetState().LaunchMe) {
                CurrentState.GetState().Toggle(true);
            }
        } catch (Exception e) {
            System.out.println(e.getLocalizedMessage());
        }
    }
    AL.destroy();
    Display.destroy();
    System.exit(0);

}
项目:Wolf_game    文件:OpenAL.java   
public OpenAL() throws LWJGLException {

        try {
            AL.create();
        } catch (Exception e) {
            System.out.println("Unable to create OpenAL.\nPlease make sure that OpenAL is available on this system. Exception: " + e);
            return;
        }

        Thread t = new Thread() {

            public void run() {
                while (true) {
                    if (isVisible())
                        repaint();
                    Display.sync(60);
                }
            }
        };
        t.setDaemon(true);
        t.start();
    }
项目:Wolf_game    文件:OpenAL.java   
public void stop() {
    int lastError;

       //stop source 0
       AL10.alSourceStop(sources.get(0));
       if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
           exit(lastError);
       }

       //delete buffers and sources
       sources.position(0).limit(1);
       AL10.alDeleteSources(sources);
       if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
           exit(lastError);
       }

       buffers.position(0).limit(1);
       AL10.alDeleteBuffers(buffers);
       if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
           exit(lastError);
       }

       AL.destroy();
}
项目:GameCo    文件:GameCo.java   
public GameCo(){ //My initialization code
    initGL();
    initFont();
    lastFPS = getTime();

    //if(gamesave = found) loadgame; else newGame();
    newGame();

    BackgroundTex = loadTexture("grass");

    conWind = new Window(100, 100, 800, 600, this);
    buyWind = new Window(8, 180, 128, 256, this);

    //gameLoop();
    while (!Display.isCloseRequested()){
        gameLoop();
    }
    Display.destroy();
       AL.destroy();
       System.exit(0);
}
项目:libGDX-LWJGL-Audio    文件:OpenALAudio.java   
public void dispose() {
    if (noDevice) {
        return;
    }
    for (int i = 0, n = allSources.size; i < n; i++) {
        int sourceID = allSources.get(i);
        int state = alGetSourcei(sourceID, AL_SOURCE_STATE);
        if (state != AL_STOPPED) {
            alSourceStop(sourceID);
        }
        alDeleteSources(sourceID);
    }

    sourceToSoundId.clear();
    soundIdToSource.clear();

    AL.destroy();
    while (AL.isCreated()) {
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
        }
    }
}
项目:TeacherSmash    文件:BasicTest.java   
/**
 * Creates an instance of PlayTest
 */
protected BasicTest() {
  try {
    AL.create();

    System.out.println("Default device: " + ALC10.alcGetString(null, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER));

    if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) {
        String[] devices = ALC10.alcGetString(null, ALC10.ALC_DEVICE_SPECIFIER).split("\0");
    System.out.println("Available devices: ");
        for(int i=0; i<devices.length; i++) {
            System.out.println(i +": " + devices[i]);
        }
    }
  } catch (Exception e) {
    System.out.println("Unable to create OpenAL.\nPlease make sure that OpenAL is available on this system. Exception: " + e);
    return;
  }
}
项目:TeacherSmash    文件:SoundManager.java   
/**
 * Destroy this SoundManager
 */
public void destroy() {
  if(soundOutput) {

    // stop playing sounds
    scratchBuffer.position(0).limit(sources.length);
    scratchBuffer.put(sources).flip();
    AL10.alSourceStop(scratchBuffer);

    // destroy sources
    AL10.alDeleteSources(scratchBuffer);

    // destroy buffers
    scratchBuffer.position(0).limit(bufferIndex);
    scratchBuffer.put(buffers, 0, bufferIndex).flip();
    AL10.alDeleteBuffers(scratchBuffer);

    // destory OpenAL
    AL.destroy();
  }
}
项目:GPVM    文件:SoundManager.java   
/**
 * Initializes the SoundManager
 *
 * @param channels Number of channels to create
 */
public void initialize(int channels) {
  try {
   AL.create();

   // allocate sources
   scratchBuffer.limit(channels);
   AL10.alGenSources(scratchBuffer);
   scratchBuffer.rewind();
   scratchBuffer.get(sources = new int[channels]);

   // could we allocate all channels?
   if(AL10.alGetError() != AL10.AL_NO_ERROR) {
    throw new LWJGLException("Unable to allocate " + channels + " sources");
   }

   // we have sound
   soundOutput = true;
  } catch (LWJGLException le) {
    le.printStackTrace();
    System.out.println("Sound disabled");
  }
}
项目:GPVM    文件:BasicTest.java   
/**
 * Creates an instance of PlayTest
 */
protected BasicTest() {
  try {
    AL.create();

    System.out.println("Default device: " + ALC10.alcGetString(null, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER));

    if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) {
        String[] devices = ALC10.alcGetString(null, ALC10.ALC_DEVICE_SPECIFIER).split("\0");
    System.out.println("Available devices: ");
        for(int i=0; i<devices.length; i++) {
            System.out.println(i +": " + devices[i]);
        }
    }
  } catch (Exception e) {
    System.out.println("Unable to create OpenAL.\nPlease make sure that OpenAL is available on this system. Exception: " + e);
    return;
  }
}
项目:TeacherSmash    文件:OpenALInfo.java   
/**
 * Runs the actual test, using supplied arguments
 */
protected void execute(String[] args) {
    try {
        AL.create(null, -1, 60, false);
        checkForErrors();
    } catch (LWJGLException le) {
        die("Init", le.getMessage());
    }

    printALCInfo();
    printALInfo();
    printEFXInfo();

    checkForErrors();

    AL.destroy();
}
项目:GPVM    文件:OpenALInfo.java   
/**
 * Runs the actual test, using supplied arguments
 */
protected void execute(String[] args) {
    try {
        AL.create(null, -1, 60, false);
        checkForErrors();
    } catch (LWJGLException le) {
        die("Init", le.getMessage());
    }

    printALCInfo();
    printALInfo();
    printEFXInfo();

    checkForErrors();

    AL.destroy();
}
项目:GPVM    文件:OpenAL.java   
public OpenAL() throws LWJGLException {

        try {
            AL.create();
        } catch (Exception e) {
            System.out.println("Unable to create OpenAL.\nPlease make sure that OpenAL is available on this system. Exception: " + e);
            return;
        }

        Thread t = new Thread() {

            public void run() {
                while (true) {
                    if (isVisible())
                        repaint();
                    Display.sync(60);
                }
            }
        };
        t.setDaemon(true);
        t.start();
    }
项目:GPVM    文件:OpenAL.java   
public void stop() {
    int lastError;

       //stop source 0
       AL10.alSourceStop(sources.get(0));
       if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
           exit(lastError);
       }

       //delete buffers and sources
       sources.position(0).limit(1);
       AL10.alDeleteSources(sources);
       if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
           exit(lastError);
       }

       buffers.position(0).limit(1);
       AL10.alDeleteBuffers(buffers);
       if((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
           exit(lastError);
       }

       AL.destroy();
}
项目:GPVM    文件:SoundManager.java   
/**
 * Initializes the SoundManager
 *
 * @param channels Number of channels to create
 */
public void initialize(int channels) {
  try {
   AL.create();

   // allocate sources
   scratchBuffer.limit(channels);
   AL10.alGenSources(scratchBuffer);
   scratchBuffer.rewind();
   scratchBuffer.get(sources = new int[channels]);

   // could we allocate all channels?
   if(AL10.alGetError() != AL10.AL_NO_ERROR) {
    throw new LWJGLException("Unable to allocate " + channels + " sources");
   }

   // we have sound
   soundOutput = true;
  } catch (LWJGLException le) {
    le.printStackTrace();
    System.out.println("Sound disabled");
  }
}
项目:GPVM    文件:SoundManager.java   
/**
 * Destroy this SoundManager
 */
public void destroy() {
  if(soundOutput) {

    // stop playing sounds
    scratchBuffer.position(0).limit(sources.length);
    scratchBuffer.put(sources).flip();
    AL10.alSourceStop(scratchBuffer);

    // destroy sources
    AL10.alDeleteSources(scratchBuffer);

    // destroy buffers
    scratchBuffer.position(0).limit(bufferIndex);
    scratchBuffer.put(buffers, 0, bufferIndex).flip();
    AL10.alDeleteBuffers(scratchBuffer);

    // destory OpenAL
    AL.destroy();
  }
}