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


Java AL10類代碼示例

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


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

示例1: update

import org.lwjgl.openal.AL10; //導入依賴的package包/類
public synchronized void update() {
    if (sourceID == -1) return;
    boolean end = false;
    int buffers = AL10.alGetSourcei(sourceID, AL10.AL_BUFFERS_PROCESSED);
    while (buffers-- > 0) {
        int bufferID = AL10.alSourceUnqueueBuffers(sourceID);
        if (bufferID == AL10.AL_INVALID_VALUE) break;
        renderedSeconds += secondsPerBuffer;
        if (end) continue;
        if (fill(bufferID)) {
            AL10.alSourceQueueBuffers(sourceID, bufferID);
        } else {
            end = true;
        }
    }
    if (end && AL10.alGetSourcei(sourceID, AL10.AL_BUFFERS_QUEUED) == 0) {
        stop();
    }
    if (isPlaying && AL10.alGetSourcei(sourceID, AL10.AL_SOURCE_STATE) != AL10.AL_PLAYING)
        AL10.alSourcePlay(sourceID);
}
 
開發者ID:dmitrykolesnikovich,項目名稱:featurea,代碼行數:22,代碼來源:MusicControllerImpl.java

示例2: playAsMusic

import org.lwjgl.openal.AL10; //導入依賴的package包/類
/**
 * Play the specified buffer as music (i.e. use the music channel)
 * 
 * @param buffer The buffer to be played
 * @param pitch The pitch to play the music at
 * @param gain The gaing to play the music at
 * @param loop True if we should loop the music
 */
void playAsMusic(int buffer,float pitch,float gain, boolean loop) {
	paused = false;
	
	setMOD(null);
	
	if (soundWorks) {
		if (currentMusic != -1) {
			AL10.alSourceStop(sources.get(0));
		}
		
		getMusicSource();
		
		AL10.alSourcei(sources.get(0), AL10.AL_BUFFER, buffer);
		AL10.alSourcef(sources.get(0), AL10.AL_PITCH, pitch);
	    AL10.alSourcei(sources.get(0), AL10.AL_LOOPING, loop ? AL10.AL_TRUE : AL10.AL_FALSE);
		
		currentMusic = sources.get(0);
		
		if (!music) {
			pauseLoop();
		} else {
			AL10.alSourcePlay(sources.get(0)); 
		}
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:34,代碼來源:SoundStore.java

示例3: getOggStream

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
 * @return The Sound read from the OGG file
 * @throws IOException Indicates a failure to load the OGG
 */
public Audio getOggStream(URL ref) throws IOException {
	if (!soundWorks) {
		return new NullAudio();
	}
	
	setMOD(null);
	setStream(null);
	
	if (currentMusic != -1) {
		AL10.alSourceStop(sources.get(0));
	}
	
	getMusicSource();
	currentMusic = sources.get(0);
	
	return new StreamSound(new OpenALStreamPlayer(currentMusic, ref));
}
 
開發者ID:imaTowan,項目名稱:Towan,代碼行數:25,代碼來源:SoundStore.java

示例4: cleanUpSource

import org.lwjgl.openal.AL10; //導入依賴的package包/類
/**
 * Clean up the buffers applied to the sound source
 */
private void cleanUpSource() {
	SoundStore store = SoundStore.get();
	
	AL10.alSourceStop(store.getSource(0));
	IntBuffer buffer = BufferUtils.createIntBuffer(1);
	int queued = AL10.alGetSourcei(store.getSource(0), AL10.AL_BUFFERS_QUEUED);
	
	while (queued > 0)
	{
		AL10.alSourceUnqueueBuffers(store.getSource(0), buffer);
		queued--;
	}
	
	AL10.alSourcei(store.getSource(0), AL10.AL_BUFFER, 0);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:19,代碼來源:StreamSound.java

示例5: getOggStream

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
 * @return The Sound read from the OGG file
 * @throws IOException Indicates a failure to load the OGG
 */
public Audio getOggStream(String ref) throws IOException {
	if (!soundWorks) {
		return new NullAudio();
	}
	
	setMOD(null);
	setStream(null);
	
	if (currentMusic != -1) {
		AL10.alSourceStop(sources.get(0));
	}
	
	getMusicSource();
	currentMusic = sources.get(0);
	
	return new StreamSound(new OpenALStreamPlayer(currentMusic, ref));
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:25,代碼來源:SoundStore.java

示例6: init

import org.lwjgl.openal.AL10; //導入依賴的package包/類
/**
* Initialise OpenAL LWJGL styley
*/
  public void init() {
  	try {
	AL.create();
	soundWorks = true;
} catch (LWJGLException e) {
	System.err.println("Failed to initialise LWJGL OpenAL");
	soundWorks = false;
	return;
}

if (soundWorks) {
	IntBuffer sources = BufferUtils.createIntBuffer(1);
	AL10.alGenSources(sources);
	
	if (AL10.alGetError() != AL10.AL_NO_ERROR) {
		System.err.println("Failed to create sources");
		soundWorks = false;
	} else {
		source = sources.get(0);
	}
	
}
  }
 
開發者ID:imaTowan,項目名稱:Towan,代碼行數:27,代碼來源:OpenALMODPlayer.java

示例7: setOrientation

import org.lwjgl.openal.AL10; //導入依賴的package包/類
public void setOrientation(Vector3f orientation){
	if(this.orientation.equals(orientation)){
		return;
	}
	
	oriBuffer.clear();
	oriBuffer.put(new float[]{
			0f,1f,0f,
			orientation.x,
			orientation.y,
			orientation.z
	});
	oriBuffer.flip();
	
	this.orientation.set(orientation);
	
	AL10.alListenerfv(AL10.AL_ORIENTATION, oriBuffer);
}
 
開發者ID:tek256,項目名稱:LD38,代碼行數:19,代碼來源:Listener.java

示例8: setEnvironment

import org.lwjgl.openal.AL10; //導入依賴的package包/類
private static void setEnvironment(int sourceID, float sendGain0, float sendGain1, float sendGain2, float sendGain3, float sendCutoff0, float sendCutoff1,
		float sendCutoff2, float sendCutoff3, float directCutoff, float directGain)
{
	//Set reverb send filter values and set source to send to all reverb fx slots
	EFX10.alFilterf(sendFilter0, EFX10.AL_LOWPASS_GAIN, sendGain0);
	EFX10.alFilterf(sendFilter0, EFX10.AL_LOWPASS_GAINHF, sendCutoff0);
	AL11.alSource3i(sourceID, EFX10.AL_AUXILIARY_SEND_FILTER, auxFXSlot0, 0, sendFilter0);	
	
	EFX10.alFilterf(sendFilter1, EFX10.AL_LOWPASS_GAIN, sendGain1);
	EFX10.alFilterf(sendFilter1, EFX10.AL_LOWPASS_GAINHF, sendCutoff1);
	AL11.alSource3i(sourceID, EFX10.AL_AUXILIARY_SEND_FILTER, auxFXSlot1, 1, sendFilter1);	
	
	EFX10.alFilterf(sendFilter2, EFX10.AL_LOWPASS_GAIN, sendGain2);
	EFX10.alFilterf(sendFilter2, EFX10.AL_LOWPASS_GAINHF, sendCutoff2);
	AL11.alSource3i(sourceID, EFX10.AL_AUXILIARY_SEND_FILTER, auxFXSlot2, 2, sendFilter2);	
	
	EFX10.alFilterf(sendFilter3, EFX10.AL_LOWPASS_GAIN, sendGain3);
	EFX10.alFilterf(sendFilter3, EFX10.AL_LOWPASS_GAINHF, sendCutoff3);
	AL11.alSource3i(sourceID, EFX10.AL_AUXILIARY_SEND_FILTER, auxFXSlot3, 3, sendFilter3);	
	
	EFX10.alFilterf(directFilter0, EFX10.AL_LOWPASS_GAIN, directGain);
	EFX10.alFilterf(directFilter0, EFX10.AL_LOWPASS_GAINHF, directCutoff);
	AL10.alSourcei(sourceID, EFX10.AL_DIRECT_FILTER, directFilter0);
	
	AL10.alSourcef(sourceID, EFX10.AL_AIR_ABSORPTION_FACTOR, SoundPhysicsCore.Config.airAbsorption);
}
 
開發者ID:sonicether,項目名稱:Sound-Physics,代碼行數:27,代碼來源:SoundPhysics.java

示例9: allocate

import org.lwjgl.openal.AL10; //導入依賴的package包/類
private void allocate(){
	ByteBuffer buffer = ResourceLoader.getBytes(path);
	IntBuffer error = BufferUtils.createIntBuffer(1);
	long decoder = stb_vorbis_open_memory(buffer, error, null);
	if(decoder == 0L){
		Application.error("Unable to open STB Vorbis");
		return;
	}
	
	STBVorbisInfo info = STBVorbisInfo.malloc();
	
	stb_vorbis_get_info(decoder, info);
	
	int channels = info.channels();
	int lengthSamples = stb_vorbis_stream_length_in_samples(decoder);
	ShortBuffer pcm = BufferUtils.createShortBuffer(lengthSamples);
	pcm.limit(stb_vorbis_get_samples_short_interleaved(decoder, channels, pcm) * channels);
	stb_vorbis_close(decoder);
	
	AL10.alBufferData(id, info.channels() == 1? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, pcm, info.sample_rate());
}
 
開發者ID:tek256,項目名稱:LD38,代碼行數:22,代碼來源:Sound.java

示例10: 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

示例11: removeBuffers

import org.lwjgl.openal.AL10; //導入依賴的package包/類
/**
 * Clean up the buffers applied to the sound source
 */
private void removeBuffers() {
	IntBuffer buffer = BufferUtils.createIntBuffer(1);
	int queued = AL10.alGetSourcei(source, AL10.AL_BUFFERS_QUEUED);
	
	while (queued > 0)
	{
		AL10.alSourceUnqueueBuffers(source, buffer);
		queued--;
	}
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:14,代碼來源:OpenALStreamPlayer.java

示例12: play

import org.lwjgl.openal.AL10; //導入依賴的package包/類
/**
 * Start this stream playing
 * 
 * @param loop True if the stream should loop 
 * @throws IOException Indicates a failure to read from the stream
 */
public void play(boolean loop) throws IOException {
	this.loop = loop;
	initStreams();
	
	done = false;

	AL10.alSourceStop(source);
	removeBuffers();
	
	startPlayback();
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:18,代碼來源:OpenALStreamPlayer.java

示例13: destroy

import org.lwjgl.openal.AL10; //導入依賴的package包/類
@Override
public void destroy() {
    try {
        if (AL.isCreated()) {
            for (int i = 0; i < music.size(); i++) {
                MusicController musicControllerImpl = music.get(i);
                if (musicControllerImpl != null) {
                    musicControllerImpl.release();
                }
            }
            for (int i = 0, n = allSources.size; i < n; i++) {
                int sourceID = allSources.get(i);
                int state = AL10.alGetSourcei(sourceID, AL10.AL_SOURCE_STATE);
                if (state != AL10.AL_STOPPED) AL10.alSourceStop(sourceID);
                AL10.alDeleteSources(sourceID);
            }
            sourceToSoundId.clear();
            soundIdToSource.clear();
            AL.destroy();
            while (AL.isCreated()) {
                try {
                    Thread.sleep(10);
                } catch (InterruptedException skip) {
                    skip.printStackTrace();
                }
            }
        }
    } catch (UnsatisfiedLinkError e) {
        e.printStackTrace();
    }
}
 
開發者ID:dmitrykolesnikovich,項目名稱:featurea,代碼行數:32,代碼來源:OpenALImpl.java

示例14: setSoundLooping

import org.lwjgl.openal.AL10; //導入依賴的package包/類
public void setSoundLooping(long soundId, boolean looping) {
    if (AL.isCreated()) {
        if (soundIdToSource.containsKey(soundId)) {
            int sourceId = soundIdToSource.get(soundId);
            AL10.alSourcei(sourceId, AL10.AL_LOOPING, looping ? AL10.AL_TRUE : AL10.AL_FALSE);
        }
    }
}
 
開發者ID:dmitrykolesnikovich,項目名稱:featurea,代碼行數:9,代碼來源:OpenALImpl.java

示例15: 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


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