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


Java ALC10.alcGetString方法代码示例

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


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

示例1: SoundPlayer

import org.lwjgl.openal.ALC10; //导入方法依赖的package包/类
public SoundPlayer() {
    this.device = ALC10.alcOpenDevice((ByteBuffer) null);
    if (this.device == 0) {
        throw new IllegalStateException("Failed to open the default device.");
    }
    this.context = ALC10.alcCreateContext(this.device, (IntBuffer) null);
    if (this.context == 0) {
        throw new IllegalStateException("no context?");
    }
    ALC10.alcMakeContextCurrent(this.context);
    ALCCapabilities deviceCaps = ALC.createCapabilities(this.device);
    AL.createCapabilities(deviceCaps);
    String deviceSpecifier = ALC10.alcGetString(this.device, ALC10.ALC_DEVICE_SPECIFIER);
    System.err.println("Using device " + deviceSpecifier);
    System.out.println("ALC_FREQUENCY: " + alcGetInteger(this.device, ALC_FREQUENCY) + "Hz");
    System.out.println("ALC_REFRESH: " + alcGetInteger(this.device, ALC_REFRESH) + "Hz");
    System.out.println("ALC_SYNC: " + (alcGetInteger(this.device, ALC_SYNC) == ALC_TRUE));
    System.out.println("ALC_MONO_SOURCES: " + alcGetInteger(this.device, ALC_MONO_SOURCES));
    System.out.println("ALC_STEREO_SOURCES: " + alcGetInteger(this.device, ALC_STEREO_SOURCES));
}
 
开发者ID:TechShroom,项目名称:EmergencyLanding,代码行数:21,代码来源:SoundPlayer.java

示例2: execute

import org.lwjgl.openal.ALC10; //导入方法依赖的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

示例3: main

import org.lwjgl.openal.ALC10; //导入方法依赖的package包/类
public static void main(String[] args) {
	System.setProperty("org.lwjgl.librarypath", new File("natives/windows").getAbsolutePath());
	String deviceName = ALC10.alcGetString(0, ALC10.ALC_DEFAULT_DEVICE_SPECIFIER);
	long device = ALC10.alcOpenDevice(deviceName);
	long context = ALC10.alcCreateContext(device, new int[] {0});
	ALC10.alcMakeContextCurrent(context);
	ALCCapabilities alcCaps = ALC.createCapabilities(device);
	ALCapabilities alCaps = AL.createCapabilities(alcCaps);

	if (alCaps.OpenAL10) {
		String file = "C:\\Users\\Isaac\\Desktop\\workspace\\assets\\audio\\gunshot2.ogg";

		MemoryStack.stackPush();
		IntBuffer channelsBuf = MemoryStack.stackMallocInt(1);
		MemoryStack.stackPush();
		IntBuffer sampleRateBuf = MemoryStack.stackMallocInt(1);

		ShortBuffer audioBuffer = STBVorbis.stb_vorbis_decode_filename(file, channelsBuf, sampleRateBuf);

		int channels = channelsBuf.get();
		int sampleRate = sampleRateBuf.get();

		MemoryStack.stackPop();
		MemoryStack.stackPop();

		int format = -1;
		if (channels == 1) {
			format = AL10.AL_FORMAT_MONO16;
		} else if (channels == 2) {
			format = AL10.AL_FORMAT_STEREO16;
		}

		int buffer = AL10.alGenBuffers();

		AL10.alBufferData(buffer, format, audioBuffer, sampleRate);

		Stdlib.free(audioBuffer);

		int[] sources = new int[4];
		AL10.alGenSources(sources);

		for (int source : sources) {
			AL10.alSourcei(source, AL10.AL_BUFFER, buffer);
			AL10.alSourcei(source, AL10.AL_LOOPING, AL10.AL_TRUE);
		}

		float length = (float) (AL10.alGetBufferi(buffer, AL10.AL_SIZE) / 2 / channels) / sampleRate;

		try {
			AL10.alSourcePlay(sources[0]);
			Thread.sleep((long) (length * 250));
			AL10.alSourcePlay(sources[1]);
			Thread.sleep((long) (length * 250));
			AL10.alSourcePlay(sources[2]);
			Thread.sleep((long) (length * 250));
			AL10.alSourcePlay(sources[3]);
		} catch (InterruptedException e) {
			e.printStackTrace();
		} finally {}

		new Scanner(System.in).nextLine();

		AL10.alSourceStopv(sources);
		AL10.alDeleteSources(sources);
		AL10.alDeleteBuffers(buffer);
	}

	ALC10.alcDestroyContext(context);
	ALC10.alcCloseDevice(device);
	ALC.destroy();
}
 
开发者ID:warlockcodes,项目名称:Null-Engine,代码行数:72,代码来源:Test.java


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