當前位置: 首頁>>代碼示例>>Java>>正文


Java AL10.alGetBufferi方法代碼示例

本文整理匯總了Java中org.lwjgl.openal.AL10.alGetBufferi方法的典型用法代碼示例。如果您正苦於以下問題:Java AL10.alGetBufferi方法的具體用法?Java AL10.alGetBufferi怎麽用?Java AL10.alGetBufferi使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.lwjgl.openal.AL10的用法示例。


在下文中一共展示了AL10.alGetBufferi方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: AudioImpl

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
 * Create a new sound
 * 
 * @param store The sound store from which the sound was created
 * @param buffer The buffer containing the sound data
 */
AudioImpl(SoundStore store, int buffer) {
	this.store = store;
	this.buffer = buffer;
	
	int bytes = AL10.alGetBufferi(buffer, AL10.AL_SIZE);
	int bits = AL10.alGetBufferi(buffer, AL10.AL_BITS);
	int channels = AL10.alGetBufferi(buffer, AL10.AL_CHANNELS);
	int freq = AL10.alGetBufferi(buffer, AL10.AL_FREQUENCY);
	
	int samples = bytes / (bits / 8);
	length = (samples / (float) freq) / channels;
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:19,代碼來源:AudioImpl.java

示例2: update

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
 * Poll the bufferNames - check if we need to fill the bufferNames with another
 * section. 
 * 
 * Most of the time this should be reasonably quick
 */
public void update() {
	if (done) {
		return;
	}

	float sampleRate = audio.getRate();
	float sampleSize;
	if (audio.getChannels() > 1) {
		sampleSize = 4; // AL10.AL_FORMAT_STEREO16
	} else {
		sampleSize = 2; // AL10.AL_FORMAT_MONO16
	}
	
	int processed = AL10.alGetSourcei(source, AL10.AL_BUFFERS_PROCESSED);
	while (processed > 0) {
		unqueued.clear();
		AL10.alSourceUnqueueBuffers(source, unqueued);
		
		int bufferIndex = unqueued.get(0);

		float bufferLength = (AL10.alGetBufferi(bufferIndex, AL10.AL_SIZE) / sampleSize) / sampleRate;
		positionOffset += bufferLength;
		
        if (stream(bufferIndex)) {			
        	AL10.alSourceQueueBuffers(source, unqueued);
        } else {
        	remainingBufferCount--;
        	if (remainingBufferCount == 0) {
        		done = true;
        	}
        }
        processed--;
	}
	
	int state = AL10.alGetSourcei(source, AL10.AL_SOURCE_STATE);
    
    if (state != AL10.AL_PLAYING) {
    	AL10.alSourcePlay(source);
    }
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:47,代碼來源:OpenALStreamPlayer.java


注:本文中的org.lwjgl.openal.AL10.alGetBufferi方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。