Class: AudioPlayback::Playback::StreamData
- Inherits:
-
Object
- Object
- AudioPlayback::Playback::StreamData
- Extended by:
- Forwardable
- Defined in:
- lib/audio-playback/playback/stream_data.rb
Overview
Playback data for the Device::Stream
Instance Attribute Summary collapse
-
#num_frames ⇒ Object
readonly
Returns the value of attribute num_frames.
Class Method Summary collapse
-
.to_pointer(playback) ⇒ FFI::Pointer
A C pointer version of the audio data.
Instance Method Summary collapse
-
#initialize(playback) ⇒ StreamData
constructor
A new instance of StreamData.
-
#reset ⇒ Object
Reset the stream metadata.
-
#to_pointer ⇒ FFI::Pointer
A C pointer version of the audio data.
Constructor Details
#initialize(playback) ⇒ StreamData
Returns a new instance of StreamData.
22 23 24 25 |
# File 'lib/audio-playback/playback/stream_data.rb', line 22 def initialize(playback) @playback = playback populate end |
Instance Attribute Details
#num_frames ⇒ Object (readonly)
Returns the value of attribute num_frames.
10 11 12 |
# File 'lib/audio-playback/playback/stream_data.rb', line 10 def num_frames @num_frames end |
Class Method Details
.to_pointer(playback) ⇒ FFI::Pointer
A C pointer version of the audio data
16 17 18 19 |
# File 'lib/audio-playback/playback/stream_data.rb', line 16 def self.to_pointer(playback) stream_data = new(playback) stream_data.to_pointer end |
Instance Method Details
#reset ⇒ Object
Reset the stream metadata
29 30 31 32 |
# File 'lib/audio-playback/playback/stream_data.rb', line 29 def reset [:is_eof, :pointer].each { |key| (key, 0.0) } true end |
#to_pointer ⇒ FFI::Pointer
A C pointer version of the audio data
36 37 38 39 40 41 42 |
# File 'lib/audio-playback/playback/stream_data.rb', line 36 def to_pointer if @pointer.nil? @pointer = FFI::LibC.malloc(@playback.data_size) @pointer.write_array_of_float(@data.flatten) end @pointer end |