sfml3.rb

Module: SFML::Listener

Defined in:
ext/audio/listener.c,
ext/audio/listener.c

Overview

Module functions controlling the single global audio listener: its position, orientation and volume, against which every SoundSource's spatialization is computed.

Class Method Summary collapse

Class Method Details

.cone ⇒ SoundSourceCone

Returns the listener's directional attenuation cone.

Returns:

Returns:



124
125
126
127
128
129
# File 'ext/audio/listener.c', line 124

static VALUE Listener_cone(VALUE module) {
    sfListenerCone cone = sfListener_getCone();

    return sound_source_cone_to_rb(
        (sfSoundSourceCone){cone.innerAngle, cone.outerAngle, cone.outerGain});
}

.cone=(value) ⇒ SoundSourceCone

Sets the listener's directional attenuation cone.

Returns:

Returns:



138
139
140
141
142
143
144
# File 'ext/audio/listener.c', line 138

static VALUE Listener_set_cone(VALUE module, VALUE rb_value) {
    sfSoundSourceCone cone = sound_source_cone_from_rb(rb_value);

    sfListener_setCone((sfListenerCone){cone.innerAngle, cone.outerAngle, cone.outerGain});

    return rb_value;
}

.direction ⇒ Vector3

Returns the direction the listener is facing, used for spatialization.

Returns:

Returns:



58
59
60
# File 'ext/audio/listener.c', line 58

static VALUE Listener_direction(VALUE module) {
    return vec3f_to_rb(sfListener_getDirection());
}

.direction=(value) ⇒ Vector3

Sets the direction the listener is facing.

Returns:

Returns:



69
70
71
72
# File 'ext/audio/listener.c', line 69

static VALUE Listener_set_direction(VALUE module, VALUE rb_value) {
    sfListener_setDirection(vec3f_from_rb(rb_value));
    return rb_value;
}

.global_volume ⇒ Float

Returns the global volume applied to every sound source in the scene.

Returns:

  • (Float)

Returns:

  • (Float) —

    0 to 100



14
15
16
# File 'ext/audio/listener.c', line 14

static VALUE Listener_global_volume(VALUE module) {
    return DBL2NUM(sfListener_getGlobalVolume());
}

.global_volume=(value) ⇒ Float

Sets the global volume all sound sources are scaled by.

Returns:

  • (Float)

Returns:

  • (Float) —

    value



25
26
27
28
# File 'ext/audio/listener.c', line 25

static VALUE Listener_set_global_volume(VALUE module, VALUE rb_value) {
    sfListener_setGlobalVolume((float)NUM2DBL(rb_value));
    return rb_value;
}

.position ⇒ Vector3

Returns the listener's position in the 3D audio scene.

Returns:

Returns:



36
37
38
# File 'ext/audio/listener.c', line 36

static VALUE Listener_position(VALUE module) {
    return vec3f_to_rb(sfListener_getPosition());
}

.position=(value) ⇒ Vector3

Sets the listener's position in the 3D audio scene.

Returns:

Returns:



47
48
49
50
# File 'ext/audio/listener.c', line 47

static VALUE Listener_set_position(VALUE module, VALUE rb_value) {
    sfListener_setPosition(vec3f_from_rb(rb_value));
    return rb_value;
}

.up_vector ⇒ Vector3

Returns the listener's up vector, defining its vertical orientation.

Returns:

Returns:



102
103
104
# File 'ext/audio/listener.c', line 102

static VALUE Listener_up_vector(VALUE module) {
    return vec3f_to_rb(sfListener_getUpVector());
}

.up_vector=(value) ⇒ Vector3

Sets the listener's up vector, defining its vertical orientation.

Returns:

Returns:



113
114
115
116
# File 'ext/audio/listener.c', line 113

static VALUE Listener_set_up_vector(VALUE module, VALUE rb_value) {
    sfListener_setUpVector(vec3f_from_rb(rb_value));
    return rb_value;
}

.velocity ⇒ Vector3

Returns the listener's velocity, used for Doppler calculations.

Returns:

Returns:



80
81
82
# File 'ext/audio/listener.c', line 80

static VALUE Listener_velocity(VALUE module) {
    return vec3f_to_rb(sfListener_getVelocity());
}

.velocity=(value) ⇒ Vector3

Sets the listener's velocity for Doppler calculations.

Returns:

Returns:



91
92
93
94
# File 'ext/audio/listener.c', line 91

static VALUE Listener_set_velocity(VALUE module, VALUE rb_value) {
    sfListener_setVelocity(vec3f_from_rb(rb_value));
    return rb_value;
}