Class: SFML::SoundCone
- Inherits:
-
Object
- Object
- SFML::SoundCone
- Defined in:
- lib/sfml/audio/sound_cone.rb
Overview
Directional-attenuation cone for a 3D sound source. Inside the ‘inner_angle` cone the sound plays at full volume; outside the `outer_angle` cone it’s attenuated by ‘outer_gain`; between the two it’s smoothly interpolated.
Angles are in degrees, measured from the source’s ‘direction` axis. `outer_gain` is a scalar in [0, 1] (0 = silent outside).
sound.direction = [0, 0, -1]
sound.cone = SFML::SoundCone.new(
inner_angle: 30, outer_angle: 90, outer_gain: 0.2,
)
Instance Attribute Summary collapse
-
#inner_angle ⇒ Object
readonly
Returns the value of attribute inner_angle.
-
#outer_angle ⇒ Object
readonly
Returns the value of attribute outer_angle.
-
#outer_gain ⇒ Object
readonly
Returns the value of attribute outer_gain.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(inner_angle:, outer_angle:, outer_gain:) ⇒ SoundCone
constructor
A new instance of SoundCone.
- #to_s ⇒ Object (also: #inspect)
Constructor Details
#initialize(inner_angle:, outer_angle:, outer_gain:) ⇒ SoundCone
Returns a new instance of SoundCone.
17 18 19 20 21 22 |
# File 'lib/sfml/audio/sound_cone.rb', line 17 def initialize(inner_angle:, outer_angle:, outer_gain:) @inner_angle = inner_angle.to_f @outer_angle = outer_angle.to_f @outer_gain = outer_gain.to_f freeze end |
Instance Attribute Details
#inner_angle ⇒ Object (readonly)
Returns the value of attribute inner_angle.
15 16 17 |
# File 'lib/sfml/audio/sound_cone.rb', line 15 def inner_angle @inner_angle end |
#outer_angle ⇒ Object (readonly)
Returns the value of attribute outer_angle.
15 16 17 |
# File 'lib/sfml/audio/sound_cone.rb', line 15 def outer_angle @outer_angle end |
#outer_gain ⇒ Object (readonly)
Returns the value of attribute outer_gain.
15 16 17 |
# File 'lib/sfml/audio/sound_cone.rb', line 15 def outer_gain @outer_gain end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
24 25 26 27 28 29 |
# File 'lib/sfml/audio/sound_cone.rb', line 24 def ==(other) other.is_a?(SoundCone) && inner_angle == other.inner_angle && outer_angle == other.outer_angle && outer_gain == other.outer_gain end |
#hash ⇒ Object
31 |
# File 'lib/sfml/audio/sound_cone.rb', line 31 def hash = [inner_angle, outer_angle, outer_gain].hash |
#to_s ⇒ Object Also known as: inspect
33 34 35 |
# File 'lib/sfml/audio/sound_cone.rb', line 33 def to_s "SoundCone(inner=#{inner_angle}°, outer=#{outer_angle}°, outer_gain=#{outer_gain})" end |