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


Java AL10.alGenBuffers方法代碼示例

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


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

示例1: OpenALStreamPlayer

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
 * Create a new player to work on an audio stream
 * 
 * @param source The source on which we'll play the audio
 * @param ref A reference to the audio file to stream
 */
public OpenALStreamPlayer(int source, String ref) {
	this.source = source;
	this.ref = ref;
	
	bufferNames = BufferUtils.createIntBuffer(BUFFER_COUNT);
	AL10.alGenBuffers(bufferNames);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:14,代碼來源:OpenALStreamPlayer.java

示例2: play

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
    * Play a mod or xm track streamed from the specified location
    * 
    * @param module The moudle to play back
    * @param source The OpenAL source to play the music on
    * @param start True if the music should be started
    * @param loop True if the track should be looped
    */
public void play(Module module, int source, boolean loop, boolean start) {
	this.source = source;
	this.loop = loop;
	this.module = module;
	done = false;
	
	ibxm = new IBXM(48000);
	ibxm.set_module(module);
	songDuration = ibxm.calculate_song_duration();

	if (bufferNames != null) {
		AL10.alSourceStop(source);
		bufferNames.flip();
		AL10.alDeleteBuffers(bufferNames);
	}
	
	bufferNames = BufferUtils.createIntBuffer(2);
	AL10.alGenBuffers(bufferNames);
	remainingBufferCount = 2;
	
	for (int i=0;i<2;i++) {
        stream(bufferNames.get(i));
	}
       AL10.alSourceQueueBuffers(source, bufferNames);
	AL10.alSourcef(source, AL10.AL_PITCH, 1.0f);
	AL10.alSourcef(source, AL10.AL_GAIN, 1.0f); 
	
	if (start) {
		AL10.alSourcePlay(source);
	}
}
 
開發者ID:imaTowan,項目名稱:Towan,代碼行數:40,代碼來源:OpenALMODPlayer.java

示例3: Music

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
public Music(String path){
	this.path = path;
	buffers = BufferUtils.createIntBuffer(2);
	AL10.alGenBuffers(buffers);
	decoder = new Decoder(path, buffers);
	
	source = AL10.alGenSources();
	AL10.alGenBuffers(buffers);
	
	musics.add(this);
}
 
開發者ID:tek256,項目名稱:LD38,代碼行數:12,代碼來源:Music.java

示例4: Sound

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
public Sound(String path, SoundType type){
	this.path = path;
	this.type = type;
	
	if(ResourceLoader.exists(path))
		id = AL10.alGenBuffers();
	else
		id = -1;
	
	allocate();
	
	sounds.add(this);
}
 
開發者ID:tek256,項目名稱:LD38,代碼行數:14,代碼來源:Sound.java

示例5: setup

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
protected void setup(byte[] pcm, int channels, int sampleRate) {
    int bytes = pcm.length - (pcm.length % (channels > 1 ? 4 : 2));
    int samples = bytes / (2 * channels);
    duration = samples / (double) sampleRate;
    ByteBuffer buffer = (ByteBuffer) BufferUtils.createByteBuffer(bytes).put(pcm, 0, bytes).flip();
    if (bufferID == -1) {
        bufferID = AL10.alGenBuffers(); // Failed to flush core dump. Minidumps are not enabled by default on client versions of Windows
        AL10.alBufferData(bufferID, channels > 1 ? AL10.AL_FORMAT_STEREO16 : AL10.AL_FORMAT_MONO16, buffer.asShortBuffer(), sampleRate);
    }
}
 
開發者ID:dmitrykolesnikovich,項目名稱:featurea,代碼行數:11,代碼來源:SoundPoolImpl.java

示例6: play

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
@Override
public void play() {
    if (sourceID == -1) {
        sourceID = player.obtainSource(true);
        if (sourceID == -1) return;
        if (buffers == null) {
            buffers = BufferUtils.createIntBuffer(bufferCount);
            AL10.alGenBuffers(buffers);
            if (AL10.alGetError() != AL10.AL_NO_ERROR)
                throw new RuntimeException("Unable to allocate audio buffers.");
        }
        AL10.alSourcei(sourceID, AL10.AL_LOOPING, AL10.AL_FALSE);
        int filled = 0;
        for (int i = 0; i < bufferCount; i++) {
            int bufferID = buffers.get(i);
            if (!fill(bufferID)) break;
            filled++;
            AL10.alSourceQueueBuffers(sourceID, bufferID);
        }
        if (filled == 0) {
        }
        if (AL10.alGetError() != AL10.AL_NO_ERROR) {
            System.err.println("alGetError = " + AL10.alGetError());
        }
    }
    AL10.alSourcePlay(sourceID);
    isPlaying = true;
    player.reload();
}
 
開發者ID:dmitrykolesnikovich,項目名稱:featurea,代碼行數:30,代碼來源:MusicControllerImpl.java

示例7: getWAV

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
 * Get the Sound based on a specified WAV file
 * 
 * @param ref The reference to the WAV file in the classpath
 * @param in The stream to the WAV to load
 * @return The Sound read from the WAV file
 * @throws IOException Indicates a failure to load the WAV
 */
public Audio getWAV(String ref, InputStream in) throws IOException {
	if (!soundWorks) {
		return new NullAudio();
	}
	if (!inited) {
		throw new RuntimeException("Can't load sounds until SoundStore is init(). Use the container init() method.");
	}
	if (deferred) {
		return new DeferredSound(ref, in, DeferredSound.WAV);
	}
	
	int buffer = -1;
	
	if (loaded.get(ref) != null) {
		buffer = ((Integer) loaded.get(ref)).intValue();
	} else {
		try {
			IntBuffer buf = BufferUtils.createIntBuffer(1);
			
			WaveData data = WaveData.create(in);
			AL10.alGenBuffers(buf);
			AL10.alBufferData(buf.get(0), data.format, data.data, data.samplerate);
			
			loaded.put(ref,new Integer(buf.get(0)));
			buffer = buf.get(0);
		} catch (Exception e) {
			Log.error(e);
			IOException x = new IOException("Failed to load: "+ref);
			x.initCause(e);
			
			throw x;
		}
	}
	
	if (buffer == -1) {
		throw new IOException("Unable to load: "+ref);
	}
	
	return new AudioImpl(this, buffer);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:49,代碼來源:SoundStore.java

示例8: getOgg

import org.lwjgl.openal.AL10; //導入方法依賴的package包/類
/**
 * Get the Sound based on a specified OGG file
 * 
 * @param ref The reference to the OGG file in the classpath
 * @param in The stream to the OGG to load
 * @return The Sound read from the OGG file
 * @throws IOException Indicates a failure to load the OGG
 */
public Audio getOgg(String ref, InputStream in) throws IOException {
	if (!soundWorks) {
		return new NullAudio();
	}
	if (!inited) {
		throw new RuntimeException("Can't load sounds until SoundStore is init(). Use the container init() method.");
	}
	if (deferred) {
		return new DeferredSound(ref, in, DeferredSound.OGG);
	}
	
	int buffer = -1;
	
	if (loaded.get(ref) != null) {
		buffer = ((Integer) loaded.get(ref)).intValue();
	} else {
		try {
			IntBuffer buf = BufferUtils.createIntBuffer(1);
			
			OggDecoder decoder = new OggDecoder();
			OggData ogg = decoder.getData(in);
			
			AL10.alGenBuffers(buf);
			AL10.alBufferData(buf.get(0), ogg.channels > 1 ? AL10.AL_FORMAT_STEREO16 : AL10.AL_FORMAT_MONO16, ogg.data, ogg.rate);
			
			loaded.put(ref,new Integer(buf.get(0)));
			                     
			buffer = buf.get(0);
		} catch (Exception e) {
			Log.error(e);
			Sys.alert("Error","Failed to load: "+ref+" - "+e.getMessage());
			throw new IOException("Unable to load: "+ref);
		}
	}
	
	if (buffer == -1) {
		throw new IOException("Unable to load: "+ref);
	}
	
	return new AudioImpl(this, buffer);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:50,代碼來源:SoundStore.java


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