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

项目:Sound-Physics    文件:SoundPhysics.java   
private static void setupEFX()
{
    //Get current context and device
    ALCcontext currentContext = ALC10.alcGetCurrentContext();
    ALCdevice currentDevice = ALC10.alcGetContextsDevice(currentContext);       

    if (ALC10.alcIsExtensionPresent(currentDevice, "ALC_EXT_EFX"))
    {
        log("EFX Extension recognized.");
    }
    else
    {
        logError("EFX Extension not found on current device. Aborting.");
        return;
    }

    //Create auxiliary effect slots
    auxFXSlot0 = EFX10.alGenAuxiliaryEffectSlots();
    log("Aux slot " + auxFXSlot0 + " created");
    EFX10.alAuxiliaryEffectSloti(auxFXSlot0, EFX10.AL_EFFECTSLOT_AUXILIARY_SEND_AUTO, AL10.AL_TRUE);

    auxFXSlot1 = EFX10.alGenAuxiliaryEffectSlots();
    log("Aux slot " + auxFXSlot1 + " created");
    EFX10.alAuxiliaryEffectSloti(auxFXSlot1, EFX10.AL_EFFECTSLOT_AUXILIARY_SEND_AUTO, AL10.AL_TRUE);

    auxFXSlot2 = EFX10.alGenAuxiliaryEffectSlots();
    log("Aux slot " + auxFXSlot2 + " created");
    EFX10.alAuxiliaryEffectSloti(auxFXSlot2, EFX10.AL_EFFECTSLOT_AUXILIARY_SEND_AUTO, AL10.AL_TRUE);

    auxFXSlot3 = EFX10.alGenAuxiliaryEffectSlots();
    log("Aux slot " + auxFXSlot3 + " created");
    EFX10.alAuxiliaryEffectSloti(auxFXSlot3, EFX10.AL_EFFECTSLOT_AUXILIARY_SEND_AUTO, AL10.AL_TRUE);    
    checkErrorLog("Failed creating auxiliary effect slots!");


    //Create effect objects
    reverb0 = EFX10.alGenEffects();                                             //Create effect object
    EFX10.alEffecti(reverb0, EFX10.AL_EFFECT_TYPE, EFX10.AL_EFFECT_EAXREVERB);      //Set effect object to be reverb
    checkErrorLog("Failed creating reverb effect slot 0!");
    reverb1 = EFX10.alGenEffects();                                             //Create effect object
    EFX10.alEffecti(reverb1, EFX10.AL_EFFECT_TYPE, EFX10.AL_EFFECT_EAXREVERB);      //Set effect object to be reverb
    checkErrorLog("Failed creating reverb effect slot 1!");
    reverb2 = EFX10.alGenEffects();                                             //Create effect object
    EFX10.alEffecti(reverb2, EFX10.AL_EFFECT_TYPE, EFX10.AL_EFFECT_EAXREVERB);      //Set effect object to be reverb
    checkErrorLog("Failed creating reverb effect slot 2!");
    reverb3 = EFX10.alGenEffects();                                             //Create effect object
    EFX10.alEffecti(reverb3, EFX10.AL_EFFECT_TYPE, EFX10.AL_EFFECT_EAXREVERB);      //Set effect object to be reverb
    checkErrorLog("Failed creating reverb effect slot 3!");

    //Create filters
    directFilter0 = EFX10.alGenFilters();
    EFX10.alFilteri(directFilter0, EFX10.AL_FILTER_TYPE, EFX10.AL_FILTER_LOWPASS);

    sendFilter0 = EFX10.alGenFilters();
    EFX10.alFilteri(sendFilter0, EFX10.AL_FILTER_TYPE, EFX10.AL_FILTER_LOWPASS);

    sendFilter1 = EFX10.alGenFilters();
    EFX10.alFilteri(sendFilter1, EFX10.AL_FILTER_TYPE, EFX10.AL_FILTER_LOWPASS);

    sendFilter2 = EFX10.alGenFilters();
    EFX10.alFilteri(sendFilter2, EFX10.AL_FILTER_TYPE, EFX10.AL_FILTER_LOWPASS);

    sendFilter3 = EFX10.alGenFilters();
    EFX10.alFilteri(sendFilter3, EFX10.AL_FILTER_TYPE, EFX10.AL_FILTER_LOWPASS);
    checkErrorLog("Error creating lowpass filters!");

    applyConfigChanges();

    //setReverbParams(ReverbParams.getReverb0(), auxFXSlot0, reverb0);      //Set the global reverb parameters and apply them to the effect and effectslot      
    //setReverbParams(ReverbParams.getReverb1(), auxFXSlot1, reverb1);      //Set the global reverb parameters and apply them to the effect and effectslot      
    //setReverbParams(ReverbParams.getReverb2(), auxFXSlot2, reverb2);      //Set the global reverb parameters and apply them to the effect and effectslot      
    //setReverbParams(ReverbParams.getReverb3(), auxFXSlot3, reverb3);      //Set the global reverb parameters and apply them to the effect and effectslot      
}
项目:Dwarf2D    文件:openAL.java   
public static ALCcontext getContext() {
    return AL.getContext();
}
项目:Mineworld    文件:OpenALManager.java   
public OpenALManager(AudioConfig config) {
    logger.info("Initializing OpenAL audio manager");
    config.subscribe(configListener);
    try {
        AL.create();
    } catch (LWJGLException e) {
        throw new RuntimeException(e);
    }

    AL10.alGetError();

    logger.info("OpenAL {} initialized!", AL10.alGetString(AL10.AL_VERSION));

    ALCcontext context = ALC10.alcGetCurrentContext();
    ALCdevice device = ALC10.alcGetContextsDevice(context);

    logger.info("Using OpenAL: {} by {}", AL10.alGetString(AL10.AL_RENDERER), AL10.alGetString(AL10.AL_VENDOR));
    logger.info("Using device: {}", ALC10.alcGetString(device, ALC10.ALC_DEVICE_SPECIFIER));
    logger.info("Available AL extensions: {}", AL10.alGetString(AL10.AL_EXTENSIONS));
    logger.info("Available ALC extensions: {}", ALC10.alcGetString(device, ALC10.ALC_EXTENSIONS));

    IntBuffer buffer = BufferUtils.createIntBuffer(1);
    ALC10.alcGetInteger(device, ALC11.ALC_MONO_SOURCES, buffer);
    logger.info("Max mono sources: {}", buffer.get(0));
    buffer.rewind();

    ALC10.alcGetInteger(device, ALC11.ALC_STEREO_SOURCES, buffer);
    logger.info("Max stereo sources: {}", buffer.get(0));
    buffer.rewind();

    ALC10.alcGetInteger(device, ALC10.ALC_FREQUENCY, buffer);
    logger.info("Mixer frequency: {}", buffer.get(0));
    buffer.rewind();

    AL10.alDistanceModel(AL10.AL_INVERSE_DISTANCE_CLAMPED);

    // Initialize sound pools
    pools.put("sfx", new BasicSoundPool(30)); // effects pool
    pools.put("music", new BasicStreamingSoundPool(2)); // music pool
    pools.get("sfx").setVolume(config.getSoundVolume());
    pools.get("music").setVolume(config.getMusicVolume());
}