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

项目:PhET    文件:SourceLimitTest.java   
/**
 * Tests the creation of n sources in on go
 */
protected void CreateAllSources() {
    int lastError;

    //make bytbuffer that can hold sourcesToCreate sources
    IntBuffer sources = BufferUtils.createIntBuffer(sourcesToCreate);

    //Create sourcesToCreate sources in one fell swoop
    try {
        sources.position(0).limit(sourcesToCreate);
        AL10.alGenSources(sources);

        //delete sources
        sources.position(0).limit(sourcesToCreate);
        AL10.alDeleteSources(sources);

        System.out.println("created " + sourcesToCreate + " sources successfully!");
    } catch (OpenALException oale) {
        System.out.println("Unable to create " + sourcesToCreate + " sources");
    }
}
项目:Wolf_game    文件:SourceLimitTest.java   
/**
 * Tests the creation of n sources in on go
 */
protected void CreateAllSources() {
    int lastError;

    //make bytbuffer that can hold sourcesToCreate sources
    IntBuffer sources = BufferUtils.createIntBuffer(sourcesToCreate);

    //Create sourcesToCreate sources in one fell swoop
    try {
        sources.position(0).limit(sourcesToCreate);
        AL10.alGenSources(sources);

        //delete sources
        sources.position(0).limit(sourcesToCreate);
        AL10.alDeleteSources(sources);

        System.out.println("created " + sourcesToCreate + " sources successfully!");
    } catch (OpenALException oale) {
        System.out.println("Unable to create " + sourcesToCreate + " sources");
    }
}
项目:GPVM    文件:SourceLimitTest.java   
/**
 * Tests the creation of n sources in on go
 */
protected void CreateAllSources() {
    int lastError;

    //make bytbuffer that can hold sourcesToCreate sources
    IntBuffer sources = BufferUtils.createIntBuffer(sourcesToCreate);

    //Create sourcesToCreate sources in one fell swoop
    try {
        sources.position(0).limit(sourcesToCreate);
        AL10.alGenSources(sources);

        //delete sources
        sources.position(0).limit(sourcesToCreate);
        AL10.alDeleteSources(sources);

        System.out.println("created " + sourcesToCreate + " sources successfully!");
    } catch (OpenALException oale) {
        System.out.println("Unable to create " + sourcesToCreate + " sources");
    }
}
项目:GPVM    文件:SourceLimitTest.java   
/**
 * Tests the creation of n sources in on go
 */
protected void CreateAllSources() {
    int lastError;

    //make bytbuffer that can hold sourcesToCreate sources
    IntBuffer sources = BufferUtils.createIntBuffer(sourcesToCreate);

    //Create sourcesToCreate sources in one fell swoop
    try {
        sources.position(0).limit(sourcesToCreate);
        AL10.alGenSources(sources);

        //delete sources
        sources.position(0).limit(sourcesToCreate);
        AL10.alDeleteSources(sources);

        System.out.println("created " + sourcesToCreate + " sources successfully!");
    } catch (OpenALException oale) {
        System.out.println("Unable to create " + sourcesToCreate + " sources");
    }
}
项目:SpaceStationAlpha    文件:SourceLimitTest.java   
/**
 * Tests the creation of n sources in on go
 */
protected void CreateAllSources() {
    int lastError;

    //make bytbuffer that can hold sourcesToCreate sources
    IntBuffer sources = BufferUtils.createIntBuffer(sourcesToCreate);

    //Create sourcesToCreate sources in one fell swoop
    try {
        sources.position(0).limit(sourcesToCreate);
        AL10.alGenSources(sources);

        //delete sources
        sources.position(0).limit(sourcesToCreate);
        AL10.alDeleteSources(sources);

        System.out.println("created " + sourcesToCreate + " sources successfully!");
    } catch (OpenALException oale) {
        System.out.println("Unable to create " + sourcesToCreate + " sources");
    }
}
项目:TeacherSmash    文件:SourceLimitTest.java   
/**
 * Tests the creation of n sources in on go
 */
protected void CreateAllSources() {
    int lastError;

    //make bytbuffer that can hold sourcesToCreate sources
    IntBuffer sources = BufferUtils.createIntBuffer(sourcesToCreate);

    //Create sourcesToCreate sources in one fell swoop
    try {
        sources.position(0).limit(sourcesToCreate);
        AL10.alGenSources(sources);

        //delete sources
        sources.position(0).limit(sourcesToCreate);
        AL10.alDeleteSources(sources);

        System.out.println("created " + sourcesToCreate + " sources successfully!");
    } catch (OpenALException oale) {
        System.out.println("Unable to create " + sourcesToCreate + " sources");
    }
}
项目:3d-Demo    文件:SourceLimitTest.java   
/**
 * Tests the creation of n sources in on go
 */
protected void CreateAllSources() {
    int lastError;

    //make bytbuffer that can hold sourcesToCreate sources
    IntBuffer sources = BufferUtils.createIntBuffer(sourcesToCreate);

    //Create sourcesToCreate sources in one fell swoop
    try {
        sources.position(0).limit(sourcesToCreate);
        AL10.alGenSources(sources);

        //delete sources
        sources.position(0).limit(sourcesToCreate);
        AL10.alDeleteSources(sources);

        System.out.println("created " + sourcesToCreate + " sources successfully!");
    } catch (OpenALException oale) {
        System.out.println("Unable to create " + sourcesToCreate + " sources");
    }
}
项目:PhET    文件:SourceLimitTest.java   
/**
 * Runs the actual test, using supplied arguments
 */
protected void execute(String[] args) {
    //parse 1st arg to sourcecount
    if (args.length > 0) {
        try {
            sourcesToCreate = Integer.parseInt(args[0]);
        } catch (NumberFormatException nfe) {
            System.out.println(
                "Unable to parse parameter to integer. Defaulting to 64 sources.");
        }
    }

   System.out.print("Creating " + sourcesToCreate + " in one go...");
   try {
     CreateAllSources();
   } catch(OpenALException oale) {
    oale.printStackTrace();
   }


   System.out.print("Creating " + sourcesToCreate + " one at a time...");
   try {
     CreateSourcesStep();
   } catch(Exception e) {
    e.printStackTrace();
   }
    //shutdown
    alExit();
}
项目:PhET    文件:SourceLimitTest.java   
/**
 * Tests if n sources can be created one at a time
 */
protected void CreateSourcesStep() {
    int lastError;
    int sourcesCreated = 0;

    //make bytbuffer that can hold sourcesToCreate sources
    IntBuffer[] sources = new IntBuffer[sourcesToCreate];

    //create the sources
    try {
        for (int i = 0; i < sourcesToCreate; i++) {
            sources[i] = BufferUtils.createIntBuffer(1);
            sources[i].position(0).limit(1);
            AL10.alGenSources(sources[i]);
            if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
                break;
            }
            sourcesCreated++;
        }
    } catch (OpenALException oale) {
        System.out.println("failed to create source: " + (sourcesCreated + 1));         
    }

    //delete allocated sources
    for (int i = 0; i < sourcesCreated; i++) {
        //delete buffers and sources
        sources[i].position(0).limit(1);
        AL10.alDeleteSources(sources[i]);
    }

    if(sourcesCreated != sourcesToCreate) {
      System.out.println("created " + sourcesCreated + " sources before failing");
    } else {
      System.out.println("created " + sourcesCreated + " sources successfully!");
    }
}
项目:tribaltrouble    文件:AudioManager.java   
private final void generateSources(int max) {
    ArrayList list = new ArrayList();
    for (int i = 0; i < max; i++) {
        try {
            AudioSource source = new AudioSource();
            list.add(source);
        } catch (OpenALException e) {
            break;
        }
    }
    sources = new AudioSource[list.size()];
    list.toArray(sources);
}
项目:Wolf_game    文件:SourceLimitTest.java   
/**
 * Runs the actual test, using supplied arguments
 */
protected void execute(String[] args) {
    //parse 1st arg to sourcecount
    if (args.length > 0) {
        try {
            sourcesToCreate = Integer.parseInt(args[0]);
        } catch (NumberFormatException nfe) {
            System.out.println(
                "Unable to parse parameter to integer. Defaulting to 64 sources.");
        }
    }

   System.out.print("Creating " + sourcesToCreate + " in one go...");
   try {
     CreateAllSources();
   } catch(OpenALException oale) {
    oale.printStackTrace();
   }


   System.out.print("Creating " + sourcesToCreate + " one at a time...");
   try {
     CreateSourcesStep();
   } catch(Exception e) {
    e.printStackTrace();
   }
    //shutdown
    alExit();
}
项目:Wolf_game    文件:SourceLimitTest.java   
/**
 * Tests if n sources can be created one at a time
 */
protected void CreateSourcesStep() {
    int lastError;
    int sourcesCreated = 0;

    //make bytbuffer that can hold sourcesToCreate sources
    IntBuffer[] sources = new IntBuffer[sourcesToCreate];

    //create the sources
    try {
        for (int i = 0; i < sourcesToCreate; i++) {
            sources[i] = BufferUtils.createIntBuffer(1);
            sources[i].position(0).limit(1);
            AL10.alGenSources(sources[i]);
            if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
                break;
            }
            sourcesCreated++;
        }
    } catch (OpenALException oale) {
        System.out.println("failed to create source: " + (sourcesCreated + 1));         
    }

    //delete allocated sources
    for (int i = 0; i < sourcesCreated; i++) {
        //delete buffers and sources
        sources[i].position(0).limit(1);
        AL10.alDeleteSources(sources[i]);
    }

    if(sourcesCreated != sourcesToCreate) {
      System.out.println("created " + sourcesCreated + " sources before failing");
    } else {
      System.out.println("created " + sourcesCreated + " sources successfully!");
    }
}
项目:GPVM    文件:SourceLimitTest.java   
/**
 * Runs the actual test, using supplied arguments
 */
protected void execute(String[] args) {
    //parse 1st arg to sourcecount
    if (args.length > 0) {
        try {
            sourcesToCreate = Integer.parseInt(args[0]);
        } catch (NumberFormatException nfe) {
            System.out.println(
                "Unable to parse parameter to integer. Defaulting to 64 sources.");
        }
    }

   System.out.print("Creating " + sourcesToCreate + " in one go...");
   try {
     CreateAllSources();
   } catch(OpenALException oale) {
    oale.printStackTrace();
   }


   System.out.print("Creating " + sourcesToCreate + " one at a time...");
   try {
     CreateSourcesStep();
   } catch(Exception e) {
    e.printStackTrace();
   }
    //shutdown
    alExit();
}
项目:GPVM    文件:SourceLimitTest.java   
/**
 * Tests if n sources can be created one at a time
 */
protected void CreateSourcesStep() {
    int lastError;
    int sourcesCreated = 0;

    //make bytbuffer that can hold sourcesToCreate sources
    IntBuffer[] sources = new IntBuffer[sourcesToCreate];

    //create the sources
    try {
        for (int i = 0; i < sourcesToCreate; i++) {
            sources[i] = BufferUtils.createIntBuffer(1);
            sources[i].position(0).limit(1);
            AL10.alGenSources(sources[i]);
            if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
                break;
            }
            sourcesCreated++;
        }
    } catch (OpenALException oale) {
        System.out.println("failed to create source: " + (sourcesCreated + 1));         
    }

    //delete allocated sources
    for (int i = 0; i < sourcesCreated; i++) {
        //delete buffers and sources
        sources[i].position(0).limit(1);
        AL10.alDeleteSources(sources[i]);
    }

    if(sourcesCreated != sourcesToCreate) {
      System.out.println("created " + sourcesCreated + " sources before failing");
    } else {
      System.out.println("created " + sourcesCreated + " sources successfully!");
    }
}
项目:GPVM    文件:SourceLimitTest.java   
/**
 * Runs the actual test, using supplied arguments
 */
protected void execute(String[] args) {
    //parse 1st arg to sourcecount
    if (args.length > 0) {
        try {
            sourcesToCreate = Integer.parseInt(args[0]);
        } catch (NumberFormatException nfe) {
            System.out.println(
                "Unable to parse parameter to integer. Defaulting to 64 sources.");
        }
    }

   System.out.print("Creating " + sourcesToCreate + " in one go...");
   try {
     CreateAllSources();
   } catch(OpenALException oale) {
    oale.printStackTrace();
   }


   System.out.print("Creating " + sourcesToCreate + " one at a time...");
   try {
     CreateSourcesStep();
   } catch(Exception e) {
    e.printStackTrace();
   }
    //shutdown
    alExit();
}
项目:GPVM    文件:SourceLimitTest.java   
/**
 * Tests if n sources can be created one at a time
 */
protected void CreateSourcesStep() {
    int lastError;
    int sourcesCreated = 0;

    //make bytbuffer that can hold sourcesToCreate sources
    IntBuffer[] sources = new IntBuffer[sourcesToCreate];

    //create the sources
    try {
        for (int i = 0; i < sourcesToCreate; i++) {
            sources[i] = BufferUtils.createIntBuffer(1);
            sources[i].position(0).limit(1);
            AL10.alGenSources(sources[i]);
            if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
                break;
            }
            sourcesCreated++;
        }
    } catch (OpenALException oale) {
        System.out.println("failed to create source: " + (sourcesCreated + 1));         
    }

    //delete allocated sources
    for (int i = 0; i < sourcesCreated; i++) {
        //delete buffers and sources
        sources[i].position(0).limit(1);
        AL10.alDeleteSources(sources[i]);
    }

    if(sourcesCreated != sourcesToCreate) {
      System.out.println("created " + sourcesCreated + " sources before failing");
    } else {
      System.out.println("created " + sourcesCreated + " sources successfully!");
    }
}
项目:SpaceStationAlpha    文件:SourceLimitTest.java   
/**
 * Runs the actual test, using supplied arguments
 */
protected void execute(String[] args) {
    //parse 1st arg to sourcecount
    if (args.length > 0) {
        try {
            sourcesToCreate = Integer.parseInt(args[0]);
        } catch (NumberFormatException nfe) {
            System.out.println(
                "Unable to parse parameter to integer. Defaulting to 64 sources.");
        }
    }

   System.out.print("Creating " + sourcesToCreate + " in one go...");
   try {
     CreateAllSources();
   } catch(OpenALException oale) {
    oale.printStackTrace();
   }


   System.out.print("Creating " + sourcesToCreate + " one at a time...");
   try {
     CreateSourcesStep();
   } catch(Exception e) {
    e.printStackTrace();
   }
    //shutdown
    alExit();
}
项目:SpaceStationAlpha    文件:SourceLimitTest.java   
/**
 * Tests if n sources can be created one at a time
 */
protected void CreateSourcesStep() {
    int lastError;
    int sourcesCreated = 0;

    //make bytbuffer that can hold sourcesToCreate sources
    IntBuffer[] sources = new IntBuffer[sourcesToCreate];

    //create the sources
    try {
        for (int i = 0; i < sourcesToCreate; i++) {
            sources[i] = BufferUtils.createIntBuffer(1);
            sources[i].position(0).limit(1);
            AL10.alGenSources(sources[i]);
            if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
                break;
            }
            sourcesCreated++;
        }
    } catch (OpenALException oale) {
        System.out.println("failed to create source: " + (sourcesCreated + 1));         
    }

    //delete allocated sources
    for (int i = 0; i < sourcesCreated; i++) {
        //delete buffers and sources
        sources[i].position(0).limit(1);
        AL10.alDeleteSources(sources[i]);
    }

    if(sourcesCreated != sourcesToCreate) {
      System.out.println("created " + sourcesCreated + " sources before failing");
    } else {
      System.out.println("created " + sourcesCreated + " sources successfully!");
    }
}
项目:TeacherSmash    文件:SourceLimitTest.java   
/**
 * Runs the actual test, using supplied arguments
 */
protected void execute(String[] args) {
    //parse 1st arg to sourcecount
    if (args.length > 0) {
        try {
            sourcesToCreate = Integer.parseInt(args[0]);
        } catch (NumberFormatException nfe) {
            System.out.println(
                "Unable to parse parameter to integer. Defaulting to 64 sources.");
        }
    }

   System.out.print("Creating " + sourcesToCreate + " in one go...");
   try {
     CreateAllSources();
   } catch(OpenALException oale) {
    oale.printStackTrace();
   }


   System.out.print("Creating " + sourcesToCreate + " one at a time...");
   try {
     CreateSourcesStep();
   } catch(Exception e) {
    e.printStackTrace();
   }
    //shutdown
    alExit();
}
项目:TeacherSmash    文件:SourceLimitTest.java   
/**
 * Tests if n sources can be created one at a time
 */
protected void CreateSourcesStep() {
    int lastError;
    int sourcesCreated = 0;

    //make bytbuffer that can hold sourcesToCreate sources
    IntBuffer[] sources = new IntBuffer[sourcesToCreate];

    //create the sources
    try {
        for (int i = 0; i < sourcesToCreate; i++) {
            sources[i] = BufferUtils.createIntBuffer(1);
            sources[i].position(0).limit(1);
            AL10.alGenSources(sources[i]);
            if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
                break;
            }
            sourcesCreated++;
        }
    } catch (OpenALException oale) {
        System.out.println("failed to create source: " + (sourcesCreated + 1));         
    }

    //delete allocated sources
    for (int i = 0; i < sourcesCreated; i++) {
        //delete buffers and sources
        sources[i].position(0).limit(1);
        AL10.alDeleteSources(sources[i]);
    }

    if(sourcesCreated != sourcesToCreate) {
      System.out.println("created " + sourcesCreated + " sources before failing");
    } else {
      System.out.println("created " + sourcesCreated + " sources successfully!");
    }
}
项目:3d-Demo    文件:SourceLimitTest.java   
/**
 * Runs the actual test, using supplied arguments
 */
protected void execute(String[] args) {
    //parse 1st arg to sourcecount
    if (args.length > 0) {
        try {
            sourcesToCreate = Integer.parseInt(args[0]);
        } catch (NumberFormatException nfe) {
            System.out.println(
                "Unable to parse parameter to integer. Defaulting to 64 sources.");
        }
    }

   System.out.print("Creating " + sourcesToCreate + " in one go...");
   try {
     CreateAllSources();
   } catch(OpenALException oale) {
    oale.printStackTrace();
   }


   System.out.print("Creating " + sourcesToCreate + " one at a time...");
   try {
     CreateSourcesStep();
   } catch(Exception e) {
    e.printStackTrace();
   }
    //shutdown
    alExit();
}
项目:3d-Demo    文件:SourceLimitTest.java   
/**
 * Tests if n sources can be created one at a time
 */
protected void CreateSourcesStep() {
    int lastError;
    int sourcesCreated = 0;

    //make bytbuffer that can hold sourcesToCreate sources
    IntBuffer[] sources = new IntBuffer[sourcesToCreate];

    //create the sources
    try {
        for (int i = 0; i < sourcesToCreate; i++) {
            sources[i] = BufferUtils.createIntBuffer(1);
            sources[i].position(0).limit(1);
            AL10.alGenSources(sources[i]);
            if ((lastError = AL10.alGetError()) != AL10.AL_NO_ERROR) {
                break;
            }
            sourcesCreated++;
        }
    } catch (OpenALException oale) {
        System.out.println("failed to create source: " + (sourcesCreated + 1));         
    }

    //delete allocated sources
    for (int i = 0; i < sourcesCreated; i++) {
        //delete buffers and sources
        sources[i].position(0).limit(1);
        AL10.alDeleteSources(sources[i]);
    }

    if(sourcesCreated != sourcesToCreate) {
      System.out.println("created " + sourcesCreated + " sources before failing");
    } else {
      System.out.println("created " + sourcesCreated + " sources successfully!");
    }
}
项目:Amber-IDE    文件:ALAudio.java   
private int getSource() {
    IntBuffer temp = BufferUtils.createIntBuffer(1);
    try {
        alGenSources(temp);
        if (alGetError() == AL_NO_ERROR) {
            return temp.get(0);
        }
    } catch (OpenALException e) {
    }
    return -1;
}
项目: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();
}
项目: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();
}
项目: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();
}