Class: Ray::Sound
- Inherits:
-
AudioSource
- Object
- AudioSource
- Ray::Sound
- Defined in:
- lib/ray/sound.rb,
ext/sound.c
Instance Method Summary collapse
- #buffer ⇒ Ray::SoundBuffer?
-
#buffer=(buf) ⇒ Object
Sets a new buffer for the sound.
-
#duration ⇒ Float
Duration of the sound.
-
#initialize(arg = nil) ⇒ Sound
constructor
A new instance of Sound.
- #looping=(val) ⇒ Object
-
#looping? ⇒ true, false
True if the sound is looping.
-
#pause ⇒ Object
Pauses the sound.
-
#play ⇒ Object
Plays the sound (or resume from a pause).
- #pretty_print(q) ⇒ Object
-
#seek(time) ⇒ Object
(also: #time=)
Seeks to a specific time in the sound.
-
#stop ⇒ Object
Stops the sound.
-
#time ⇒ Float
Current playing offset, in seconds.
Constructor Details
#initialize(arg = nil) ⇒ Sound
Returns a new instance of Sound.
3 4 5 6 7 8 9 10 11 |
# File 'lib/ray/sound.rb', line 3 def initialize(arg = nil) case arg when String then self.buffer = SoundBufferSet[arg] when SoundBuffer then self.buffer = arg when nil then return else self.buffer = SoundBuffer.new(arg) end end |
Instance Method Details
#buffer ⇒ Ray::SoundBuffer?
36 37 38 39 |
# File 'ext/sound.c', line 36 static VALUE ray_sound_buffer(VALUE self) { return rb_iv_get(self, "@buffer"); } |
#buffer=(buf) ⇒ Object
28 29 30 31 32 33 |
# File 'ext/sound.c', line 28
static
VALUE ray_sound_set_buffer(VALUE self, VALUE buf) {
say_sound_set_buffer(ray_rb2sound(self), ray_rb2sound_buffer(buf));
rb_iv_set(self, "@buffer", buf);
return buf;
}
|
#duration ⇒ Float
Returns Duration of the sound. 0 when no buffer is attached to the sound.
74 75 76 77 |
# File 'ext/sound.c', line 74 static VALUE ray_sound_duration(VALUE self) { return rb_float_new(say_sound_get_duration(ray_rb2sound(self))); } |
#looping=(val) ⇒ Object
48 49 50 51 52 |
# File 'ext/sound.c', line 48
static
VALUE ray_sound_set_looping(VALUE self, VALUE val) {
say_sound_set_looping(ray_rb2sound(self), RTEST(val));
return val;
}
|
#looping? ⇒ true, false
Returns True if the sound is looping.
42 43 44 45 |
# File 'ext/sound.c', line 42 static VALUE ray_sound_is_looping(VALUE self) { return say_sound_is_looping(ray_rb2sound(self)) ? Qtrue : Qfalse; } |
#pause ⇒ Object
Pauses the sound. Can be resumed using play.
87 88 89 90 91 |
# File 'ext/sound.c', line 87 static VALUE ray_sound_pause(VALUE self) { say_sound_pause(ray_rb2sound(self)); return self; } |
#play ⇒ Object
Plays the sound (or resume from a pause)
80 81 82 83 84 |
# File 'ext/sound.c', line 80 static VALUE ray_sound_play(VALUE self) { say_sound_play(ray_rb2sound(self)); return self; } |
#pretty_print(q) ⇒ Object
13 14 15 |
# File 'lib/ray/sound.rb', line 13 def pretty_print(q) super q, ["time", "duration", "looping?", "buffer"] end |
#seek(time) ⇒ Object Also known as: time=
59 60 61 62 63 |
# File 'ext/sound.c', line 59
static
VALUE ray_sound_seek(VALUE self, VALUE time) {
say_sound_seek(ray_rb2sound(self), NUM2DBL(time));
return time;
}
|
#stop ⇒ Object
Stops the sound
94 95 96 97 98 |
# File 'ext/sound.c', line 94 static VALUE ray_sound_stop(VALUE self) { say_sound_stop(ray_rb2sound(self)); return self; } |
#time ⇒ Float
Returns current playing offset, in seconds.
66 67 68 69 |
# File 'ext/sound.c', line 66 static VALUE ray_sound_time(VALUE self) { return rb_float_new(say_sound_get_time(ray_rb2sound(self))); } |