当前位置: 首页>>代码示例>>Java>>正文


Java OpenALException类代码示例

本文整理汇总了Java中org.lwjgl.openal.OpenALException的典型用法代码示例。如果您正苦于以下问题:Java OpenALException类的具体用法?Java OpenALException怎么用?Java OpenALException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OpenALException类属于org.lwjgl.openal包,在下文中一共展示了OpenALException类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: CreateAllSources

import org.lwjgl.openal.OpenALException; //导入依赖的package包/类
/**
 * 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");
	}
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:24,代码来源:SourceLimitTest.java

示例2: execute

import org.lwjgl.openal.OpenALException; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:32,代码来源:SourceLimitTest.java

示例3: CreateSourcesStep

import org.lwjgl.openal.OpenALException; //导入依赖的package包/类
/**
 * 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!");
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:39,代码来源:SourceLimitTest.java

示例4: generateSources

import org.lwjgl.openal.OpenALException; //导入依赖的package包/类
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);
}
 
开发者ID:sunenielsen,项目名称:tribaltrouble,代码行数:14,代码来源:AudioManager.java

示例5: getSource

import org.lwjgl.openal.OpenALException; //导入依赖的package包/类
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;
}
 
开发者ID:IvyBits,项目名称:Amber-IDE,代码行数:12,代码来源:ALAudio.java

示例6: execute

import org.lwjgl.openal.OpenALException; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:82,代码来源:ALCCaptureTest.java


注:本文中的org.lwjgl.openal.OpenALException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。