Class: RbSDL2::Audio::AudioBuffer
- Inherits:
-
Object
- Object
- RbSDL2::Audio::AudioBuffer
- Includes:
- AudioSpecReader
- Defined in:
- lib/rb_sdl2/audio/audio_buffer.rb
Defined Under Namespace
Classes: AudioBufferPointer
Instance Attribute Summary collapse
-
#size ⇒ Object
(also: #length)
readonly
Returns the value of attribute size.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ptr, size, spec) ⇒ AudioBuffer
constructor
A new instance of AudioBuffer.
- #to_ptr ⇒ Object
- #to_str ⇒ Object
Constructor Details
#initialize(ptr, size, spec) ⇒ AudioBuffer
Returns a new instance of AudioBuffer.
23 24 25 26 27 |
# File 'lib/rb_sdl2/audio/audio_buffer.rb', line 23 def initialize(ptr, size, spec) @ptr = ptr @size = size @spec = spec end |
Instance Attribute Details
#size ⇒ Object (readonly) Also known as: length
Returns the value of attribute size.
29 30 31 |
# File 'lib/rb_sdl2/audio/audio_buffer.rb', line 29 def size @size end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
32 33 34 |
# File 'lib/rb_sdl2/audio/audio_buffer.rb', line 32 def spec @spec end |
Class Method Details
.load(obj) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rb_sdl2/audio/audio_buffer.rb', line 11 def load(obj) RbSDL2.open_rw(obj) do |rw| spec = AudioSpec.new buf = ::FFI::MemoryPointer.new(:pointer) len = ::FFI::MemoryPointer.new(:uint32) err = ::SDL::LoadWAV_RW(rw, 0, spec, buf, len) raise RbSDL2Error if err.null? new(AudioBufferPointer.new(buf.read_pointer), len.read_uint32, spec) end end |
Instance Method Details
#to_ptr ⇒ Object
37 |
# File 'lib/rb_sdl2/audio/audio_buffer.rb', line 37 def to_ptr = @ptr |
#to_str ⇒ Object
39 |
# File 'lib/rb_sdl2/audio/audio_buffer.rb', line 39 def to_str = @ptr.read_bytes(size) |