module SF::Listener
#
The audio listener is the point in the scene from where all the sounds are heard
The audio listener defines the global properties of the
audio environment, it defines where and how sounds and musics
are heard. If SF::View
is the eyes of the user, then SF::Listener
is his ears (by the way, they are often linked together --
same position, orientation, etc.).
SF::Listener
is a simple interface, which allows to setup the
listener in the 3D audio environment (position, direction and
up vector), and to adjust the global volume.
Because the listener is unique in the scene, SF::Listener
only
contains static functions and doesn't have to be instantiated.
Usage example:
# Move the listener to the position (1, 0, -5)
SF::Listener.set_position(1, 0, -5)
# Make it face the right axis (1, 0, 0)
SF::Listener.direction = SF.vector3f(1, 0, 0)
# Reduce the global volume
SF::Listener.global_volume = 50
Class methods#
.direction : Vector3f
#
Get the current forward vector of the listener in the scene
Returns: Listener's forward vector (not normalized)
See also: direction=
.direction=(direction : Vector3f)
#
Set the forward vector of the listener in the scene
The direction (also called "at vector") is the vector pointing forward from the listener's perspective. Together with the up vector, it defines the 3D orientation of the listener in the scene. The direction vector doesn't have to be normalized. The default listener's direction is (0, 0, -1).
- direction - New listener's direction
See also: direction
, up_vector=
, position=
.global_volume : Float32
#
Get the current value of the global volume
Returns: Current global volume, in the range 0..100
See also: global_volume=
.global_volume=(volume : Number)
#
Change the global volume of all the sounds and musics
The volume is a number between 0 and 100; it is combined with the individual volume of each sound / music. The default value for the volume is 100 (maximum).
- volume - New global volume, in the range
0..100
See also: global_volume
.position : Vector3f
#
Get the current position of the listener in the scene
Returns: Listener's position
See also: position=
.position=(position : Vector3f)
#
Set the position of the listener in the scene
The default listener's position is (0, 0, 0).
- position - New listener's position
See also: position
, direction=
.set_direction(x : Number, y : Number, z : Number)
#
Set the forward vector of the listener in the scene
The direction (also called "at vector") is the vector pointing forward from the listener's perspective. Together with the up vector, it defines the 3D orientation of the listener in the scene. The direction vector doesn't have to be normalized. The default listener's direction is (0, 0, -1).
- x - X coordinate of the listener's direction
- y - Y coordinate of the listener's direction
- z - Z coordinate of the listener's direction
See also: direction
, up_vector=
, position=
.set_position(x : Number, y : Number, z : Number)
#
Set the position of the listener in the scene
The default listener's position is (0, 0, 0).
- x - X coordinate of the listener's position
- y - Y coordinate of the listener's position
- z - Z coordinate of the listener's position
See also: position
, direction=
.set_up_vector(x : Number, y : Number, z : Number)
#
Set the upward vector of the listener in the scene
The up vector is the vector that points upward from the listener's perspective. Together with the direction, it defines the 3D orientation of the listener in the scene. The up vector doesn't have to be normalized. The default listener's up vector is (0, 1, 0). It is usually not necessary to change it, especially in 2D scenarios.
- x - X coordinate of the listener's up vector
- y - Y coordinate of the listener's up vector
- z - Z coordinate of the listener's up vector
See also: up_vector
, direction=
, position=
.up_vector : Vector3f
#
Get the current upward vector of the listener in the scene
Returns: Listener's upward vector (not normalized)
See also: up_vector=
.up_vector=(up_vector : Vector3f)
#
Set the upward vector of the listener in the scene
The up vector is the vector that points upward from the listener's perspective. Together with the direction, it defines the 3D orientation of the listener in the scene. The up vector doesn't have to be normalized. The default listener's up vector is (0, 1, 0). It is usually not necessary to change it, especially in 2D scenarios.
- up_vector - New listener's up vector
See also: up_vector
, direction=
, position=