Java Code Examples for org.lwjgl.openal.AL10#alListener()

The following examples show how to use org.lwjgl.openal.AL10#alListener() . 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: AmbientAudio.java    From tribaltrouble with GNU General Public License v2.0 5 votes vote down vote up
public final void updateSoundListener(CameraState camera, HeightMap heightmap) {
	if (AL.isCreated() && Settings.getSettings().play_sfx) {
		AL10.alListener3f(AL10.AL_POSITION, camera.getCurrentX(), camera.getCurrentY(), camera.getCurrentZ());
		camera.updateDirectionAndNormal(f, u, s);
		orientation_buffer.put(0, f.x);
		orientation_buffer.put(1, f.y);
		orientation_buffer.put(2, f.z);
		orientation_buffer.put(3, u.x);
		orientation_buffer.put(4, u.y);
		orientation_buffer.put(5, u.z);
		AL10.alListener(AL10.AL_ORIENTATION, orientation_buffer);

		int meters_per_world = heightmap.getMetersPerWorld();
		float dx = StrictMath.abs(camera.getCurrentX() - meters_per_world/2);
		float dy = StrictMath.abs(camera.getCurrentY() - meters_per_world/2);
		float dr = 2f*(float)Math.sqrt(dx*dx + dy*dy)/meters_per_world; //can use Math here - not gamestate affecting

		// update placement and gain of ambient forest source
		ambient_forest.setPos(0f, 0f, heightmap.getNearestHeight(camera.getCurrentX(), camera.getCurrentY()) - camera.getCurrentZ() + 8f);
		ambient_forest.setGain(AudioPlayer.AUDIO_GAIN_AMBIENT_FOREST * StrictMath.min(1f, StrictMath.max(0f, 1f - dr + 0.5f)));

		// update placement and gain of ambient beach source
		float factor = 1f;
		if (dr != 0)
			factor = 1f/dr - 1f;
		float beach_x = camera.getCurrentX()*factor;
		float beach_y = camera.getCurrentY()*factor;
		float beach_z = heightmap.getNearestHeight(camera.getCurrentX(), camera.getCurrentY()) - camera.getCurrentZ();
		float beach_gain = AudioPlayer.AUDIO_GAIN_AMBIENT_BEACH * StrictMath.min(1f, StrictMath.max(0f, 1f - StrictMath.abs(4f*dr - 3.75f)));
		ambient_beach.setPos(beach_x, beach_y, beach_z);
		ambient_beach.setGain(beach_gain);

		// update placement of ambient wind source
		ambient_wind.setPos(0f, 0f, StrictMath.max(0f, 50f + GameCamera.MAX_Z - camera.getCurrentZ()));
		ambient_wind.setGain(AudioPlayer.AUDIO_GAIN_AMBIENT_WIND);
	}
}
 
Example 2
Source File: Sonics.java    From AnyaBasic with MIT License 4 votes vote down vote up
private void setListenerValues()
{
    AL10.alListener(AL10.AL_POSITION,    listenerPos);
    AL10.alListener(AL10.AL_VELOCITY,    listenerVel);
    AL10.alListener(AL10.AL_ORIENTATION, listenerOri);
}
 
Example 3
Source File: LwjglAL.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void alListener(int param, FloatBuffer data) {
    AL10.alListener(param, data);
}