Class: Ray::AudioSource

Inherits:
Object
  • Object
show all
Defined in:
ext/audio_source.c

Instance Method Summary collapse

Instance Method Details

#attenuationFloat

Returns The source’s attenuation.

Returns:

  • (Float)

    The source’s attenuation



136
137
138
139
140
# File 'ext/audio_source.c', line 136

static
VALUE ray_audio_source_attenuation(VALUE self) {
  say_audio_source *source = ray_rb2audio_source(self);
  return rb_float_new(say_audio_source_get_attenuation(source));
}

#attenuation=(attenuation) ⇒ Object

Sets the attenuation of a sound.

Parameters:

  • atenuation (Float)

    New attenuation factor of the sound. 0 will prevent the sound from being attenuated, 100 would make the sound be attenuated much more quickly.



149
150
151
152
153
154
# File 'ext/audio_source.c', line 149

static
VALUE ray_audio_source_set_attenuation(VALUE self, VALUE att) {
  rb_check_frozen(self);
  say_audio_source_set_attenuation(ray_rb2audio_source(self), NUM2DBL(att));
  return att;
}

#min_distanceFloat

Returns the source’s minimal distance.

Returns:

  • (Float)

    the source’s minimal distance.



113
114
115
116
117
# File 'ext/audio_source.c', line 113

static
VALUE ray_audio_source_min_distance(VALUE self) {
  say_audio_source *source = ray_rb2audio_source(self);
  return rb_float_new(say_audio_source_get_min_distance(source));
}

#min_distance=(dist) ⇒ Object

Sets the sounds minimal distance.

Parameters:

  • dist (Float)

    the distance beyond which the source’s volume will decrease. Defaulted to 1.



125
126
127
128
129
130
131
132
133
# File 'ext/audio_source.c', line 125

static
VALUE ray_audio_source_set_min_distance(VALUE self, VALUE dist) {
  rb_check_frozen(self);

  say_audio_source *source = ray_rb2audio_source(self);
  say_audio_source_set_min_distance(source, NUM2DBL(dist));

  return dist;
}

#pitchFloat

Returns The pitch of the source.

Returns:

  • (Float)

    The pitch of the source.



42
43
44
45
46
# File 'ext/audio_source.c', line 42

static
VALUE ray_audio_source_pitch(VALUE self) {
  say_audio_source *source = ray_rb2audio_source(self);
  return rb_float_new(say_audio_source_get_pitch(source));
}

#pitch=(pitch) ⇒ Object

Sets the pitch of the sound.

Parameters:

  • pitch (Float)

    the pitch value, which makes a sound more acute or grave and also affects playing speed. Defaulted to 1.



54
55
56
57
58
59
60
61
62
# File 'ext/audio_source.c', line 54

static
VALUE ray_audio_source_set_pitch(VALUE self, VALUE pitch) {
  rb_check_frozen(self);

  say_audio_source *source = ray_rb2audio_source(self);
  say_audio_source_set_pitch(source, NUM2DBL(pitch));

  return pitch;
}

#posRay::Vector3

Returns The position of the source.

Returns:



65
66
67
68
69
# File 'ext/audio_source.c', line 65

static
VALUE ray_audio_source_pos(VALUE self) {
  say_audio_source *source = ray_rb2audio_source(self);
  return ray_vector3_to_rb(say_audio_source_get_pos(source));
}

#pos=(pos) ⇒ Object

Sets the position of the sound.

Parameters:

  • pos (Ray::Vector3, #to_vector3)

    The position of the source.



76
77
78
79
80
81
82
83
84
# File 'ext/audio_source.c', line 76

static
VALUE ray_audio_source_set_pos(VALUE self, VALUE pos) {
  rb_check_frozen(self);

  say_audio_source *source = ray_rb2audio_source(self);
  say_audio_source_set_pos(source, ray_convert_to_vector3(pos));

  return pos;
}

#relative=(rel) ⇒ Object

Sets whether the sound should be relative.

Parameters:

  • rel (true, false)

    Whether the source position should be relative to the listener’s.



102
103
104
105
106
107
108
109
110
# File 'ext/audio_source.c', line 102

static
VALUE ray_audio_source_set_relative(VALUE self, VALUE val) {
  rb_check_frozen(self);

  say_audio_source *source = ray_rb2audio_source(self);
  say_audio_source_set_relative(source, RTEST(val));

  return val;
}

#relative?true, false

as opposed to being absolute.

Returns:

  • (true, false)

    True if the source position is relative to the listener,



90
91
92
93
94
# File 'ext/audio_source.c', line 90

static
VALUE ray_audio_source_is_relative(VALUE self) {
  say_audio_source *source = ray_rb2audio_source(self);
  return say_audio_source_get_relative(source) ? Qtrue : Qfalse;
}

#statusSymbol

Returns Playing status. One of playing, paused, stopped.

Returns:

  • (Symbol)

    Playing status. One of playing, paused, stopped.



157
158
159
160
161
162
163
164
165
166
# File 'ext/audio_source.c', line 157

static
VALUE ray_audio_source_status(VALUE self) {
  switch (say_audio_source_get_status(ray_rb2audio_source(self))) {
  case SAY_STATUS_PAUSED:  return RAY_SYM("paused");
  case SAY_STATUS_PLAYING: return RAY_SYM("playing");
  case SAY_STATUS_STOPPED: return RAY_SYM("stopped");
  }

  return Qnil; /* should never happen */
}

#volumeFloat

Returns Volume of the source, between 0 and 100.

Returns:

  • (Float)

    Volume of the source, between 0 and 100.



20
21
22
23
24
# File 'ext/audio_source.c', line 20

static
VALUE ray_audio_source_volume(VALUE self) {
  say_audio_source *source = ray_rb2audio_source(self);
  return rb_float_new(say_audio_source_get_volume(source));
}

#volume=(vol) ⇒ Object

Sets the volume of the source.

Parameters:

  • vol (Float)

    The new volume of the source.



31
32
33
34
35
36
37
38
39
# File 'ext/audio_source.c', line 31

static
VALUE ray_audio_source_set_volume(VALUE self, VALUE value) {
  rb_check_frozen(self);

  say_audio_source *source = ray_rb2audio_source(self);
  say_audio_source_set_volume(source, NUM2DBL(value));

  return value;
}