0

flibitEFX source

This commit is contained in:
2017-05-12 01:49:39 +03:00
parent da1de2bc7f
commit c9fa4bf413
8 changed files with 375 additions and 1 deletions

View File

@@ -22,7 +22,6 @@ if (OperatingSystem.current().isWindows()) {
dependencies {
compile (['org.lwjgl.lwjgl:lwjgl:' + lwjgl_ver],
['org.lwjgl.lwjgl:lwjgl_util:' + lwjgl_ver])
compile fileTree (dir: 'lib', include: 'flibitEFX.jar')
}
sourceSets {

Binary file not shown.

View File

@@ -0,0 +1,71 @@
/*
* Copyright (C) 2011 Ethan "flibitijibibo" Lee
*
* This file is part of flibitEFX.
*
* flibitEFX is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* flibitEFX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with flibitEFX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.flibitijibibo.flibitEFX;
import org.lwjgl.openal.EFX10;
/**
* @author Ethan "flibitijibibo" Lee
*/
public abstract class EFXEffect {
private int slotIndex;
private int effectIndex;
/** Constructor creates an EFX effect slot containing an effect.
* @param efxEffect The EFX10 effect type (i.e. EFX10.AL_EFFECT_REVERB)
*/
public EFXEffect(int efxEffect) {
slotIndex = EFX10.alGenAuxiliaryEffectSlots();
effectIndex = EFX10.alGenEffects();
// TODO: Check to see if efxEffect is a valid AL_EFFECT_TYPE.
EFX10.alEffecti(effectIndex, EFX10.AL_EFFECT_TYPE, efxEffect);
EFX10.alAuxiliaryEffectSloti(slotIndex, EFX10.AL_EFFECTSLOT_EFFECT, effectIndex);
}
/** Unloads the EFX effect and effect slot. */
public void killEffect() {
EFX10.alDeleteEffects(effectIndex);
EFX10.alDeleteAuxiliaryEffectSlots(slotIndex);
}
/** Returns the index of the EFX effect slot.
* @return The index of the EFX effect slot
*/
public int getIndex() {
return slotIndex;
}
/** Applies an effect property to this EFX effect.
* @param passedProperty The EFX10 effect property
* @param passedValue The EFX10 effect value
*/
protected void addEffectf(int passedProperty, float passedValue) {
EFX10.alEffectf(effectIndex, passedProperty, passedValue);
}
/** Applies an effect property to this EFX effect.
* @param passedProperty The EFX10 effect property
* @param passedValue The EFX10 effect value
*/
protected void addEffecti(int passedProperty, int passedValue) {
EFX10.alEffecti(effectIndex, passedProperty, passedValue);
}
}

View File

@@ -0,0 +1,93 @@
/*
* Copyright (C) 2011 Ethan "flibitijibibo" Lee
*
* This file is part of flibitEFX.
*
* flibitEFX is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* flibitEFX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with flibitEFX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.flibitijibibo.flibitEFX;
import org.lwjgl.openal.EFX10;
/**
* @author Ethan "flibitijibibo" Lee
*/
public class EFXEffectEcho extends EFXEffect {
/** Constructor creates a generic echo effect. */
public EFXEffectEcho() {
super(EFX10.AL_EFFECT_ECHO);
}
/** Sets the amount of high frequency damping to apply to the echo effect.
* @param passedValue The new damping value to apply to the echo effect
*/
public void setDamping(float passedValue) {
if (passedValue < EFX10.AL_ECHO_MIN_DAMPING)
addEffectf(EFX10.AL_ECHO_DAMPING, EFX10.AL_ECHO_MIN_DAMPING);
else if (passedValue > EFX10.AL_ECHO_MAX_DAMPING)
addEffectf(EFX10.AL_ECHO_DAMPING, EFX10.AL_ECHO_MAX_DAMPING);
else
addEffectf(EFX10.AL_ECHO_DAMPING, passedValue);
}
/** Sets the echo effect's delay time.
* @param passedValue The echo effect's new delay time
*/
public void setDelay(float passedValue) {
if (passedValue < EFX10.AL_ECHO_MIN_DELAY)
addEffectf(EFX10.AL_ECHO_DELAY, EFX10.AL_ECHO_MIN_DELAY);
else if (passedValue > EFX10.AL_ECHO_MAX_DELAY)
addEffectf(EFX10.AL_ECHO_DELAY, EFX10.AL_ECHO_MAX_DELAY);
else
addEffectf(EFX10.AL_ECHO_DELAY, passedValue);
}
/** Sets the amount of feedback to echo back.
* @param passedValue The new feedback volume of the echo effect
*/
public void setFeedback(float passedValue) {
if (passedValue < EFX10.AL_ECHO_MIN_FEEDBACK)
addEffectf(EFX10.AL_ECHO_FEEDBACK, EFX10.AL_ECHO_MIN_FEEDBACK);
else if (passedValue > EFX10.AL_ECHO_MAX_FEEDBACK)
addEffectf(EFX10.AL_ECHO_FEEDBACK, EFX10.AL_ECHO_MAX_FEEDBACK);
else
addEffectf(EFX10.AL_ECHO_FEEDBACK, passedValue);
}
/** Sets the delay between each echo "tap".
* @param passedValue The new delay time between each echo "tap"
*/
public void setLRDelay(float passedValue) {
if (passedValue < EFX10.AL_ECHO_MIN_LRDELAY)
addEffectf(EFX10.AL_ECHO_LRDELAY, EFX10.AL_ECHO_MIN_LRDELAY);
else if (passedValue > EFX10.AL_ECHO_MAX_LRDELAY)
addEffectf(EFX10.AL_ECHO_LRDELAY, EFX10.AL_ECHO_MAX_LRDELAY);
else
addEffectf(EFX10.AL_ECHO_LRDELAY, passedValue);
}
/** Sets the amount of hard panning allowed for each echo.
* @param passedValue The new level of flexibility for the echo effect's panning
*/
public void setSpread(float passedValue) {
if (passedValue < EFX10.AL_ECHO_MIN_SPREAD)
addEffectf(EFX10.AL_ECHO_SPREAD, EFX10.AL_ECHO_MIN_SPREAD);
else if (passedValue > EFX10.AL_ECHO_MAX_SPREAD)
addEffectf(EFX10.AL_ECHO_SPREAD, EFX10.AL_ECHO_MAX_SPREAD);
else
addEffectf(EFX10.AL_ECHO_SPREAD, passedValue);
}
}

View File

@@ -0,0 +1,35 @@
/*
* Copyright (C) 2011 Ethan "flibitijibibo" Lee
*
* This file is part of flibitEFX.
*
* flibitEFX is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* flibitEFX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with flibitEFX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.flibitijibibo.flibitEFX;
import org.lwjgl.openal.EFX10;
/**
* @author Ethan "flibitijibibo" Lee
*/
public class EFXEffectReverb extends EFXEffect {
/** Constructor creates a generic reverb effect. */
public EFXEffectReverb() {
super(EFX10.AL_EFFECT_REVERB);
}
// TODO: Add methods for all AL_EFFECT_REVERB properties.
}

View File

@@ -0,0 +1,70 @@
/*
* Copyright (C) 2011 Ethan "flibitijibibo" Lee
*
* This file is part of flibitEFX.
*
* flibitEFX is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* flibitEFX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with flibitEFX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.flibitijibibo.flibitEFX;
import org.lwjgl.openal.EFX10;
/**
* @author Ethan "flibitijibibo" Lee
*/
public class EFXEffectRingModulator extends EFXEffect {
public static final int SINUSOID = EFX10.AL_RING_MODULATOR_SINUSOID;
public static final int SAWTOOTH = EFX10.AL_RING_MODULATOR_SAWTOOTH;
public static final int SQUARE = EFX10.AL_RING_MODULATOR_SQUARE;
/** Constructor creates a generic ring modulator effect. */
public EFXEffectRingModulator() {
super(EFX10.AL_EFFECT_RING_MODULATOR);
}
/** Sets the frequency of the ring modulator.
* @param passedValue The new frequency of the ring modulator
*/
public void setFrequency(float passedValue) {
if (passedValue > EFX10.AL_RING_MODULATOR_MAX_FREQUENCY)
addEffectf(EFX10.AL_RING_MODULATOR_FREQUENCY, EFX10.AL_RING_MODULATOR_MAX_FREQUENCY);
else if (passedValue < EFX10.AL_RING_MODULATOR_MIN_FREQUENCY)
addEffectf(EFX10.AL_RING_MODULATOR_FREQUENCY, EFX10.AL_RING_MODULATOR_MIN_FREQUENCY);
else
addEffectf(EFX10.AL_RING_MODULATOR_FREQUENCY, passedValue);
}
/** Sets the high-pass cutoff for the ring modulator.
* @param passedValue The new cutoff value for the ring modulator high-pass filter
*/
public void setHighPassCutoff(float passedValue) {
if (passedValue > EFX10.AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF)
addEffectf(EFX10.AL_RING_MODULATOR_HIGHPASS_CUTOFF, EFX10.AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF);
else if (passedValue < EFX10.AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF)
addEffectf(EFX10.AL_RING_MODULATOR_HIGHPASS_CUTOFF, EFX10.AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF);
else
addEffectf(EFX10.AL_RING_MODULATOR_HIGHPASS_CUTOFF, passedValue);
}
/** Sets the waveform of the ring modulator.
* @param waveform Should be EFXEffectRingModulator.SINUSOID, SAWTOOTH or SQUARE
*/
public void setWaveform(int waveform) {
if (waveform != SINUSOID && waveform != SAWTOOTH && waveform != SQUARE)
return;
addEffecti(EFX10.AL_RING_MODULATOR_WAVEFORM, waveform);
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright (C) 2011 Ethan "flibitijibibo" Lee
*
* This file is part of flibitEFX.
*
* flibitEFX is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* flibitEFX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with flibitEFX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.flibitijibibo.flibitEFX;
import org.lwjgl.openal.EFX10;
/**
* @author Ethan "flibitijibibo" Lee
*/
public abstract class EFXFilter {
private int filterIndex;
/** Constructor creates an EFX effect slot containing a filter.
* @param efxFilter The EFX10 filter type (i.e. EFX10.AL_FILTER_HIGHPASS)
*/
public EFXFilter(int efxFilter) {
filterIndex = EFX10.alGenFilters();
// TODO: Check to see if efxFilter is a valid AL_FILTER_TYPE.
EFX10.alFilteri(filterIndex, EFX10.AL_FILTER_TYPE, efxFilter);
}
/** Unloads the EFX filter. */
public void killFilter() {
EFX10.alDeleteFilters(filterIndex);
}
/** Returns the index of the EFX filter.
* @return The index of the EFX filter
*/
public int getIndex() {
return filterIndex;
}
/** Applies a filter property to this EFX filter.
* @param passedProperty The EFX10 filter property
* @param passedValue The EFX10 filter value
*/
protected void addFilter(int passedProperty, float passedValue) {
EFX10.alFilterf(filterIndex, passedProperty, passedValue);
}
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (C) 2011 Ethan "flibitijibibo" Lee
*
* This file is part of flibitEFX.
*
* flibitEFX is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* flibitEFX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with flibitEFX. If not, see <http://www.gnu.org/licenses/>.
*/
package com.flibitijibibo.flibitEFX;
import org.lwjgl.openal.EFX10;
/**
* @author Ethan "flibitijibibo" Lee
*/
public class EFXFilterLowPass extends EFXFilter {
/** Constructor creates a generic low-pass filter. */
public EFXFilterLowPass() {
super(EFX10.AL_FILTER_LOWPASS);
}
/** Sets the gain of the low-pass filter.
* @param passedValue The new value of the low-pass filter gain
*/
public void setGain(float passedValue) {
addFilter(EFX10.AL_LOWPASS_GAIN, passedValue);
}
/** Sets the gain of the low-pass filter's high frequencies.
* @param passedValue The new value of the low-pass filter's HF gain
*/
public void setGainHF(float passedValue) {
addFilter(EFX10.AL_LOWPASS_GAINHF, passedValue);
}
}