diff --git a/build.gradle b/build.gradle index 6e79482..b0269b9 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { diff --git a/lib/flibitEFX.jar b/lib/flibitEFX.jar deleted file mode 100644 index 4ec6859..0000000 Binary files a/lib/flibitEFX.jar and /dev/null differ diff --git a/src/com/flibitijibibo/flibitEFX/EFXEffect.java b/src/com/flibitijibibo/flibitEFX/EFXEffect.java new file mode 100644 index 0000000..0522e92 --- /dev/null +++ b/src/com/flibitijibibo/flibitEFX/EFXEffect.java @@ -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 . + */ + +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); + } +} \ No newline at end of file diff --git a/src/com/flibitijibibo/flibitEFX/EFXEffectEcho.java b/src/com/flibitijibibo/flibitEFX/EFXEffectEcho.java new file mode 100644 index 0000000..9e46ef3 --- /dev/null +++ b/src/com/flibitijibibo/flibitEFX/EFXEffectEcho.java @@ -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 . + */ + +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); + } +} \ No newline at end of file diff --git a/src/com/flibitijibibo/flibitEFX/EFXEffectReverb.java b/src/com/flibitijibibo/flibitEFX/EFXEffectReverb.java new file mode 100644 index 0000000..87b13c0 --- /dev/null +++ b/src/com/flibitijibibo/flibitEFX/EFXEffectReverb.java @@ -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 . + */ + +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. +} \ No newline at end of file diff --git a/src/com/flibitijibibo/flibitEFX/EFXEffectRingModulator.java b/src/com/flibitijibibo/flibitEFX/EFXEffectRingModulator.java new file mode 100644 index 0000000..78d3d7b --- /dev/null +++ b/src/com/flibitijibibo/flibitEFX/EFXEffectRingModulator.java @@ -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 . + */ + +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); + } +} \ No newline at end of file diff --git a/src/com/flibitijibibo/flibitEFX/EFXFilter.java b/src/com/flibitijibibo/flibitEFX/EFXFilter.java new file mode 100644 index 0000000..6f708a5 --- /dev/null +++ b/src/com/flibitijibibo/flibitEFX/EFXFilter.java @@ -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 . + */ + +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); + } +} \ No newline at end of file diff --git a/src/com/flibitijibibo/flibitEFX/EFXFilterLowPass.java b/src/com/flibitijibibo/flibitEFX/EFXFilterLowPass.java new file mode 100644 index 0000000..1c7858d --- /dev/null +++ b/src/com/flibitijibibo/flibitEFX/EFXFilterLowPass.java @@ -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 . + */ + +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); + } +} \ No newline at end of file