sfml3.rb

Class: SFML::SoundSourceCone

Inherits:
Object
  • Object
show all
Defined in:
ext/audio/sound_source_cone.c,
ext/audio/sound_source_cone.c

Overview

A directional attenuation cone for a SoundSource (SoundSource#cone) or the Listener (Listener.cone): within inner_angle degrees of the facing direction the source is heard at full volume; beyond outer_angle degrees it is heard at outer_gain volume, with a smooth transition in between.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#new(inner_angle, outer_angle, outer_gain) ⇒ SoundSourceCone

Creates a directional attenuation cone with the given angles and gain.



51
52
53
54
55
56
57
58
59
# File 'ext/audio/sound_source_cone.c', line 51

static VALUE SoundSourceCone_initialize(VALUE self, VALUE rb_inner, VALUE rb_outer, VALUE rb_gain) {
    sfSoundSourceCone cone = {.innerAngle = (float)NUM2DBL(rb_inner),
                              .outerAngle = (float)NUM2DBL(rb_outer),
                              .outerGain = (float)NUM2DBL(rb_gain)};

    ((SoundSourceCone*)Get_SoundSourceCone_Struct(self))->cone = cone;

    return self;
}

Instance Attribute Details

#inner_angle ⇒ Float

Returns the inner cone angle in degrees.

Returns:

  • (Float)

Returns:

  • (Float) —

    angle, in degrees, of the inner cone within which the source is heard at full volume



165
166
167
# File 'ext/audio/sound_source_cone.c', line 165

static VALUE SoundSourceCone_get_inner_angle(VALUE self) {
    return DBL2NUM(((SoundSourceCone*)Get_SoundSourceCone_Struct(self))->cone.innerAngle);
}

#outer_angle ⇒ Float

Returns the outer cone angle in degrees.

Returns:

  • (Float)

Returns:

  • (Float) —

    angle, in degrees, of the outer cone beyond which the source is heard at outer_gain volume



165
166
167
# File 'ext/audio/sound_source_cone.c', line 165

static VALUE SoundSourceCone_get_outer_angle(VALUE self) {
    return DBL2NUM(((SoundSourceCone*)Get_SoundSourceCone_Struct(self))->cone.outerAngle);
}

#outer_gain ⇒ Float

Returns the gain applied outside the outer cone.

Returns:

  • (Float)

Returns:

  • (Float) —

    volume factor applied outside the outer cone



165
166
167
# File 'ext/audio/sound_source_cone.c', line 165

static VALUE SoundSourceCone_get_outer_gain(VALUE self) {
    return DBL2NUM(((SoundSourceCone*)Get_SoundSourceCone_Struct(self))->cone.outerGain);
}

Instance Method Details

#==(other) ⇒ Boolean

Returns true if other is a cone with the same angles and gain.

Returns:

  • (Boolean)

Returns:

  • (Boolean)


151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'ext/audio/sound_source_cone.c', line 151

static VALUE SoundSourceCone_eql(VALUE self, VALUE rb_other) {
    sfSoundSourceCone a = ((SoundSourceCone*)Get_SoundSourceCone_Struct(self))->cone;
    sfSoundSourceCone b;

    if (!rb_obj_is_kind_of(rb_other, rb_cSoundSourceCone)) {
        return Qfalse;
    }

    b = ((SoundSourceCone*)Get_SoundSourceCone_Struct(rb_other))->cone;

    return BOOL2RB(a.innerAngle == b.innerAngle && a.outerAngle == b.outerAngle &&
                   a.outerGain == b.outerGain);
}

#to_a ⇒ Array, Float

Returns the cone's three components as an Array.

Returns ].

Returns:

  • (Array, Float, Float) —

    ]

Returns:

  • (Array<Float>) —

    [inner_angle, outer_angle, outer_gain]



137
138
139
140
141
142
# File 'ext/audio/sound_source_cone.c', line 137

static VALUE SoundSourceCone_to_a(VALUE self) {
    sfSoundSourceCone cone = ((SoundSourceCone*)Get_SoundSourceCone_Struct(self))->cone;

    return rb_ary_new_from_args(3, DBL2NUM(cone.innerAngle), DBL2NUM(cone.outerAngle),
                                DBL2NUM(cone.outerGain));
}