Class: Rubyboy::Raylib::Audio
- Inherits:
-
Object
- Object
- Rubyboy::Raylib::Audio
- Includes:
- Rubyboy::Raylib
- Defined in:
- lib/rubyboy/raylib/audio.rb
Constant Summary collapse
- MAX_SAMPLES =
512
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize ⇒ Audio
constructor
A new instance of Audio.
- #play(samples) ⇒ Object
Constructor Details
#initialize ⇒ Audio
Returns a new instance of Audio.
12 13 14 15 16 17 |
# File 'lib/rubyboy/raylib/audio.rb', line 12 def initialize InitAudioDevice() SetAudioStreamBufferSizeDefault(MAX_SAMPLES * 2) @stream = LoadAudioStream(48000, 32, 2) PlayAudioStream(@stream) end |
Instance Method Details
#close ⇒ Object
26 27 28 29 |
# File 'lib/rubyboy/raylib/audio.rb', line 26 def close UnloadAudioStream(@stream) CloseAudioDevice() end |
#play(samples) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/rubyboy/raylib/audio.rb', line 19 def play(samples) samples_pointer = FFI::MemoryPointer.new(:float, samples.size) samples_pointer.put_array_of_float(0, samples) UpdateAudioStream(@stream, samples_pointer, samples.size) end |