Class: SFML::SoundBuffer

Inherits:
Object
  • Object
show all
Defined in:
lib/sfml/audio.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ SoundBuffer

Returns a new instance of SoundBuffer.


65
66
67
68
69
# File 'lib/sfml/audio.rb', line 65

def initialize(filename)
  @buffer = SFMLImporter.sfSoundBuffer_createFromFile(filename)
  raise"Couldn't load #{filename}" if @buffer.null?
  ObjectSpace.define_finalizer @buffer, SFML::SoundBuffer.dtor
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer


63
64
65
# File 'lib/sfml/audio.rb', line 63

def buffer
  @buffer
end

Class Method Details

.dtorObject


57
58
59
60
61
# File 'lib/sfml/audio.rb', line 57

def self.dtor
  proc { |id|
    SFMLImporter.sfSoundBuffer_destroy(id)
  }
end

Instance Method Details

#get_durationObject


70
71
72
# File 'lib/sfml/audio.rb', line 70

def get_duration
  SFMLImporter.sfSoundBuffer_getDuration(@buffer) / 1000000.0
end