Module: AudioPlayback
- Defined in:
- lib/audio-playback.rb,
lib/audio-playback/file.rb,
lib/audio-playback/sound.rb,
lib/audio-playback/device.rb,
lib/audio-playback/playback.rb,
lib/audio-playback/position.rb,
lib/audio-playback/commandline.rb,
lib/audio-playback/device/output.rb,
lib/audio-playback/device/stream.rb,
lib/audio-playback/playback/frame.rb,
lib/audio-playback/playback/mixer.rb,
lib/audio-playback/playback/frame_set.rb,
lib/audio-playback/playback/stream_data.rb
Overview
Play audio files
Defined Under Namespace
Modules: Commandline, Device, Playback Classes: File, Position, Sound
Constant Summary collapse
- VERSION =
"0.0.8"
Class Method Summary collapse
-
.ensure_initialized ⇒ Boolean
Ensure that the audio system is initialized.
-
.list_devices ⇒ Array<String>
List the available audio output devices.
-
.play(file_paths, options = {}) ⇒ Object
Convenience method to play an audio file.
Class Method Details
.ensure_initialized ⇒ Boolean
Ensure that the audio system is initialized
58 59 60 |
# File 'lib/audio-playback.rb', line 58 def self.ensure_initialized @initialized ||= FFI::PortAudio::API.Pa_Initialize end |
.list_devices ⇒ Array<String>
List the available audio output devices
52 53 54 |
# File 'lib/audio-playback.rb', line 52 def self.list_devices Device::Output.list end |
.play(file_paths, options = {}) ⇒ Object
Convenience method to play an audio file
42 43 44 45 46 47 48 |
# File 'lib/audio-playback.rb', line 42 def self.play(file_paths, = {}) sounds = Array(file_paths).map { |path| Sound.load(path, ) } requested_device = [:output_device] || [:output] output = Device::Output.by_name(requested_device) || Device::Output.by_id(requested_device) || Device.default_output [:is_looping] ||= [:loop] Playback.play(sounds, output, ) end |