JOAL v2.6.0-rc-20250706
JOAL, OpenAL® API Binding for Java™ (public API).
Listener.java
Go to the documentation of this file.
1/**
2* Copyright (c) 2010-2023 JogAmp Community. All rights reserved.
3* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7*
8* -Redistribution of source code must retain the above copyright notice,
9* this list of conditions and the following disclaimer.
10*
11* -Redistribution in binary form must reproduce the above copyright notice,
12* this list of conditions and the following disclaimer in the documentation
13* and/or other materials provided with the distribution.
14*
15* Neither the name of Sun Microsystems, Inc. or the names of contributors may
16* be used to endorse or promote products derived from this software without
17* specific prior written permission.
18*
19* This software is provided "AS IS," without a warranty of any kind.
20* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
21* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
22* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS
23* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A
24* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
25* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT
26* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
27* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
28* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS
29* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
30*
31* You acknowledge that this software is not designed or intended for use in the
32* design, construction, operation or maintenance of any nuclear facility.
33*/
34
35package com.jogamp.openal.sound3d;
36
37import com.jogamp.openal.ALConstants;
38
39/**
40 * This class represents the human listener in the Sound3D environment. It
41 * provides methods for controlling the position, orientation as well as other
42 * properties associated with the listener.
43 *
44 * @author Athomas Goldberg, Sven Gothel, et al.
45 */
46public final class Listener {
47 public Listener() {
48 }
49
50 /**
51 * Sets the Gain, or volume of the audio in the environment relative to the
52 * listener
53 *
54 * @param gain the gain, or volume
55 */
56 public void setGain(final float gain) {
58 }
59
60 /**
61 * Gets the value of the gain, or volume of the audio in the environment
62 * relative to the listener.
63 *
64 * @return the gain value.
65 */
66 public float getGain() {
67 final float[] f = new float[1];
69
70 return f[0];
71 }
72
73 /**
74 * Sets the position in (x-y-z coordinates) of the Listener in the Sound3D
75 * environment.
76 *
77 * @param x The position of the listener along the X-axis in the Sound3D
78 * environment
79 * @param y The position of the listener along the Y-axis in the Sound3D
80 * environment
81 * @param z The position of the listener along the Z-axis in the Sound3D
82 * environment
83 */
84 public void setPosition(final float x, final float y, final float z) {
86 }
87
88 /**
89 * Sets the position in (x-y-z coordinates) of the Listener in the Sound3D
90 * environment.
91 *
92 * @param position a Vec3f object containing the x,y and z coordinates of
93 * Listener.
94 */
95 public void setPosition(final Vec3f position) {
96 AudioSystem3D.al.alListener3f(ALConstants.AL_POSITION, position.v1, position.v2, position.v3);
97 }
98
99 /**
100 * Gets the position in (x-y-z coordinates) of the Listener in the Sound3D
101 * environment.
102 *
103 * @return a Vec3f object containing the x,y and z coordinates of
104 * Listener.
105 */
107 Vec3f result = null;
108 final float[] tmp = new float[3];
110 result = new Vec3f(tmp[0], tmp[1], tmp[2]);
111
112 return result;
113 }
114
115 /**
116 * Sets the velocity in (x-y-z coordinates) of the Listener in the Sound3D
117 * environment. Used in determining doppler shift.
118 *
119 * @param velocity a Vec3f object containing the velicity in
120 * x,y and z coordinates of Listener.
121 */
122 public void setVelocity(final Vec3f velocity) {
123 AudioSystem3D.al.alListener3f(ALConstants.AL_VELOCITY, velocity.v1, velocity.v2, velocity.v3);
124 }
125
126 /**
127 * Gets the velocity in (x-y-z coordinates) of the Listener in the Sound3D
128 * environment. Used in determining doppler shift.
129 *
130 * @return a Vec3f object containing the velicity in
131 * x,y and z coordinates of Listener.
132 */
134 Vec3f result = null;
135 final float[] tmp = new float[3];
137 result = new Vec3f(tmp[0], tmp[1], tmp[2]);
138
139 return result;
140 }
141
142 /**
143 * Sets the orientation of the Listener in the Sound3D environment.
144 * Orientation is expressed as `at` and `up` vectors.
145 *
146 * @param orientation The first 3 elements of the array should contain
147 * the `at` vector, the second 3 elements should contain the `up` vector.
148 */
149 public void setOrientation(final float[] orientation) {
151 }
152
153 /**
154 * Gets the orientation of the Listener in the Sound3D environment.
155 * Orientation is expressed as `at` and `up` vectors.
156 *
157 * @return an array containing the orientation of the listener, a pair of 3-float vectors for x,y,z.
158 * The first 3 elements of the array contain the `at` vector, the second 3 elements contain the `up` vector.
159 */
160 public float[] getOrientation() {
161 final float[] tmp = new float[6];
163 return tmp;
164 }
165}
The AudioSystem3D class provides a set of methods for creating and manipulating a 3D audio environmen...
This class represents the human listener in the Sound3D environment.
Definition: Listener.java:46
float getGain()
Gets the value of the gain, or volume of the audio in the environment relative to the listener.
Definition: Listener.java:66
Vec3f getPosition()
Gets the position in (x-y-z coordinates) of the Listener in the Sound3D environment.
Definition: Listener.java:106
Vec3f getVelocity()
Gets the velocity in (x-y-z coordinates) of the Listener in the Sound3D environment.
Definition: Listener.java:133
void setOrientation(final float[] orientation)
Sets the orientation of the Listener in the Sound3D environment.
Definition: Listener.java:149
void setVelocity(final Vec3f velocity)
Sets the velocity in (x-y-z coordinates) of the Listener in the Sound3D environment.
Definition: Listener.java:122
void setPosition(final Vec3f position)
Sets the position in (x-y-z coordinates) of the Listener in the Sound3D environment.
Definition: Listener.java:95
float[] getOrientation()
Gets the orientation of the Listener in the Sound3D environment.
Definition: Listener.java:160
void setGain(final float gain)
Sets the Gain, or volume of the audio in the environment relative to the listener.
Definition: Listener.java:56
void setPosition(final float x, final float y, final float z)
Sets the position in (x-y-z coordinates) of the Listener in the Sound3D environment.
Definition: Listener.java:84
A convenience class representing a 3-element float vector.
Definition: Vec3f.java:42
final float v3
the first element in the vector
Definition: Vec3f.java:50
final float v2
the first element in the vector
Definition: Vec3f.java:47
final float v1
the first element in the vector
Definition: Vec3f.java:44
static final int AL_GAIN
Define "AL_GAIN" with expression '0x100A', CType: int.
static final int AL_ORIENTATION
Define "AL_ORIENTATION" with expression '0x100F', CType: int.
static final int AL_VELOCITY
Define "AL_VELOCITY" with expression '0x1006', CType: int.
static final int AL_POSITION
Define "AL_POSITION" with expression '0x1004', CType: int.
void alListener3f(int param, float value1, float value2, float value3)
Entry point (through function pointer) to C language function: void alListener3f(ALenum param,...
void alGetListenerf(int param, FloatBuffer value)
Entry point (through function pointer) to C language function: void alGetListenerf(ALenum param,...
void alGetListenerfv(int param, FloatBuffer values)
Entry point (through function pointer) to C language function: void alGetListenerfv(ALenum param,...
void alListenerfv(int param, FloatBuffer values)
Entry point (through function pointer) to C language function: void alListenerfv(ALenum param,...
void alListenerf(int param, float value)
Entry point (through function pointer) to C language function: void alListenerf(ALenum param,...