Search in sources :

Example 6 with ALCdevice

use of org.lwjgl.openal.ALCdevice in project lwjgl by LWJGL.

the class OpenALInfo method printEFXInfo.

private void printEFXInfo() {
    if (!EFXUtil.isEfxSupported()) {
        System.out.println("EFX not available");
        return;
    }
    ALCdevice device = AL.getDevice();
    IntBuffer major = BufferUtils.createIntBuffer(1);
    IntBuffer minor = BufferUtils.createIntBuffer(1);
    IntBuffer sends = BufferUtils.createIntBuffer(1);
    ALC10.alcGetInteger(device, EFX10.ALC_EFX_MAJOR_VERSION, major);
    ALC10.alcGetInteger(device, EFX10.ALC_EFX_MINOR_VERSION, minor);
    if (ALC10.alcGetError(device) == ALC10.ALC_NO_ERROR) {
        System.out.println("EFX version: " + major.get() + "." + minor.get());
    }
    ALC10.alcGetInteger(device, EFX10.ALC_MAX_AUXILIARY_SENDS, sends);
    if (ALC10.alcGetError(device) == ALC10.ALC_NO_ERROR) {
        System.out.println("Max auxiliary sends: " + sends.get());
    }
    System.out.println("Supported filters: ");
    HashMap<String, Integer> filters = new HashMap<String, Integer>();
    filters.put("Low-pass", EFX10.AL_FILTER_LOWPASS);
    filters.put("High-pass", EFX10.AL_FILTER_HIGHPASS);
    filters.put("Band-pass", EFX10.AL_FILTER_BANDPASS);
    Set<Entry<String, Integer>> entries = filters.entrySet();
    for (final Entry<String, Integer> entry : entries) {
        String key = entry.getKey();
        if (EFXUtil.isFilterSupported(entry.getValue()))
            System.out.println("    " + entry.getKey());
    }
    System.out.println("Supported effects: ");
    HashMap<String, Integer> effects = new HashMap<String, Integer>();
    effects.put("EAX Reverb", EFX10.AL_EFFECT_EAXREVERB);
    effects.put("Reverb", EFX10.AL_EFFECT_REVERB);
    effects.put("Chorus", EFX10.AL_EFFECT_CHORUS);
    effects.put("Distortion", EFX10.AL_EFFECT_DISTORTION);
    effects.put("Echo", EFX10.AL_EFFECT_ECHO);
    effects.put("Flanger", EFX10.AL_EFFECT_FLANGER);
    effects.put("Frequency Shifter", EFX10.AL_EFFECT_FREQUENCY_SHIFTER);
    effects.put("Vocal Morpher", EFX10.AL_EFFECT_VOCAL_MORPHER);
    effects.put("Pitch Shifter", EFX10.AL_EFFECT_PITCH_SHIFTER);
    effects.put("Ring Modulator", EFX10.AL_EFFECT_RING_MODULATOR);
    effects.put("Autowah", EFX10.AL_EFFECT_AUTOWAH);
    effects.put("Compressor", EFX10.AL_EFFECT_COMPRESSOR);
    effects.put("Equalizer", EFX10.AL_EFFECT_EQUALIZER);
    entries = effects.entrySet();
    for (final Entry<String, Integer> entry : entries) {
        if (EFXUtil.isEffectSupported(entry.getValue()))
            System.out.println("    " + entry.getKey());
    }
}
Also used : Entry(java.util.Map.Entry) HashMap(java.util.HashMap) IntBuffer(java.nio.IntBuffer) ALCdevice(org.lwjgl.openal.ALCdevice)

Example 7 with ALCdevice

use of org.lwjgl.openal.ALCdevice in project lwjgl by LWJGL.

the class ALCCaptureTest method execute.

/**
	 * Runs the actual test, using supplied arguments
	 */
protected void execute(String[] args) {
    int lastError = ALC10.ALC_NO_ERROR;
    IntBuffer sampleCount = BufferUtils.createIntBuffer(1);
    int state = AL10.AL_PLAYING;
    int FMT = AL10.AL_FORMAT_MONO16;
    int FMTSIZE = 16 / 8;
    int FREQ = 44100;
    int TIME = 5;
    int SAMPS = (FREQ * TIME);
    ByteBuffer buf = BufferUtils.createByteBuffer(SAMPS * FMTSIZE);
    // check that capture is available
    if (!ALC10.alcIsExtensionPresent(AL.getDevice(), "ALC_EXT_CAPTURE")) {
        throw new OpenALException("ALC_EXT_CAPTURE extension not available");
    }
    // get list of devices
    String[] captureDevices = ALC10.alcGetString(null, ALC11.ALC_CAPTURE_DEVICE_SPECIFIER).split("\0");
    System.out.println("Available Capture Devices: ");
    for (int i = 0; i < captureDevices.length; i++) {
        System.out.println(i + ": " + captureDevices[i]);
    }
    String defaultRecorder = ALC10.alcGetString(AL.getDevice(), ALC11.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER);
    System.out.println("Default capture device: " + defaultRecorder);
    ALCdevice device = ALC11.alcCaptureOpenDevice(null, FREQ, FMT, SAMPS);
    if (device != null) {
        // record some sound
        // =====================================
        System.out.print("Recording using " + ALC10.alcGetString(device, ALC11.ALC_CAPTURE_DEVICE_SPECIFIER) + "...");
        ALC11.alcCaptureStart(device);
        while (sampleCount.get(0) < SAMPS) {
            pause(1000);
            ALC10.alcGetInteger(device, ALC11.ALC_CAPTURE_SAMPLES, sampleCount);
        }
        System.out.println("done");
        ALC11.alcCaptureStop(device);
        // capure the samples
        ALC11.alcCaptureSamples(device, buf, SAMPS);
        ALC11.alcCaptureCloseDevice(device);
        // -------------------------------------
        // play back recording
        // ===================
        IntBuffer buffers = BufferUtils.createIntBuffer(1);
        IntBuffer sources = BufferUtils.createIntBuffer(1);
        buffers.position(0).limit(1);
        AL10.alGenBuffers(buffers);
        sources.position(0).limit(1);
        AL10.alGenSources(sources);
        System.out.print("Playing...");
        AL10.alBufferData(buffers.get(0), FMT, buf, FREQ);
        AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffers.get(0));
        AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, AL10.AL_FALSE);
        AL10.alSourcePlay(sources.get(0));
        while (state == AL10.AL_PLAYING) {
            pause(100);
            state = AL10.alGetSourcei(sources.get(0), AL10.AL_SOURCE_STATE);
        }
        System.out.println("done");
        AL10.alDeleteSources(sources);
        AL10.alDeleteBuffers(buffers);
    }
    alExit();
}
Also used : IntBuffer(java.nio.IntBuffer) ALCdevice(org.lwjgl.openal.ALCdevice) ByteBuffer(java.nio.ByteBuffer) OpenALException(org.lwjgl.openal.OpenALException)

Aggregations

ALCdevice (org.lwjgl.openal.ALCdevice)7 IntBuffer (java.nio.IntBuffer)4 ALCcontext (org.lwjgl.openal.ALCcontext)4 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 OpenALException (org.lwjgl.openal.OpenALException)1