Module: AudioPlayback::Device
- Extended by:
- Device
- Included in:
- Device
- Defined in:
- lib/audio-playback/device.rb,
lib/audio-playback/device/output.rb,
lib/audio-playback/device/stream.rb
Overview
Audio IO devices
Defined Under Namespace
Instance Method Summary collapse
-
#by_id(id) ⇒ Output
Get a device by its ID.
-
#by_name(name) ⇒ Output
Get a device by its name.
-
#default_output ⇒ Output
The system default output.
-
#device_info(id) ⇒ FFI::PortAudio::API::PaDeviceInfo
Get system device info given a device ID.
-
#outputs ⇒ Array<Output>
All output devices.
Instance Method Details
#by_id(id) ⇒ Output
Get a device by its ID
26 27 28 |
# File 'lib/audio-playback/device.rb', line 26 def by_id(id) outputs.find { |device| [device, device.id].include?(id) } end |
#by_name(name) ⇒ Output
Get a device by its name
33 34 35 |
# File 'lib/audio-playback/device.rb', line 33 def by_name(name) outputs.find { |device| device.name == name } end |
#default_output ⇒ Output
The system default output
39 40 41 |
# File 'lib/audio-playback/device.rb', line 39 def default_output by_id(FFI::PortAudio::API.Pa_GetDefaultOutputDevice) end |
#device_info(id) ⇒ FFI::PortAudio::API::PaDeviceInfo
Get system device info given a device ID
46 47 48 |
# File 'lib/audio-playback/device.rb', line 46 def device_info(id) FFI::PortAudio::API.Pa_GetDeviceInfo(id) end |
#outputs ⇒ Array<Output>
All output devices
13 14 15 16 17 18 19 20 21 |
# File 'lib/audio-playback/device.rb', line 13 def outputs AudioPlayback.ensure_initialized if @devices.nil? count = FFI::PortAudio::API.Pa_GetDeviceCount ids = (0..count-1).to_a.select { |id| output?(id) } @devices = ids.map { |id| Output.new(id) } end @devices end |