org.lwjgl.openal.EFX10 Java Examples

The following examples show how to use org.lwjgl.openal.EFX10. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SoundPhysics.java    From Sound-Physics with GNU General Public License v3.0 6 votes vote down vote up
private static void setEnvironment(int sourceID, float sendGain0, float sendGain1, float sendGain2, float sendGain3, float sendCutoff0, float sendCutoff1,
		float sendCutoff2, float sendCutoff3, float directCutoff, float directGain)
{
	//Set reverb send filter values and set source to send to all reverb fx slots
	EFX10.alFilterf(sendFilter0, EFX10.AL_LOWPASS_GAIN, sendGain0);
	EFX10.alFilterf(sendFilter0, EFX10.AL_LOWPASS_GAINHF, sendCutoff0);
	AL11.alSource3i(sourceID, EFX10.AL_AUXILIARY_SEND_FILTER, auxFXSlot0, 0, sendFilter0);	
	
	EFX10.alFilterf(sendFilter1, EFX10.AL_LOWPASS_GAIN, sendGain1);
	EFX10.alFilterf(sendFilter1, EFX10.AL_LOWPASS_GAINHF, sendCutoff1);
	AL11.alSource3i(sourceID, EFX10.AL_AUXILIARY_SEND_FILTER, auxFXSlot1, 1, sendFilter1);	
	
	EFX10.alFilterf(sendFilter2, EFX10.AL_LOWPASS_GAIN, sendGain2);
	EFX10.alFilterf(sendFilter2, EFX10.AL_LOWPASS_GAINHF, sendCutoff2);
	AL11.alSource3i(sourceID, EFX10.AL_AUXILIARY_SEND_FILTER, auxFXSlot2, 2, sendFilter2);	
	
	EFX10.alFilterf(sendFilter3, EFX10.AL_LOWPASS_GAIN, sendGain3);
	EFX10.alFilterf(sendFilter3, EFX10.AL_LOWPASS_GAINHF, sendCutoff3);
	AL11.alSource3i(sourceID, EFX10.AL_AUXILIARY_SEND_FILTER, auxFXSlot3, 3, sendFilter3);	
	
	EFX10.alFilterf(directFilter0, EFX10.AL_LOWPASS_GAIN, directGain);
	EFX10.alFilterf(directFilter0, EFX10.AL_LOWPASS_GAINHF, directCutoff);
	AL10.alSourcei(sourceID, EFX10.AL_DIRECT_FILTER, directFilter0);
	
	AL10.alSourcef(sourceID, EFX10.AL_AIR_ABSORPTION_FACTOR, SoundPhysicsCore.Config.airAbsorption);
}
 
Example #2
Source File: LwjglAudioRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void updateFilter(Filter f){
    int id = f.getId();
    if (id == -1){
        ib.position(0).limit(1);
        EFX10.alGenFilters(ib);
        id = ib.get(0);
        f.setId(id);
        
        objManager.registerForCleanup(f);
    }

    if (f instanceof LowPassFilter){
        LowPassFilter lpf = (LowPassFilter) f;
        EFX10.alFilteri(id, EFX10.AL_FILTER_TYPE,    EFX10.AL_FILTER_LOWPASS);
        EFX10.alFilterf(id, EFX10.AL_LOWPASS_GAIN,   lpf.getVolume());
        EFX10.alFilterf(id, EFX10.AL_LOWPASS_GAINHF, lpf.getHighFreqVolume());
    }else{
        throw new UnsupportedOperationException("Filter type unsupported: "+
                                                f.getClass().getName());
    }

    f.clearUpdateNeeded();
}
 
Example #3
Source File: LwjglAudioRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void clearChannel(int index){
    // make room at this channel
    if (chanSrcs[index] != null){
        AudioNode src = chanSrcs[index];

        int sourceId = channels[index];
        alSourceStop(sourceId);

        if (src.getAudioData() instanceof AudioStream){
            AudioStream str = (AudioStream) src.getAudioData();
            ib.position(0).limit(STREAMING_BUFFER_COUNT);
            ib.put(str.getIds()).flip();
            alSourceUnqueueBuffers(sourceId, ib);
        }else if (src.getAudioData() instanceof AudioBuffer){
            alSourcei(sourceId, AL_BUFFER, 0);
        }

        if (src.getDryFilter() != null && supportEfx){
            // detach filter
            alSourcei(sourceId, EFX10.AL_DIRECT_FILTER, EFX10.AL_FILTER_NULL);
        }
        if (src.isPositional()){
            AudioNode pas = (AudioNode) src;
            if (pas.isReverbEnabled() && supportEfx) {
                AL11.alSource3i(sourceId, EFX10.AL_AUXILIARY_SEND_FILTER, 0, 0, EFX10.AL_FILTER_NULL);
            }
        }

        chanSrcs[index] = null;
    }
}
 
Example #4
Source File: LwjglAudioRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setEnvironment(Environment env){
    checkDead();
    synchronized (threadLock){
        while (!threadLock.get()){
            try {
                threadLock.wait();
            } catch (InterruptedException ex) {
            }
        }
        if (audioDisabled || !supportEfx)
            return;
        
        EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_DENSITY,             env.getDensity());
        EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_DIFFUSION,           env.getDiffusion());
        EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_GAIN,                env.getGain());
        EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_GAINHF,              env.getGainHf());
        EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_DECAY_TIME,          env.getDecayTime());
        EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_DECAY_HFRATIO,       env.getDecayHFRatio());
        EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_REFLECTIONS_GAIN,    env.getReflectGain());
        EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_REFLECTIONS_DELAY,   env.getReflectDelay());
        EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_LATE_REVERB_GAIN,    env.getLateReverbGain());
        EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_LATE_REVERB_DELAY,   env.getLateReverbDelay());
        EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_AIR_ABSORPTION_GAINHF, env.getAirAbsorbGainHf());
        EFX10.alEffectf(reverbFx, EFX10.AL_REVERB_ROOM_ROLLOFF_FACTOR, env.getRoomRolloffFactor());

        // attach effect to slot
        EFX10.alAuxiliaryEffectSloti(reverbFxSlot, EFX10.AL_EFFECTSLOT_EFFECT, reverbFx);
    }
}
 
Example #5
Source File: LwjglAudioRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void cleanupInThread(){
    if (audioDisabled){
        AL.destroy();
        return;
    }

    // stop any playing channels
    for (int i = 0; i < chanSrcs.length; i++){
        if (chanSrcs[i] != null){
            clearChannel(i);
        }
    }
    
    // delete channel-based sources
    ib.clear();
    ib.put(channels);
    ib.flip();
    alDeleteSources(ib);
    
    // delete audio buffers and filters
    objManager.deleteAllObjects(this);

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

        // If this is not allocated, why is it deleted?
        // Commented out to fix native crash in OpenAL.
        ib.position(0).limit(1);
        ib.put(0, reverbFxSlot);
        EFX10.alDeleteAuxiliaryEffectSlots(ib);
    }

    AL.destroy();
}
 
Example #6
Source File: LwjglAudioRenderer.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void deleteFilter(Filter filter) {
    int id = filter.getId();
    if (id != -1){
        EFX10.alDeleteFilters(id);
    }
}
 
Example #7
Source File: SoundPhysics.java    From Sound-Physics with GNU General Public License v3.0 4 votes vote down vote up
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		
}
 
Example #8
Source File: LwjglEFX.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void alEffectf(int effect, int param, float value) {
    EFX10.alEffectf(effect, param, value);
}
 
Example #9
Source File: LwjglEFX.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void alDeleteFilters(int numFilters, IntBuffer buffers) {
    if (buffers.position() != 0) throw new AssertionError();
    if (buffers.limit() != numFilters) throw new AssertionError();
    EFX10.alDeleteFilters(buffers);
}
 
Example #10
Source File: LwjglEFX.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void alFilterf(int filter, int param, float value) {
    EFX10.alFilterf(filter, param, value);
}
 
Example #11
Source File: LwjglEFX.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void alFilteri(int filter, int param, int value) {
    EFX10.alFilteri(filter, param, value);
}
 
Example #12
Source File: LwjglEFX.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void alGenFilters(int numFilters, IntBuffer buffers) {
    if (buffers.position() != 0) throw new AssertionError();
    if (buffers.limit() != numFilters) throw new AssertionError();
    EFX10.alGenFilters(buffers);
}
 
Example #13
Source File: LwjglEFX.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void alDeleteAuxiliaryEffectSlots(int numEffectSlots, IntBuffer buffers) {
    if (buffers.position() != 0) throw new AssertionError();
    if (buffers.limit() != numEffectSlots) throw new AssertionError();
    EFX10.alDeleteAuxiliaryEffectSlots(buffers);
}
 
Example #14
Source File: LwjglEFX.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void alDeleteEffects(int numEffects, IntBuffer buffers) {
    if (buffers.position() != 0) throw new AssertionError();
    if (buffers.limit() != numEffects) throw new AssertionError();
    EFX10.alDeleteEffects(buffers);
}
 
Example #15
Source File: LwjglEFX.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void alAuxiliaryEffectSloti(int effectSlot, int param, int value) {
    EFX10.alAuxiliaryEffectSloti(effectSlot, param, value);
}
 
Example #16
Source File: LwjglEFX.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void alEffecti(int effect, int param, int value) {
    EFX10.alEffecti(effect, param, value);
}
 
Example #17
Source File: LwjglEFX.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void alGenEffects(int numEffects, IntBuffer buffers) {
    if (buffers.position() != 0) throw new AssertionError();
    if (buffers.limit() != numEffects) throw new AssertionError();
    EFX10.alGenEffects(buffers);
}
 
Example #18
Source File: LwjglEFX.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void alGenAuxiliaryEffectSlots(int numSlots, IntBuffer buffers) {
    if (buffers.position() != 0) throw new AssertionError();
    if (buffers.limit() != numSlots) throw new AssertionError();
    EFX10.alGenAuxiliaryEffectSlots(buffers);
}
 
Example #19
Source File: SoundPhysics.java    From Sound-Physics with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Applies the parameters in the enum ReverbParams to the main reverb effect.
 */
protected static void setReverbParams(ReverbParams r, int auxFXSlot, int reverbSlot)
{
	/*
	EFX10.alEffectf(reverbSlot, EFX10.AL_REVERB_DECAY_TIME, r.decayTime);		//Set default parameters
	EFX10.alEffectf(reverbSlot, EFX10.AL_REVERB_DENSITY, r.density);
	EFX10.alEffectf(reverbSlot, EFX10.AL_REVERB_DIFFUSION, r.diffusion);
	EFX10.alEffectf(reverbSlot, EFX10.AL_REVERB_GAIN, r.gain);
	EFX10.alEffectf(reverbSlot, EFX10.AL_REVERB_GAINHF, r.gainHF);
	EFX10.alEffectf(reverbSlot, EFX10.AL_REVERB_DECAY_HFRATIO, r.decayHFRatio);
	EFX10.alEffectf(reverbSlot, EFX10.AL_REVERB_REFLECTIONS_GAIN, r.reflectionsGain);
	EFX10.alEffectf(reverbSlot, EFX10.AL_REVERB_REFLECTIONS_DELAY, r.reflectionsDelay);
	EFX10.alEffectf(reverbSlot, EFX10.AL_REVERB_LATE_REVERB_GAIN, r.lateReverbGain);
	EFX10.alEffectf(reverbSlot, EFX10.AL_REVERB_LATE_REVERB_DELAY, r.lateReverbDelay);
	EFX10.alEffectf(reverbSlot, EFX10.AL_REVERB_AIR_ABSORPTION_GAINHF, r.airAbsorptionGainHF);
	EFX10.alEffectf(reverbSlot, EFX10.AL_REVERB_ROOM_ROLLOFF_FACTOR, r.roomRolloffFactor);
	EFX10.alEffecti(reverbSlot, EFX10.AL_REVERB_DECAY_HFLIMIT, AL10.AL_TRUE);
	*/
	
	EFX10.alEffectf(reverbSlot, EFX10.AL_EAXREVERB_DENSITY, r.density);		//Set default parameters
	checkErrorLog("Error while assigning reverb density: " + r.density);
	EFX10.alEffectf(reverbSlot, EFX10.AL_EAXREVERB_DIFFUSION, r.diffusion);		//Set default parameters
	checkErrorLog("Error while assigning reverb diffusion: " + r.diffusion);
	EFX10.alEffectf(reverbSlot, EFX10.AL_EAXREVERB_GAIN, r.gain);		//Set default parameters
	checkErrorLog("Error while assigning reverb gain: " + r.gain);
	EFX10.alEffectf(reverbSlot, EFX10.AL_EAXREVERB_GAINHF, r.gainHF);		//Set default parameters
	checkErrorLog("Error while assigning reverb gainHF: " + r.gainHF);
	EFX10.alEffectf(reverbSlot, EFX10.AL_EAXREVERB_DECAY_TIME, r.decayTime);		//Set default parameters
	checkErrorLog("Error while assigning reverb decayTime: " + r.decayTime);
	EFX10.alEffectf(reverbSlot, EFX10.AL_EAXREVERB_DECAY_HFRATIO, r.decayHFRatio);		//Set default parameters
	checkErrorLog("Error while assigning reverb decayHFRatio: " + r.decayHFRatio);
	EFX10.alEffectf(reverbSlot, EFX10.AL_EAXREVERB_REFLECTIONS_GAIN, r.reflectionsGain);		//Set default parameters
	checkErrorLog("Error while assigning reverb reflectionsGain: " + r.reflectionsGain);
	EFX10.alEffectf(reverbSlot, EFX10.AL_EAXREVERB_LATE_REVERB_GAIN, r.lateReverbGain);		//Set default parameters
	checkErrorLog("Error while assigning reverb lateReverbGain: " + r.lateReverbGain);
	EFX10.alEffectf(reverbSlot, EFX10.AL_EAXREVERB_LATE_REVERB_DELAY, r.lateReverbDelay);		//Set default parameters
	checkErrorLog("Error while assigning reverb lateReverbDelay: " + r.lateReverbDelay);
	EFX10.alEffectf(reverbSlot, EFX10.AL_EAXREVERB_AIR_ABSORPTION_GAINHF, r.airAbsorptionGainHF);		//Set default parameters
	checkErrorLog("Error while assigning reverb airAbsorptionGainHF: " + r.airAbsorptionGainHF);
	EFX10.alEffectf(reverbSlot, EFX10.AL_EAXREVERB_ROOM_ROLLOFF_FACTOR, r.roomRolloffFactor);		//Set default parameters
	checkErrorLog("Error while assigning reverb roomRolloffFactor: " + r.roomRolloffFactor);
	
	
	//Attach updated effect object
	EFX10.alAuxiliaryEffectSloti(auxFXSlot, EFX10.AL_EFFECTSLOT_EFFECT, reverbSlot);
}