Java Code Examples for org.lwjgl.openal.AL10#alSourcef()
The following examples show how to use
org.lwjgl.openal.AL10#alSourcef() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SoundPhysics.java From Sound-Physics with GNU General Public License v3.0 | 6 votes |
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); }
Example 2
Source File: SoundStore.java From opsu with GNU General Public License v3.0 | 6 votes |
/** * 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)); } } }
Example 3
Source File: SoundStore.java From opsu-dance with GNU General Public License v3.0 | 6 votes |
/** * 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)); } } }
Example 4
Source File: OpenALStreamPlayer.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
/** * Starts the streaming. */ private void startPlayback() { removeBuffers(); AL10.alSourcei(source, AL10.AL_LOOPING, AL10.AL_FALSE); AL10.alSourcef(source, AL10.AL_PITCH, pitch); remainingBufferCount = BUFFER_COUNT; for (int i = 0; i < BUFFER_COUNT; i++) { stream(bufferNames.get(i)); } AL10.alSourceQueueBuffers(source, bufferNames); AL10.alSourcePlay(source); }
Example 5
Source File: AudioImpl.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.openal.Audio#setPosition(float) */ public boolean setPosition(float position) { position = position % length; AL10.alSourcef(store.getSource(index), AL11.AL_SEC_OFFSET, position); if (AL10.alGetError() != 0) { return false; } return true; }
Example 6
Source File: OpenALStreamPlayer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Starts the streaming. */ private void startPlayback() { AL10.alSourcei(source, AL10.AL_LOOPING, AL10.AL_FALSE); AL10.alSourcef(source, AL10.AL_PITCH, pitch); remainingBufferCount = BUFFER_COUNT; for (int i = 0; i < BUFFER_COUNT; i++) { stream(bufferNames.get(i)); } AL10.alSourceQueueBuffers(source, bufferNames); AL10.alSourcePlay(source); }
Example 7
Source File: SoundStore.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Set the music volume of the current playing music. Does NOT affect the global volume * * @param volume The volume for the current playing music */ public void setCurrentMusicVolume(float volume) { if (volume < 0) { volume = 0; } if (volume > 1) { volume = 1; } if (soundWorks) { lastCurrentMusicVolume = volume; AL10.alSourcef(sources.get(0), AL10.AL_GAIN, lastCurrentMusicVolume * musicVolume); } }
Example 8
Source File: SoundStore.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Set the music volume * * @param volume The volume for music */ public void setMusicVolume(float volume) { if (volume < 0) { volume = 0; } if (volume > 1) { volume = 1; } musicVolume = volume; if (soundWorks) { AL10.alSourcef(sources.get(0), AL10.AL_GAIN, lastCurrentMusicVolume * musicVolume); } }
Example 9
Source File: OpenALStreamPlayer.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Starts the streaming. */ private void startPlayback() { removeBuffers(); AL10.alSourcei(source, AL10.AL_LOOPING, AL10.AL_FALSE); AL10.alSourcef(source, AL10.AL_PITCH, pitch); remainingBufferCount = BUFFER_COUNT; for (int i = 0; i < BUFFER_COUNT; i++) { stream(bufferNames.get(i)); } AL10.alSourceQueueBuffers(source, bufferNames); AL10.alSourcePlay(source); }
Example 10
Source File: QueuedAudioPlayer.java From tribaltrouble with GNU General Public License v2.0 | 5 votes |
QueuedAudioPlayer(AudioSource source, AudioParameters params) { super(source, params); this.url = Utils.makeURL((String)params.sound); this.buffer_stream = new ByteBufferOutputStream(true); if ((!params.music && !Settings.getSettings().play_sfx) || this.source == null) { this.ogg_stream = null; this.channels = 0; this.audio = null; return; } if (params.relative) AL10.alSourcei(source.getSource(), AL10.AL_SOURCE_RELATIVE, AL10.AL_TRUE); else AL10.alSourcei(source.getSource(), AL10.AL_SOURCE_RELATIVE, AL10.AL_FALSE); setGain(params.gain); setPos(params.x, params.y, params.z); audio = new Audio(NUM_BUFFERS); IntBuffer al_buffers = audio.getBuffers(); this.ogg_stream = new OGGStream(url); this.channels = ogg_stream.getChannels(); for (int i = 0; i < al_buffers.capacity(); i++) { fillBuffer(al_buffers.get(i)); } AL10.alSourcei(source.getSource(), AL10.AL_LOOPING, AL10.AL_FALSE); AL10.alSourcef(source.getSource(), AL10.AL_ROLLOFF_FACTOR, ROLLOFF_FACTOR); AL10.alSourcef(source.getSource(), AL10.AL_REFERENCE_DISTANCE, params.radius); AL10.alSourcef(source.getSource(), AL10.AL_MIN_GAIN, 0f); AL10.alSourcef(source.getSource(), AL10.AL_MAX_GAIN, 1f); AL10.alSourcef(source.getSource(), AL10.AL_PITCH, params.pitch); AL10.alSourceQueueBuffers(source.getSource(), al_buffers); if (params.music || AudioManager.getManager().startPlaying()) AL10.alSourcePlay(source.getSource()); AudioManager.getManager().registerQueuedPlayer(this); }
Example 11
Source File: OpenALMODPlayer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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); } }
Example 12
Source File: SoundStore.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Set the music volume of the current playing music. Does NOT affect the global volume * * @param volume The volume for the current playing music */ public void setCurrentMusicVolume(float volume) { if (volume < 0) { volume = 0; } if (volume > 1) { volume = 1; } if (soundWorks) { lastCurrentMusicVolume = volume; AL10.alSourcef(sources.get(0), AL10.AL_GAIN, lastCurrentMusicVolume * musicVolume); } }
Example 13
Source File: SoundStore.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
/** * Set the pitch at which the current music is being played * * @param pitch The pitch at which the current music is being played */ public void setMusicPitch(float pitch) { if (soundWorks) { stream.setup(pitch); AL10.alSourcef(sources.get(0), AL10.AL_PITCH, pitch); } }
Example 14
Source File: SoundStore.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
/** * Play the specified buffer as a sound effect with the specified * pitch and gain. * * @param buffer The ID of the buffer to play * @param pitch The pitch to play at * @param gain The gain to play at * @param loop True if the sound should loop * @param x The x position to play the sound from * @param y The y position to play the sound from * @param z The z position to play the sound from * @return source The source that will be used */ int playAsSoundAt(int buffer,float pitch,float gain,boolean loop,float x, float y, float z) { gain *= soundVolume; if (gain == 0) { gain = 0.001f; } if (soundWorks) { if (sounds) { int nextSource = findFreeSource(); if (nextSource == -1) { return -1; } AL10.alSourceStop(sources.get(nextSource)); AL10.alSourcei(sources.get(nextSource), AL10.AL_BUFFER, buffer); AL10.alSourcef(sources.get(nextSource), AL10.AL_PITCH, pitch); AL10.alSourcef(sources.get(nextSource), AL10.AL_GAIN, gain); AL10.alSourcei(sources.get(nextSource), AL10.AL_LOOPING, loop ? AL10.AL_TRUE : AL10.AL_FALSE); sourcePos.clear(); sourceVel.clear(); sourceVel.put(new float[] { 0, 0, 0 }); sourcePos.put(new float[] { x, y, z }); sourcePos.flip(); sourceVel.flip(); AL10.alSource(sources.get(nextSource), AL10.AL_POSITION, sourcePos); AL10.alSource(sources.get(nextSource), AL10.AL_VELOCITY, sourceVel); AL10.alSourcePlay(sources.get(nextSource)); return nextSource; } } return -1; }
Example 15
Source File: SoundStore.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
/** * Set the music volume of the current playing music. Does NOT affect the global volume * * @param volume The volume for the current playing music */ public void setCurrentMusicVolume(float volume) { if (volume < 0) { volume = 0; } if (volume > 1) { volume = 1; } if (soundWorks) { lastCurrentMusicVolume = volume; AL10.alSourcef(sources.get(0), AL10.AL_GAIN, lastCurrentMusicVolume * musicVolume); } }
Example 16
Source File: Mini2DxOpenALAudio.java From mini2Dx with Apache License 2.0 | 5 votes |
public void setSoundPan (long soundId, float pan, float volume) { int sourceId = soundIdToSource.get(soundId, -1); if (sourceId != -1) { AL10.alSource3f(sourceId, AL10.AL_POSITION, MathUtils.cos((pan - 1) * MathUtils.PI / 2), 0, MathUtils.sin((pan + 1) * MathUtils.PI / 2)); AL10.alSourcef(sourceId, AL10.AL_GAIN, volume); } }
Example 17
Source File: LwjglAL.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void alSourcef(int source, int param, float value) { AL10.alSourcef(source, param, value); }
Example 18
Source File: Mini2DxOpenALAudio.java From mini2Dx with Apache License 2.0 | 4 votes |
public void setSoundGain (long soundId, float volume) { Integer sourceId = soundIdToSource.get(soundId); if (sourceId != null) AL10.alSourcef(sourceId, AL10.AL_GAIN, volume); }
Example 19
Source File: SoundStore.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Set the pitch at which the current music is being played * * @param pitch The pitch at which the current music is being played */ public void setMusicPitch(float pitch) { if (soundWorks) { AL10.alSourcef(sources.get(0), AL10.AL_PITCH, pitch); } }
Example 20
Source File: OpenALMODPlayer.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Setup the playback properties * * @param pitch The pitch to play back at * @param gain The volume to play back at */ public void setup(float pitch, float gain) { AL10.alSourcef(source, AL10.AL_PITCH, pitch); AL10.alSourcef(source, AL10.AL_GAIN, gain); }