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

项目:PhET    文件:OpenALInfo.java   
private void printALCInfo() {
    IntBuffer version = BufferUtils.createIntBuffer(2);
    ALCdevice device;

    if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) {
        if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATE_ALL_EXT")) {
            printDevices(ALC11.ALC_ALL_DEVICES_SPECIFIER, "playback");
        } else {
            printDevices(ALC10.ALC_DEVICE_SPECIFIER, "playback");
        }
        printDevices(ALC11.ALC_CAPTURE_DEVICE_SPECIFIER, "capture");
    } else {
      System.out.println("No device enumeration available");
    }

    device = ALC10.alcGetContextsDevice(ALC10.alcGetCurrentContext());
    checkForErrors();

    System.out.println("Default playback device: " + ALC10.alcGetString(device, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER));

    System.out.println("Default capture device: " + ALC10.alcGetString(device, ALC11.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER));

    ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, version);
    ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, (IntBuffer) version.position(1));
    checkForErrors();

    System.out.println("ALC version: " + version.get(0) + "." + version.get(1));

    System.out.println("ALC extensions:");
    String[] extensions = ALC10.alcGetString(device, ALC10.ALC_EXTENSIONS).split(" ");
    for ( String extension : extensions ) {
        if ( extension.trim().length() == 0 ) {
            continue;
        }
        System.out.println("    " + extension);
    }
    checkForErrors();
}
项目:Wolf_game    文件:OpenALInfo.java   
private void printALCInfo() {
    IntBuffer version = BufferUtils.createIntBuffer(2);
    ALCdevice device;

    if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) {
        if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATE_ALL_EXT")) {
            printDevices(ALC11.ALC_ALL_DEVICES_SPECIFIER, "playback");
        } else {
            printDevices(ALC10.ALC_DEVICE_SPECIFIER, "playback");
        }
        printDevices(ALC11.ALC_CAPTURE_DEVICE_SPECIFIER, "capture");
    } else {
      System.out.println("No device enumeration available");
    }

    device = ALC10.alcGetContextsDevice(ALC10.alcGetCurrentContext());
    checkForErrors();

    System.out.println("Default playback device: " + ALC10.alcGetString(device, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER));

    System.out.println("Default capture device: " + ALC10.alcGetString(device, ALC11.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER));

    ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, version);
    ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, (IntBuffer) version.position(1));
    checkForErrors();

    System.out.println("ALC version: " + version.get(0) + "." + version.get(1));

    System.out.println("ALC extensions:");
    String[] extensions = ALC10.alcGetString(device, ALC10.ALC_EXTENSIONS).split(" ");
    for ( String extension : extensions ) {
        if ( extension.trim().length() == 0 ) {
            continue;
        }
        System.out.println("    " + extension);
    }
    checkForErrors();
}
项目:GPVM    文件:OpenALInfo.java   
private void printALCInfo() {
    IntBuffer version = BufferUtils.createIntBuffer(2);
    ALCdevice device;

    if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) {
        if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATE_ALL_EXT")) {
            printDevices(ALC11.ALC_ALL_DEVICES_SPECIFIER, "playback");
        } else {
            printDevices(ALC10.ALC_DEVICE_SPECIFIER, "playback");
        }
        printDevices(ALC11.ALC_CAPTURE_DEVICE_SPECIFIER, "capture");
    } else {
      System.out.println("No device enumeration available");
    }

    device = ALC10.alcGetContextsDevice(ALC10.alcGetCurrentContext());
    checkForErrors();

    System.out.println("Default playback device: " + ALC10.alcGetString(device, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER));

    System.out.println("Default capture device: " + ALC10.alcGetString(device, ALC11.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER));

    ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, version);
    ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, (IntBuffer) version.position(1));
    checkForErrors();

    System.out.println("ALC version: " + version.get(0) + "." + version.get(1));

    System.out.println("ALC extensions:");
    String[] extensions = ALC10.alcGetString(device, ALC10.ALC_EXTENSIONS).split(" ");
    for ( String extension : extensions ) {
        if ( extension.trim().length() == 0 ) {
            continue;
        }
        System.out.println("    " + extension);
    }
    checkForErrors();
}
项目:GPVM    文件:OpenALInfo.java   
private void printALCInfo() {
    IntBuffer version = BufferUtils.createIntBuffer(2);
    ALCdevice device;

    if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) {
        if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATE_ALL_EXT")) {
            printDevices(ALC11.ALC_ALL_DEVICES_SPECIFIER, "playback");
        } else {
            printDevices(ALC10.ALC_DEVICE_SPECIFIER, "playback");
        }
        printDevices(ALC11.ALC_CAPTURE_DEVICE_SPECIFIER, "capture");
    } else {
      System.out.println("No device enumeration available");
    }

    device = ALC10.alcGetContextsDevice(ALC10.alcGetCurrentContext());
    checkForErrors();

    System.out.println("Default playback device: " + ALC10.alcGetString(device, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER));

    System.out.println("Default capture device: " + ALC10.alcGetString(device, ALC11.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER));

    ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, version);
    ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, (IntBuffer) version.position(1));
    checkForErrors();

    System.out.println("ALC version: " + version.get(0) + "." + version.get(1));

    System.out.println("ALC extensions:");
    String[] extensions = ALC10.alcGetString(device, ALC10.ALC_EXTENSIONS).split(" ");
    for ( String extension : extensions ) {
        if ( extension.trim().length() == 0 ) {
            continue;
        }
        System.out.println("    " + extension);
    }
    checkForErrors();
}
项目:SpaceStationAlpha    文件:OpenALInfo.java   
private void printALCInfo() {
    IntBuffer version = BufferUtils.createIntBuffer(2);
    ALCdevice device;

    if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) {
        if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATE_ALL_EXT")) {
            printDevices(ALC11.ALC_ALL_DEVICES_SPECIFIER, "playback");
        } else {
            printDevices(ALC10.ALC_DEVICE_SPECIFIER, "playback");
        }
        printDevices(ALC11.ALC_CAPTURE_DEVICE_SPECIFIER, "capture");
    } else {
      System.out.println("No device enumeration available");
    }

    device = ALC10.alcGetContextsDevice(ALC10.alcGetCurrentContext());
    checkForErrors();

    System.out.println("Default playback device: " + ALC10.alcGetString(device, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER));

    System.out.println("Default capture device: " + ALC10.alcGetString(device, ALC11.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER));

    ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, version);
    ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, (IntBuffer) version.position(1));
    checkForErrors();

    System.out.println("ALC version: " + version.get(0) + "." + version.get(1));

    System.out.println("ALC extensions:");
    String[] extensions = ALC10.alcGetString(device, ALC10.ALC_EXTENSIONS).split(" ");
    for ( String extension : extensions ) {
        if ( extension.trim().length() == 0 ) {
            continue;
        }
        System.out.println("    " + extension);
    }
    checkForErrors();
}
项目:TeacherSmash    文件:OpenALInfo.java   
private void printALCInfo() {
    IntBuffer version = BufferUtils.createIntBuffer(2);
    ALCdevice device;

    if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) {
        if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATE_ALL_EXT")) {
            printDevices(ALC11.ALC_ALL_DEVICES_SPECIFIER, "playback");
        } else {
            printDevices(ALC10.ALC_DEVICE_SPECIFIER, "playback");
        }
        printDevices(ALC11.ALC_CAPTURE_DEVICE_SPECIFIER, "capture");
    } else {
      System.out.println("No device enumeration available");
    }

    device = ALC10.alcGetContextsDevice(ALC10.alcGetCurrentContext());
    checkForErrors();

    System.out.println("Default playback device: " + ALC10.alcGetString(device, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER));

    System.out.println("Default capture device: " + ALC10.alcGetString(device, ALC11.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER));

    ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, version);
    ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, (IntBuffer) version.position(1));
    checkForErrors();

    System.out.println("ALC version: " + version.get(0) + "." + version.get(1));

    System.out.println("ALC extensions:");
    String[] extensions = ALC10.alcGetString(device, ALC10.ALC_EXTENSIONS).split(" ");
    for ( String extension : extensions ) {
        if ( extension.trim().length() == 0 ) {
            continue;
        }
        System.out.println("    " + extension);
    }
    checkForErrors();
}
项目:3d-Demo    文件:OpenALInfo.java   
private void printALCInfo() {
    IntBuffer version = BufferUtils.createIntBuffer(2);
    ALCdevice device;

    if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATION_EXT")) {
        if(ALC10.alcIsExtensionPresent(null, "ALC_ENUMERATE_ALL_EXT")) {
            printDevices(ALC11.ALC_ALL_DEVICES_SPECIFIER, "playback");
        } else {
            printDevices(ALC10.ALC_DEVICE_SPECIFIER, "playback");
        }
        printDevices(ALC11.ALC_CAPTURE_DEVICE_SPECIFIER, "capture");
    } else {
      System.out.println("No device enumeration available");
    }

    device = ALC10.alcGetContextsDevice(ALC10.alcGetCurrentContext());
    checkForErrors();

    System.out.println("Default playback device: " + ALC10.alcGetString(device, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER));

    System.out.println("Default capture device: " + ALC10.alcGetString(device, ALC11.ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER));

    ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, version);
    ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, (IntBuffer) version.position(1));
    checkForErrors();

    System.out.println("ALC version: " + version.get(0) + "." + version.get(1));

    System.out.println("ALC extensions:");
    String[] extensions = ALC10.alcGetString(device, ALC10.ALC_EXTENSIONS).split(" ");
    for ( String extension : extensions ) {
        if ( extension.trim().length() == 0 ) {
            continue;
        }
        System.out.println("    " + extension);
    }
    checkForErrors();
}
项目:PhET    文件:ALCCaptureTest.java   
/**
 * 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();
}
项目:DynamicSurroundings    文件:SoundManagerReplacement.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public static void configureSound(@Nonnull final SoundSetupEvent event) {
    int totalChannels = -1;

    try {

        final boolean create = !AL.isCreated();
        if (create) {
            AL.create();
            alErrorCheck();
        }

        final IntBuffer ib = BufferUtils.createIntBuffer(1);
        ALC10.alcGetInteger(AL.getDevice(), ALC11.ALC_MONO_SOURCES, ib);
        alErrorCheck();
        totalChannels = ib.get(0);

        if (create)
            AL.destroy();

    } catch (final Throwable e) {
        e.printStackTrace();
    }

    int normalChannelCount = ModOptions.normalSoundChannelCount;
    int streamChannelCount = ModOptions.streamingSoundChannelCount;

    if (ModOptions.autoConfigureChannels && totalChannels > 64) {
        totalChannels = ((totalChannels + 1) * 3) / 4;
        streamChannelCount = Math.min(totalChannels / 5, MAX_STREAM_CHANNELS);
        normalChannelCount = totalChannels - streamChannelCount;
    }

    DSurround.log().info("Sound channels: %d normal, %d streaming (total avail: %s)", normalChannelCount,
            streamChannelCount, totalChannels == -1 ? "UNKNOWN" : Integer.toString(totalChannels));
    SoundSystemConfig.setNumberNormalChannels(normalChannelCount);
    SoundSystemConfig.setNumberStreamingChannels(streamChannelCount);

    // Setup sound buffering
    if (ModOptions.streamBufferCount != 0)
        SoundSystemConfig.setNumberStreamingBuffers(ModOptions.streamBufferCount);
    if (ModOptions.streamBufferSize != 0)
        SoundSystemConfig.setStreamingBufferSize(ModOptions.streamBufferSize * 1024);
    DSurround.log().info("Stream buffers: %d x %d", SoundSystemConfig.getNumberStreamingBuffers(),
            SoundSystemConfig.getStreamingBufferSize());
}
项目:Wolf_game    文件:ALCCaptureTest.java   
/**
 * 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();
}
项目:GPVM    文件:ALCCaptureTest.java   
/**
 * 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();
}
项目:GPVM    文件:ALCCaptureTest.java   
/**
 * 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();
}
项目:SpaceStationAlpha    文件:ALCCaptureTest.java   
/**
 * 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();
}
项目:TeacherSmash    文件:ALCCaptureTest.java   
/**
 * 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();
}
项目: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());
}
项目:3d-Demo    文件:ALCCaptureTest.java   
/**
 * 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();
}