Class: SFML::Sound
- Inherits:
-
Object
- Object
- SFML::Sound
- Defined in:
- lib/sfml/audio.rb
Instance Attribute Summary collapse
-
#sound ⇒ Object
readonly
Returns the value of attribute sound.
Class Method Summary collapse
Instance Method Summary collapse
- #get_buffer ⇒ Object
- #get_loop ⇒ Object
- #get_pitch ⇒ Object
- #get_playing_offset ⇒ Object
- #get_status ⇒ Object
- #get_volume ⇒ Object
-
#initialize(buffer = nil) ⇒ Sound
constructor
A new instance of Sound.
- #initialize_copy(obj) ⇒ Object
- #pause ⇒ Object
- #play ⇒ Object
- #set_buffer(buffer) ⇒ Object
- #set_loop(b) ⇒ Object
- #set_pitch(f) ⇒ Object
- #set_playing_offset(time) ⇒ Object
- #set_volume(f) ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(buffer = nil) ⇒ Sound
Returns a new instance of Sound.
86 87 88 89 90 91 92 93 94 |
# File 'lib/sfml/audio.rb', line 86 def initialize(buffer=nil) @sound = SFMLImporter.sfSound_create() raise "Failed create SFML::Sound" if @sound.null? @buffer = buffer if buffer SFMLImporter.sfSound_setBuffer(@sound, buffer.buffer) end ObjectSpace.define_finalizer @sound, SFML::Sound.dtor end |
Instance Attribute Details
#sound ⇒ Object (readonly)
Returns the value of attribute sound.
84 85 86 |
# File 'lib/sfml/audio.rb', line 84 def sound @sound end |
Class Method Details
.dtor ⇒ Object
77 78 79 80 81 82 |
# File 'lib/sfml/audio.rb', line 77 def self.dtor proc { |id| SFMLImporter.sfSound_stop(id) SFMLImporter.sfSound_destroy(id) } end |
Instance Method Details
#get_buffer ⇒ Object
103 104 105 |
# File 'lib/sfml/audio.rb', line 103 def get_buffer @buffer end |
#get_loop ⇒ Object
128 129 130 |
# File 'lib/sfml/audio.rb', line 128 def get_loop SFMLImporter.sfSound_getLoop(@sound) > 0 end |
#get_pitch ⇒ Object
134 135 136 |
# File 'lib/sfml/audio.rb', line 134 def get_pitch SFMLImporter.sfSound_getPitch(@sound) end |
#get_playing_offset ⇒ Object
146 147 148 |
# File 'lib/sfml/audio.rb', line 146 def SFMLImporter.(@sound) / 1000000.0 end |
#get_status ⇒ Object
115 116 117 118 119 120 121 122 123 124 |
# File 'lib/sfml/audio.rb', line 115 def get_status case SFMLImporter.sfSound_getStatus(@sound) when SFMLImporter::SFSTOPPED :stopped when SFMLImporter::SFPAUSED :paused when SFMLImporter::SFPLAYING :playing end end |
#get_volume ⇒ Object
140 141 142 |
# File 'lib/sfml/audio.rb', line 140 def get_volume SFMLImporter.sfSound_getVolume(@sound) end |
#initialize_copy(obj) ⇒ Object
95 96 97 98 |
# File 'lib/sfml/audio.rb', line 95 def initialize_copy(obj) @sound = SFMLImporter.sfSound_copy(obj.sound) @buffer = obj.buffer end |
#pause ⇒ Object
109 110 111 |
# File 'lib/sfml/audio.rb', line 109 def pause SFMLImporter.sfSound_pause(@sound) end |
#play ⇒ Object
106 107 108 |
# File 'lib/sfml/audio.rb', line 106 def play SFMLImporter.sfSound_play(@sound) end |
#set_buffer(buffer) ⇒ Object
99 100 101 102 |
# File 'lib/sfml/audio.rb', line 99 def set_buffer(buffer) @buffer = buffer SFMLImporter.sfSound_setBuffer(@sound, buffer.buffer) end |
#set_loop(b) ⇒ Object
125 126 127 |
# File 'lib/sfml/audio.rb', line 125 def set_loop(b) SFMLImporter.sfSound_setLoop(@sound, (b ? 1 : 0)) end |
#set_pitch(f) ⇒ Object
131 132 133 |
# File 'lib/sfml/audio.rb', line 131 def set_pitch(f) SFMLImporter.sfSound_setPitch(@sound, f) end |
#set_playing_offset(time) ⇒ Object
143 144 145 |
# File 'lib/sfml/audio.rb', line 143 def (time) SFMLImporter.(@sound, time * 1000000.0) end |
#set_volume(f) ⇒ Object
137 138 139 |
# File 'lib/sfml/audio.rb', line 137 def set_volume(f) SFMLImporter.sfSound_setVolume(@sound, f) end |
#stop ⇒ Object
112 113 114 |
# File 'lib/sfml/audio.rb', line 112 def stop SFMLImporter.sfSound_stop(@sound) end |