Sha256: 322077be33141c0abc7e1def349d1cb87dea1dd088a31237228384e821d4dbc6
Contents?: true
Size: 1.03 KB
Versions: 5
Compression:
Stored size: 1.03 KB
Contents
# Ruby2D::Sound module Ruby2D class Sound attr_reader :path attr_accessor :data def initialize(path) unless File.exist? path raise Error, "Cannot find audio file `#{path}`" end @path = path unless ext_init(@path) raise Error, "Sound `#{@path}` cannot be created" end end # Play the sound def play ext_play end # Returns the length in seconds def length ext_length end # Get the volume of the sound def volume ext_get_volume end # Set the volume of the sound def volume=(v) # Clamp value to between 0-100 if v < 0 then v = 0 end if v > 100 then v = 100 end ext_set_volume(v) end # Get the volume of the sound mixer def self.mix_volume ext_get_mix_volume end # Set the volume of the sound mixer def self.mix_volume=(v) # Clamp value to between 0-100 if v < 0 then v = 0 end if v > 100 then v = 100 end ext_set_mix_volume(v) end end end
Version data entries
5 entries across 5 versions & 2 rubygems
Version | Path |
---|---|
ruby2d-0.11.3 | lib/ruby2d/sound.rb |
ruby2d-0.11.2 | lib/ruby2d/sound.rb |
ruby2d-rpeck-windows-0.11.1 | lib/ruby2d/sound.rb |
ruby2d-0.11.1 | lib/ruby2d/sound.rb |
ruby2d-0.11.0 | lib/ruby2d/sound.rb |